rc3-html-infobeamer/public/main.70ebfdc7bf1b6f07ff5cb8...

190 lines
7.5 KiB
JavaScript
Raw Normal View History

2021-12-24 02:16:26 +01:00
"use strict";
(() => {
2021-12-24 02:28:07 +01:00
// ns-hugo:/home/raoul/rc3_2021/html-infobeamer-content/assets/js/dom.js
2021-12-24 02:16:26 +01:00
var html = htm.bind(preact.h);
var schedule_meta_here_dom = (schedule) => {
let inner = html`${schedule.map((talk) => html`
<div class="talk-here-meta-box">
<div class="speaker">${talk.personnames}:</div>
<div class="title">${talk.title}</div>
<div class="start-duration">
<span class="start">Starting at ${talk.start}</span>
<span class="duration">Duration: ${talk.duration} minutes</span>
</div>
</div>
`)}`;
return inner;
};
var schedule_abstract_here_dom = (schedule) => {
let inner = html``;
let placeHolder = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec ut urna. Curabitur lorem risus, sagittis vitae, accumsan a, iaculis id, metus. Suspendisse potenti. Fusce nonummy commodo dui. Fusce venenatis ligula in pede. Aliquam velit dui, commodo quis, porttitor eget, convallis et, nisi. Nam sed nisl nec elit suscipit ullamcorper. Cras ac enim vel dui vestibulum suscipit. Suspendisse venenatis. Nam pharetra. Pellentesque et arcu. Nam sed nisl nec elit suscipit ullamcorper. Aenean turpis ipsum, rhoncus vitae, posuere vitae, euismod sed, ligula. Integer risus velit, facilisis eget, viverra et, venenatis id, leo. Aenean ligula. Mauris sed nulla quis nisi interdum tempor. Nullam libero nunc, tristique eget, laoreet eu, sagittis id, ante. Aliquam sed erat. Vestibulum viverra varius enim. Donec at diam a tellus dignissim vestibulum. Nullam sapien mauris, venenatis at, fermentum at, tempus eu, urna.";
schedule.forEach((talk) => {
let abstract = talk.abstract !== void 0 ? talk.abstract : placeHolder;
inner = html`<span class="text">${abstract}</span>`;
});
return inner;
};
var schedule_all_list_dom = (schedule) => {
let inner = html`
${schedule.map((talk) => html`
<div class="item">
<div>
<div class="title">${talk.title}</div>
</div>
<div class="details">
<span class="start">${talk.start}</span>
<span class="day">Day ${talk.day}</span>
<span class="stage">${talk.room}</span>
</div>
</div>`)}`;
return inner;
};
var update_schedule_dom = (schedule) => {
const here_roomguid = "";
const here_room = "Chaos-West TV";
const here_number_events = 1;
const all_number_events = 10;
let allData = schedule.slice(0, all_number_events);
let hereData = schedule.filter((i) => i.room === here_room).slice(0, 1);
let nextHereMetaDom = schedule_meta_here_dom(hereData);
let nextHereAbstractDom = schedule_abstract_here_dom(hereData);
let nextAllMetaDom = schedule_all_list_dom(allData);
let inner = html`
<div class="slide">
<div class="schedule">
<div class="left">
<div class="panel meta">
<div class="header">Next Up Here</div>
<div class="content">${nextHereMetaDom}</div>
</div>
<div class="panel abstract">
<div class="header">Abstract</div>
<div class="content">${nextHereAbstractDom}</div>
</div>
</div>
<div class="right">
<div class="panel list">
<div class="header">Next Up at rC3</div>
<div class="content">${nextAllMetaDom}</div>
</div>
</div>
</div>
</div>`;
return inner;
};
var music_playing_now_dom = (music) => {
let inner = html`
<div class="music">
${music.map((current) => html`
<div class="line1">
<span class="header">Now playing:</span>
<span class="license">(${current.license})</span>
</div>
<div class="line2">
<span class="artist">${current.artist}</span>
<span></span>
<span class="title">${current.title}</span>
</div>`)}
</div>`;
return inner;
};
function update_main_slide(data) {
let schedule = data.schedule;
let music = data.music;
let twitter = data.twitter;
let scheduleDom = update_schedule_dom(schedule);
let musicDom = music_playing_now_dom(music);
let twitterDom = void 0;
let inner = html`
${scheduleDom}
${musicDom}
${twitterDom}
`;
const anchorElId = "main";
const el = document.getElementById(anchorElId);
preact.render(inner, el);
}
// <stdin>
var scheduleData = JSON.constructor([]);
var musicData = JSON.constructor([]);
var twitterData = JSON.constructor([]);
if (window.Worker) {
const workerBaseURL = window.infoBeamerConfig.get("workerBaseURL");
const scheduleWorkerCode = workerBaseURL + "js/schedule_worker.js";
console.log("Loading schedule worker JS from: " + scheduleWorkerCode);
const scheduleWorker = new Worker(scheduleWorkerCode);
const scheduleURL = window.infoBeamerConfig.get("scheduleURL");
const scheduleFetchInterval = window.infoBeamerConfig.get("scheduleFetchInterval");
scheduleWorker.postMessage({
msgType: "ScheduleFetchConfig",
scheduleURL,
scheduleFetchInterval
});
scheduleWorker.onmessage = function(e) {
let msgType = e.data.msgType;
if (msgType === "ScheduleUpdate") {
scheduleData = e.data.schedule;
let time = e.data.timestamp;
console.log("Message: " + msgType + " at " + time);
console.log(scheduleData);
update_screen();
}
};
const musicWorkerCode = workerBaseURL + "js/generic_fetch_worker.js";
console.log("Loading worker JS from: " + musicWorkerCode);
const musicWorker = new Worker(musicWorkerCode);
const musicType = "Music";
const musicURL = window.infoBeamerConfig.get("musicURL");
const musicFetchInterval = window.infoBeamerConfig.get("musicFetchInterval");
musicWorker.postMessage({
fetchType: musicType,
fetchURL: musicURL,
fetchInterval: musicFetchInterval
});
musicWorker.onmessage = function(e) {
let msgType = e.data.msgType;
if (msgType === musicType) {
2021-12-24 02:28:07 +01:00
musicData = JSON.constructor([e.data.json]);
2021-12-24 02:16:26 +01:00
let time = e.data.timestamp;
console.log("Message: " + msgType + " at " + time);
console.log(musicData);
update_screen();
}
};
const twitterWorkerCode = workerBaseURL + "js/generic_fetch_worker.js";
console.log("Loading worker JS from: " + twitterWorkerCode);
const twitterWorker = new Worker(twitterWorkerCode);
const twitterType = "Twitter";
const twitterURL = window.infoBeamerConfig.get("twitterURL");
const twitterFetchInterval = window.infoBeamerConfig.get("twitterFetchInterval");
twitterWorker.postMessage({
fetchType: twitterType,
fetchURL: twitterURL,
fetchInterval: twitterFetchInterval
});
twitterWorker.onmessage = function(e) {
let msgType = e.data.msgType;
if (msgType === twitterType) {
twitterData = e.data.json;
let time = e.data.timestamp;
console.log("Message: " + msgType + " at " + time);
console.log(twitterData);
update_screen();
}
};
} else {
console.log("Your browser doesn't support web workers.");
}
function update_screen() {
let time = new Date();
console.log("Updating screen at at: " + time);
update_main_slide({ schedule: scheduleData, music: musicData, twitter: twitterData });
}
function main_loop() {
update_screen();
setTimeout(main_loop, 10 * 1e3);
}
main_loop();
})();