"use strict"; (() => { // ns-hugo:/home/raoul-web/rc3_2021/html-infobeamer-content/assets/js/services.js var social_limiter = (tweets, toots) => { const numberTweets = 20; let posts = tweets.concat(toots); let byDate = (fst, snd) => Date.parse(fst.time) - Date.parse(snd.time); let postsSorted = posts.sort(byDate); if (postsSorted.length > 0) { while (postsSorted.length < numberTweets) { postsSorted = postsSorted.concat(postsSorted); } } postsSorted = postsSorted.reverse().slice(0, numberTweets); return postsSorted; }; var tweet_author = (data, tweet) => { let authorId = tweet.author_id; let users = data.includes.users; let author = users.find((item) => item.id === authorId); let userName = author !== void 0 ? author.username : "NoOne"; return userName; }; var tweet_profile_image = (data, tweet) => { const defaultProfileImageUrl = "https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png"; let authorId = tweet.author_id; let users = data.includes.users; let author = users.find((item) => item.id === authorId); let profileImageUrl = author !== void 0 ? author.profile_image_url : defaultProfileImageUrl; return profileImageUrl; }; var tweet_text = (tweet) => tweet.text; var tweet_time = (tweet) => tweet.created_at; var twitter_filter = (inputData) => { let tweets; inputData.forEach((d) => tweets = d.data.map((t) => { return { author: tweet_author(d, t), image: tweet_profile_image(d, t), text: tweet_text(t), time: tweet_time(t), source: "twitter" }; })); return tweets; }; var toot_author = (toot) => toot.account.username; var toot_profile_image = (toot) => toot.account.avatar_static; var toot_text = (toot) => toot.content; var toot_time = (toot) => toot.created_at; var html_plainify = (html2) => { let span = document.createElement("span"); span.innerHTML = html2; let children = span.querySelectorAll("*"); children.forEach((child) => { child.textContent += " "; }); return span.textContent.toString().replace(/ +/g, " "); }; var mastodon_filter = (idata) => { let toots; idata.forEach((d) => { toots = d.map((t) => { return { author: toot_author(t), image: toot_profile_image(t), text: html_plainify(toot_text(t)), time: toot_time(t), source: "mastodon" }; }); }); return toots; }; var schedule_filter = (data) => { let dataDays = data.schedule.conference.days; let talksData = dataDays.map((d) => { let rooms = Object.values(d.rooms); rooms.flat().forEach((t) => { t.day = d.index; }); return rooms; }).flat(2); let byDate = (fst, snd) => Date.parse(fst.date) - Date.parse(snd.date); let talksDataSorted = talksData.sort(byDate); return talksDataSorted; }; var future_events = (schedule, datetime) => { let scheduleFiltered = schedule.filter((e) => Date.parse(e.date) > datetime); return scheduleFiltered; }; // ns-hugo:/home/raoul-web/rc3_2021/html-infobeamer-content/assets/js/dom.js var html = htm.bind(preact.h); var speaker_names = (talk) => talk.persons.map((p) => p.public_name); var speaker_dom = (talk) => { const separator = ", "; let names = speaker_names(talk); let inner; if (names.length > 0) { let string = names.join(separator); inner = html`
${string}:
`; } else { inner = html``; } return inner; }; var to_minutes = (duration) => { const timeFormat = "hh:mm"; let dt = moment(duration, timeFormat); let minutes = 60 * dt.hours() + dt.minutes(); return minutes; }; var duration_dom = (duration) => { return html`${to_minutes(duration)} minutes`; }; var meta_here_dom = (schedule) => { let inner = html`${schedule.map((talk) => html`
${speaker_dom(talk)}
${talk.title}
Starting at ${talk.start} ${duration_dom(talk.duration)}
`)}`; return inner; }; var abstract_text_dom = (talk) => { const placeHolder = "\xAF_(\u30C4)_/\xAF"; let inner; if (talk.abstract !== null) { let lang = talk.language !== void 0 ? talk.language : "en"; inner = html`
${talk.abstract}
`; } else { inner = html``; } return inner; }; var track_dom = (talk) => { let inner; if (talk.track !== null) { inner = html`
Track: ${talk.track}
`; } else { inner = html``; } return inner; }; var abstract_here_dom = (schedule) => { let inner = html``; schedule.forEach((talk) => { inner = html` ${abstract_text_dom(talk)} ${track_dom(talk)}`; }); return inner; }; var talk_day = (talk) => { const lut = { 1: "I", 2: "II", 3: "III", 4: "IV" }; return lut[talk.day]; }; var talk_day_dom = (talk) => html`Day ${talk_day(talk)}`; var list_all_dom = (schedule) => { let inner = html` ${schedule.map((talk) => html`
${talk.title}
${talk.start} ${talk_day_dom(talk)} ${talk.room}
`)}`; return inner; }; var schedule_dom = (schedule) => { const here_room = "Chaos-West TV"; const here_number_events = 1; const all_number_events = 7; let allTalks = schedule.slice(0, all_number_events); let nextTalkHere = schedule.filter((i) => i.room === here_room).slice(0, 1); let nextHereMetaDom = meta_here_dom(nextTalkHere); let nextHereAbstractDom = abstract_here_dom(nextTalkHere); let nextAllMetaDom = list_all_dom(allTalks); let inner = html`
Next Up Here
${nextHereMetaDom}
Abstract
${nextHereAbstractDom}
Next Up at rC3
${nextAllMetaDom}
`; return inner; }; var music_playing_now_dom = (music) => { let inner = html`
${music.map((current) => html`
Now playing: (${current.license})
«${current.title}» by ${current.artist}
`)}
`; return inner; }; var post_time = (date) => moment(date).format("hh:mm, D. MMMM YYYY"); var social_network_dom = (post) => { let icon = ""; if (post.source === "twitter") { icon = "fa-twitter"; } else if (post.source === "mastodon") { icon = "fa-mastodon"; } return html``; }; var single_post_dom = (post) => { let inner = html`
${social_network_dom(post)} @${post.author} ${post_time(post.time)}
${post.text}
`; return inner; }; var social_container_dom = (posts) => { let inner = html`
${posts.map((p) => single_post_dom(p))}
`; return inner; }; var hashtag_dom = () => { let inner = html`
For Questions:
Please use the Hashtag #rc3cwtv or join our IRC Channel #rc3-cwtv
`; return inner; }; function update_main_slide(data) { let schedule = data.schedule; let music = data.music; let postings = data.posts; let scheduleDom = schedule_dom(schedule); let hashtagDom = hashtag_dom(); let musicDom = music_playing_now_dom(music); let postingsDom = social_container_dom(postings); let inner = html` ${scheduleDom} ${hashtagDom} ${musicDom} ${postingsDom} `; const anchorElId = "main"; const el = document.getElementById(anchorElId); preact.render(inner, el); } // var scheduleData = []; var musicData = []; var twitterData = []; var mastodonData = []; if (window.Worker) { const workerBaseURL = window.infoBeamerConfig.get("workerBaseURL"); const fetchWorkerCode = workerBaseURL + "js/generic_fetch_worker.js"; const scheduleWorker = new Worker(fetchWorkerCode); const scheduleType = "Schedule"; const scheduleURL = window.infoBeamerConfig.get("scheduleURL"); const scheduleFetchInterval = window.infoBeamerConfig.get("scheduleFetchInterval"); scheduleWorker.postMessage({ fetchType: scheduleType, fetchURL: scheduleURL, fetchInterval: scheduleFetchInterval }); scheduleWorker.onmessage = function(e) { if (e.data.msgType === scheduleType) { console.log("Data Message at " + Date()); console.log(e.data); scheduleData = schedule_filter(e.data.json); update_screen(); } }; const musicWorker = new Worker(fetchWorkerCode); 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) { if (e.data.msgType === musicType) { console.log("Data Message at " + Date()); console.log(e.data); musicData = [e.data.json]; update_screen(); } }; const twitterWorker = new Worker(fetchWorkerCode); 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) { if (e.data.msgType === twitterType) { console.log("Data Message at " + Date()); console.log(e.data); twitterData = [e.data.json]; twitterData = twitter_filter(twitterData); update_screen(); } }; const mastodonWorker = new Worker(fetchWorkerCode); const mastodonType = "Mastodon"; const mastodonURL = window.infoBeamerConfig.get("mastodonURL"); const mastodonFetchInterval = window.infoBeamerConfig.get("mastodonFetchInterval"); mastodonWorker.postMessage({ fetchType: mastodonType, fetchURL: mastodonURL, fetchInterval: mastodonFetchInterval }); mastodonWorker.onmessage = function(e) { if (e.data.msgType === mastodonType) { console.log("Data Message at " + Date()); console.log(e.data); mastodonData = [e.data.json]; mastodonData = mastodon_filter(mastodonData); update_screen(); } }; } else { console.log("Your browser doesn't support web workers."); } function update_screen() { let realTime = new Date(); console.log("Updating screen at at: " + realTime); let now = Date.now(); console.log("Using 'now': " + now); update_main_slide({ schedule: future_events(scheduleData, now), music: musicData, posts: social_limiter(twitterData, mastodonData) }); } function main_loop() { update_screen(); setTimeout(main_loop, 10 * 1e3); } main_loop(); })();