'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 nowString = 'Jetzt'; const minBioLength = 20; const event_persons = (persons) => html`
${serv.fix_dash(serv.person_names_concat(persons))}:
`; const event_time = (event, time) => { const esd = sol.eventStartDate(event); const nowish = luxon.Interval.fromDateTimes(esd.minus({minutes: 1}), esd.plus({minutes: 1})); const stime = nowish.contains(time) ? nowString : esd.setLocale('de').toRelative({base: time, unit: 'minutes'}); return html`
${stime}
`; }; const event_meta = (event, time) => html`
${event_persons(sol.eventPersons(event))}
${serv.fix_dash(sol.eventTitle(event))}
${sol.eventSubtitle(event)}
${event_time(event, time)}
`; const event_description = (event) => { const description = sol.eventAbstract(event); const abstract = sol.eventAbstract(event); const atext = sol.defined(abstract) ? abstract : ""; const dtext = sol.defined(description) ? description : ""; const text = atext.length >= dtext.length ? atext : dtext; return html`
Beschreibung:
${text}
`; }; const event_content = (event) => html`
${event_description(event)}
`; const speaker_info = (speaker, count) => { const name = serv.fix_dash(sol.personName(speaker)); const bio = sol.personBiography(speaker); let inner; if (sol.defined(bio) && bio.length >= minBioLength) { inner = html`
${name}
${bio}
`; } else { inner = html``; } return inner; }; const speaker_meta = (event) => { const speakers = sol.eventPersons(event); const n = speakers.length; return html`
${speakers.map(s => speaker_info(s, n))}
`; }; const event_info = (event, time) => html`
${event_meta(event, time)}
${event_content(event)} ${speaker_meta(event)}
`; const footer = (config) => html``; const update_main_slide = (data, time, config) => { if (sol.defined(data.scheduleData)) { const schedule = data.scheduleData; const thisRoom = config.roomName; const dt = luxon.Duration.fromObject({minutes: 6}); const events = sol.allEvents(schedule); const eventsHere = sol.eventsByRoomName(events, thisRoom); const startingEventsHere = sol.startingEvents(eventsHere, time, dt); const currentEventsHere = sol.currentEvents(eventsHere, time); const endedEventsHere = sol.endedEvents(eventsHere, time, dt); const upcomingEventsHere = sol.distinctEvents(startingEventsHere.concat(currentEventsHere, endedEventsHere)); const inner = html`
${upcomingEventsHere.slice(0,1).map(e => event_info(e, time))} ${footer(config)}
`; // Add main slide to frame const anchorElId = "main"; const el = document.getElementById(anchorElId); preact.render(inner, el); }; }; export { update_main_slide };