'use strict'; import * as sol from "../../solight/sol.js"; import * as serv from "../services/service.js"; import * as music from "./music.js"; const html = htm.bind(preact.h); const max_events = 5; const title_string = 'Nächste Events:'; const local_room = 'Hier'; const this_room = (config) => sol.optional(config.roomName); const this_location = (config) => { const here = this_room(config); return sol.defined(here) ? html`@${here}` : html``; }; const schedule_table_header = () => html`
${title_string}
`; const event_time = (event) => { const esd = sol.eventStartDate(event); const time = esd.setLocale('de').toLocaleString(luxon.DateTime.TIME_24_SIMPLE); return html`
${time}
`; }; const event_location = (event, config) => { const here_room = this_room(config); const event_room = sol.eventRoomName(event); let inner; if (sol.defined(here_room) && (event_room === here_room)) { inner = html`
${local_room}
`; } else { inner = html`
${event_room}
`; } return inner; }; const event_title = (event) => { const title = serv.fix_dash(sol.eventTitle(event)); const ti = serv.track_index(sol.eventTrack(event)); return html`
${title}
`; }; const event_speaker = (event) => { const speaker = serv.fix_dash(serv.person_names_concat(sol.eventPersons(event))); return html`
${speaker}
`; }; const schedule_table_event = (event, config) => html`
${event_time(event)} ${event_location(event, config)}
${event_title(event)} ${event_speaker(event)}
`; const schedule_table_events = (events, config) => html`
${events.map(e => schedule_table_event(e, config))}
`; const schedule_table = (events, config) => html` ${schedule_table_header()} ${schedule_table_events(events, config)}`; const header = (config) => html`
${this_location(config)}
`; const list_track = (track) => html`${track}`; const list_tracks = (tracks) => html`
${tracks.map(t => list_track(t))}
`; const footer = (tracks, config) => html` `; const update_main_slide = (data, time, config) => { // console.log("Updating Main Slide with:"); // console.log(data); // console.log(time); // console.log(config); if (sol.defined(data.scheduleData)) { const schedule = data.scheduleData; // const allDays = sol.allDays(schedule); // const currentDays = sol.currentDays(allDays, time); // const futureDays = sol.futureDays(allDays, time); // const nextDays = currentDays.concat(futureDays); // const nextDaysSorted = sol.sortDaysByStartDate(nextDays, time); // Hack: if we do not have a next day, all days are in the past and it does not matter. // const nextDay = nextDaysSorted.length > 0 ? nextDaysSorted[0] : allDays[0]; const allEvents = sol.allEvents(schedule); const nextEvents = allEvents; //const nextEvents = allEventssol.eventsByDay(allEvents, nextDay); const dt = luxon.Duration.fromObject({minutes: 10}); const startedEvents = sol.startedEvents(nextEvents, time, dt); const futureEvents = sol.futureEvents(nextEvents, time); // const upcomingEvents = futureEvents; // const upcomingEvents = sol.futureEvents(nextEvents, time); const upcomingEvents = sol.distinctEvents(startedEvents.concat(futureEvents)); const upcomingEventsSorted = sol.sortEventsByStartDate(upcomingEvents); const allTracks = sol.allTracks(schedule); const tracks = allTracks.filter(t => t !== "Andere"); // Take first n events const events = upcomingEventsSorted.slice(0, max_events); // Assemble dom const inner = html`
${header(config)} ${schedule_table(events, config)} ${footer(tracks, config)}
`; // Add main slide to info beamer const anchorElId = "main"; const el = document.getElementById(anchorElId); preact.render(inner, el); }; }; export { update_main_slide };