2021-12-24 02:16:26 +01:00
|
|
|
"use strict";
|
|
|
|
(() => {
|
2021-12-25 22:19:20 +01:00
|
|
|
// ns-hugo:/home/raoul-web/rc3_2021/html-infobeamer-content/assets/js/services.js
|
2021-12-26 21:23:15 +01:00
|
|
|
var delay = 3 * 5 * 60 * 1e3;
|
|
|
|
var postsLimit = 20;
|
2021-12-27 00:26:02 +01:00
|
|
|
var postMaxAge = 32 * 24 * 60 * 60 * 1e3;
|
2021-12-26 21:23:15 +01:00
|
|
|
var defaultUrlSet = [
|
|
|
|
"https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
|
|
|
|
"https://chaos.social/avatars/original/missing.png"
|
|
|
|
];
|
|
|
|
var default_profile_image_url = () => "./nounicorn.png";
|
2021-12-25 22:19:20 +01:00
|
|
|
var social_limiter = (tweets, toots) => {
|
|
|
|
let posts = tweets.concat(toots);
|
2021-12-27 00:26:02 +01:00
|
|
|
let maxAge = (p) => Date.parse(p.time) >= Date.now() - postMaxAge;
|
|
|
|
let recentPosts = posts.filter(maxAge);
|
2021-12-25 22:19:20 +01:00
|
|
|
let byDate = (fst, snd) => Date.parse(fst.time) - Date.parse(snd.time);
|
2021-12-27 00:26:02 +01:00
|
|
|
let postsSorted = recentPosts.sort(byDate);
|
2021-12-25 22:19:20 +01:00
|
|
|
if (postsSorted.length > 0) {
|
2021-12-26 21:23:15 +01:00
|
|
|
while (postsSorted.length < postsLimit) {
|
2021-12-25 22:19:20 +01:00
|
|
|
postsSorted = postsSorted.concat(postsSorted);
|
|
|
|
}
|
|
|
|
}
|
2021-12-27 00:26:02 +01:00
|
|
|
let postsLimited = postsSorted.reverse().slice(0, postsLimit);
|
|
|
|
return postsLimited;
|
2021-12-25 22:19:20 +01:00
|
|
|
};
|
2021-12-26 21:23:15 +01:00
|
|
|
var replace_default_image_url = (url) => defaultUrlSet.includes(url) === true ? default_profile_image_url() : url;
|
2021-12-25 22:19:20 +01:00
|
|
|
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) => {
|
|
|
|
let authorId = tweet.author_id;
|
|
|
|
let users = data.includes.users;
|
|
|
|
let author = users.find((item) => item.id === authorId);
|
2021-12-26 21:23:15 +01:00
|
|
|
let profileImageUrl = replace_default_image_url(author.profile_image_url);
|
2021-12-25 22:19:20 +01:00
|
|
|
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;
|
2021-12-26 21:23:15 +01:00
|
|
|
var toot_profile_image = (toot) => replace_default_image_url(toot.account.avatar_static);
|
2021-12-25 22:19:20 +01:00
|
|
|
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;
|
|
|
|
};
|
2021-12-26 21:23:15 +01:00
|
|
|
var future_events = (schedule, now) => schedule.filter((e) => Date.parse(e.date) >= now - delay);
|
|
|
|
var same_music_track = (track1, track2) => track1.artist === track2.artist && track1.title === track2.title;
|
2021-12-26 02:57:42 +01:00
|
|
|
var is_new_music = (musicA, musicB) => {
|
2021-12-26 21:23:15 +01:00
|
|
|
let isNewMusic;
|
2021-12-26 03:32:01 +01:00
|
|
|
if (musicA.length !== 0 && musicB.length !== 0) {
|
2021-12-26 21:23:15 +01:00
|
|
|
isNewMusic = same_music_track(musicA[0], musicB[0]);
|
2021-12-26 03:32:01 +01:00
|
|
|
} else if (musicA.length === 0 && musicB.length === 0) {
|
2021-12-26 21:23:15 +01:00
|
|
|
isNewMusic = true;
|
2021-12-26 03:32:01 +01:00
|
|
|
} else {
|
2021-12-26 21:23:15 +01:00
|
|
|
isNewMusic = false;
|
2021-12-26 03:32:01 +01:00
|
|
|
}
|
2021-12-26 21:23:15 +01:00
|
|
|
return !isNewMusic;
|
2021-12-26 02:57:42 +01:00
|
|
|
};
|
2021-12-26 05:29:23 +01:00
|
|
|
var music_update = (musicA, musicB) => {
|
2021-12-26 21:23:15 +01:00
|
|
|
if (is_new_music(musicA, musicB) === true) {
|
2021-12-27 00:26:02 +01:00
|
|
|
musicB.forEach((mb) => mb.since = Date.now());
|
|
|
|
} else {
|
|
|
|
musicA.forEach((ma) => {
|
|
|
|
musicB.forEach((mb) => mb.since = ma.since);
|
|
|
|
});
|
2021-12-26 05:29:23 +01:00
|
|
|
}
|
2021-12-26 02:57:42 +01:00
|
|
|
return musicB;
|
|
|
|
};
|
2021-12-25 22:19:20 +01:00
|
|
|
|
2021-12-24 23:18:02 +01:00
|
|
|
// ns-hugo:/home/raoul-web/rc3_2021/html-infobeamer-content/assets/js/dom.js
|
2021-12-24 02:16:26 +01:00
|
|
|
var html = htm.bind(preact.h);
|
2021-12-26 21:23:15 +01:00
|
|
|
var hereRoom = "Chaos-West TV";
|
2021-12-27 00:26:02 +01:00
|
|
|
var number_events_all = 8;
|
2021-12-26 05:29:23 +01:00
|
|
|
var musicAge = 5 * 1e3;
|
2021-12-26 21:23:15 +01:00
|
|
|
var urgent = 5 * 60 * 1e3;
|
|
|
|
var stale = 3 * 5 * 60 * 1e3;
|
|
|
|
var lapse = 5 * 1e3;
|
|
|
|
var talk_day = (talk) => {
|
|
|
|
const lut = {
|
|
|
|
1: "I",
|
|
|
|
2: "II",
|
|
|
|
3: "III",
|
|
|
|
4: "IV"
|
|
|
|
};
|
|
|
|
return lut[talk.day];
|
|
|
|
};
|
|
|
|
var is_own_talk = (talk) => talk.room === hereRoom;
|
|
|
|
var talk_start_time = (talk) => Date.parse(talk.date);
|
2021-12-26 02:57:42 +01:00
|
|
|
var is_urgent = (talk, time) => {
|
2021-12-26 21:23:15 +01:00
|
|
|
let timeDelta = talk_start_time(talk) - time;
|
|
|
|
return timeDelta >= 0 && timeDelta <= urgent;
|
|
|
|
};
|
|
|
|
var is_stale = (talk, time) => {
|
|
|
|
let timeDelta = talk_start_time(talk) - time;
|
|
|
|
return timeDelta < 0;
|
|
|
|
};
|
|
|
|
var is_lapse = (talk, time) => {
|
|
|
|
let timeDelta = talk_start_time(talk) - time;
|
|
|
|
return timeDelta <= -(stale - lapse);
|
2021-12-26 02:57:42 +01:00
|
|
|
};
|
|
|
|
var urgent_class = (talk, time) => is_urgent(talk, time) ? "urgent" : "";
|
2021-12-26 21:23:15 +01:00
|
|
|
var stale_class = (talk, time) => is_stale(talk, time) ? "stale" : "";
|
|
|
|
var lapse_class = (talk, time) => is_lapse(talk, time) ? "lapse" : "";
|
2021-12-25 22:19:20 +01:00
|
|
|
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`<div class="speaker">${string}:</div>`;
|
|
|
|
} else {
|
|
|
|
inner = html``;
|
|
|
|
}
|
|
|
|
return inner;
|
|
|
|
};
|
2021-12-26 21:23:15 +01:00
|
|
|
var starting_dom = (talk, time) => {
|
|
|
|
const hrs3 = 3 * 60 * 60 * 1e3;
|
|
|
|
const min15 = 3 * 5 * 60 * 1e3;
|
|
|
|
const min2 = 2 * 60 * 1e3;
|
|
|
|
const min1 = 60 * 1e3;
|
|
|
|
let timeDelta = talk_start_time(talk) - time;
|
|
|
|
let minutes = Math.ceil(Math.abs(timeDelta / 1e3 / 60));
|
|
|
|
let inner;
|
|
|
|
if (timeDelta > hrs3) {
|
|
|
|
inner = html`<span class="start">Day ${talk_day(talk)} at ${talk.start}</span>`;
|
|
|
|
} else if (timeDelta > min15) {
|
|
|
|
inner = html`<span class="start">Starting at ${talk.start}</span>`;
|
|
|
|
} else if (timeDelta <= min15 && timeDelta > min1) {
|
|
|
|
inner = html`<span class="start">Starting in ${minutes} minutes</span>`;
|
|
|
|
} else if (timeDelta <= min1 && timeDelta >= 0) {
|
|
|
|
inner = html`<span class="start">Starting now!</span>`;
|
|
|
|
} else if (timeDelta < 0 && timeDelta >= -min1) {
|
|
|
|
inner = html`<span class="start">Just started!</span>`;
|
|
|
|
} else if (timeDelta < -min1 && timeDelta >= -min15) {
|
|
|
|
inner = html`<span class="start">Started ${minutes} minutes ago</span>`;
|
|
|
|
} else if (timeDelta < -min15) {
|
|
|
|
inner = html`<span class="start">Seriously missed</span>`;
|
|
|
|
}
|
|
|
|
return inner;
|
|
|
|
};
|
2021-12-25 22:19:20 +01:00
|
|
|
var to_minutes = (duration) => {
|
|
|
|
const timeFormat = "hh:mm";
|
|
|
|
let dt = moment(duration, timeFormat);
|
|
|
|
let minutes = 60 * dt.hours() + dt.minutes();
|
|
|
|
return minutes;
|
2021-12-25 07:28:56 +01:00
|
|
|
};
|
2021-12-26 21:23:15 +01:00
|
|
|
var duration_dom = (talk) => {
|
|
|
|
return html`<span class="duration">${to_minutes(talk.duration)} minutes</span>`;
|
2021-12-25 22:19:20 +01:00
|
|
|
};
|
2021-12-26 02:57:42 +01:00
|
|
|
var meta_here_dom = (schedule, time) => {
|
2021-12-24 02:16:26 +01:00
|
|
|
let inner = html`${schedule.map((talk) => html`
|
2021-12-26 21:23:15 +01:00
|
|
|
<div class="talk-here-meta-box ${urgent_class(talk, time)} ${stale_class(talk, time)}">
|
2021-12-25 22:19:20 +01:00
|
|
|
<div class="speaker">${speaker_dom(talk)}</div>
|
2021-12-26 02:57:42 +01:00
|
|
|
<div class="title"><span class="titletext">${talk.title}</span></div>
|
2021-12-24 02:16:26 +01:00
|
|
|
<div class="start-duration">
|
2021-12-26 21:23:15 +01:00
|
|
|
${starting_dom(talk, time)}
|
|
|
|
${duration_dom(talk)}
|
2021-12-24 02:16:26 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`)}`;
|
|
|
|
return inner;
|
|
|
|
};
|
2021-12-25 22:19:20 +01:00
|
|
|
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`<div class="text" lang="${lang}">${talk.abstract}</div>`;
|
|
|
|
} else {
|
|
|
|
inner = html``;
|
|
|
|
}
|
|
|
|
return inner;
|
|
|
|
};
|
|
|
|
var track_dom = (talk) => {
|
|
|
|
let inner;
|
|
|
|
if (talk.track !== null) {
|
|
|
|
inner = html`<div class="track">Track: ${talk.track}</div>`;
|
|
|
|
} else {
|
|
|
|
inner = html``;
|
|
|
|
}
|
|
|
|
return inner;
|
|
|
|
};
|
|
|
|
var abstract_here_dom = (schedule) => {
|
2021-12-24 02:16:26 +01:00
|
|
|
let inner = html``;
|
|
|
|
schedule.forEach((talk) => {
|
2021-12-25 07:28:56 +01:00
|
|
|
inner = html`
|
2021-12-25 22:19:20 +01:00
|
|
|
${abstract_text_dom(talk)}
|
|
|
|
${track_dom(talk)}`;
|
2021-12-24 02:16:26 +01:00
|
|
|
});
|
|
|
|
return inner;
|
|
|
|
};
|
2021-12-25 22:19:20 +01:00
|
|
|
var talk_day_dom = (talk) => html`<span class="day">Day ${talk_day(talk)}</span>`;
|
2021-12-26 21:23:15 +01:00
|
|
|
var highlight_class = (talk) => is_own_talk(talk) === true ? "highlight" : "";
|
2021-12-26 02:57:42 +01:00
|
|
|
var do_not_record_dom = (talk) => {
|
|
|
|
let icon = "fa-microphone-slash";
|
|
|
|
let inner;
|
|
|
|
if (talk.do_not_record === true) {
|
|
|
|
inner = html`<span class="do-not-record"><span class="fa ${icon}"></span></span>`;
|
|
|
|
} else {
|
|
|
|
inner = html``;
|
|
|
|
}
|
|
|
|
return inner;
|
|
|
|
};
|
|
|
|
var list_all_dom = (schedule, time) => {
|
2021-12-24 02:16:26 +01:00
|
|
|
let inner = html`
|
|
|
|
${schedule.map((talk) => html`
|
2021-12-26 21:23:15 +01:00
|
|
|
<div class="item ${highlight_class(talk)} ${urgent_class(talk, time)} ${stale_class(talk, time)} ${lapse_class(talk, time)}">
|
2021-12-24 02:16:26 +01:00
|
|
|
<div>
|
|
|
|
<div class="title">${talk.title}</div>
|
|
|
|
</div>
|
|
|
|
<div class="details">
|
|
|
|
<span class="start">${talk.start}</span>
|
2021-12-25 22:19:20 +01:00
|
|
|
${talk_day_dom(talk)}
|
2021-12-26 02:57:42 +01:00
|
|
|
${do_not_record_dom(talk)}
|
2021-12-24 02:16:26 +01:00
|
|
|
<span class="stage">${talk.room}</span>
|
|
|
|
</div>
|
|
|
|
</div>`)}`;
|
|
|
|
return inner;
|
|
|
|
};
|
2021-12-26 21:23:15 +01:00
|
|
|
var next_up_here_dom = (talks, time) => {
|
|
|
|
let inner;
|
|
|
|
if (talks.length > 0) {
|
|
|
|
inner = html`
|
|
|
|
<div class="panel meta">
|
|
|
|
<div class="header">Next Up Here</div>
|
|
|
|
<div class="content">${meta_here_dom(talks, time)}</div>
|
|
|
|
</div>`;
|
|
|
|
} else {
|
|
|
|
inner = html`
|
|
|
|
<div class="panel meta">
|
|
|
|
<div class="header">Next Up Here</div>
|
|
|
|
</div>`;
|
|
|
|
}
|
|
|
|
return inner;
|
|
|
|
};
|
|
|
|
var next_up_abstract_dom = (talks, time) => {
|
|
|
|
let inner;
|
|
|
|
if (talks.length > 0) {
|
|
|
|
inner = html`
|
|
|
|
<div class="panel abstract">
|
|
|
|
<div class="header">Abstract</div>
|
|
|
|
<div class="content">${abstract_here_dom(talks)}</div>
|
|
|
|
</div>`;
|
|
|
|
} else {
|
|
|
|
inner = html``;
|
|
|
|
}
|
|
|
|
return inner;
|
|
|
|
};
|
|
|
|
var next_up_list_all_dom = (talks, time) => {
|
|
|
|
let inner;
|
|
|
|
if (talks.length > 0) {
|
|
|
|
inner = html`
|
|
|
|
<div class="panel list">
|
|
|
|
<div class="header">Next Up at rC3</div>
|
|
|
|
<div class="content">${list_all_dom(talks, time)}</div>
|
|
|
|
</div>`;
|
|
|
|
} else {
|
|
|
|
inner = html`
|
|
|
|
<div class="panel list">
|
|
|
|
<div class="header">Next Up at rC3</div>
|
|
|
|
</div>`;
|
|
|
|
}
|
|
|
|
return inner;
|
|
|
|
};
|
2021-12-26 02:57:42 +01:00
|
|
|
var schedule_dom = (schedule, time) => {
|
2021-12-26 21:23:15 +01:00
|
|
|
let allTalks = schedule.slice(0, number_events_all);
|
2021-12-26 02:57:42 +01:00
|
|
|
let nextTalkHere = schedule.filter(is_own_talk).slice(0, 1);
|
2021-12-26 21:23:15 +01:00
|
|
|
return html`
|
2021-12-24 02:16:26 +01:00
|
|
|
<div class="slide">
|
|
|
|
<div class="schedule">
|
|
|
|
<div class="left">
|
2021-12-26 21:23:15 +01:00
|
|
|
${next_up_here_dom(nextTalkHere, time)}
|
|
|
|
${next_up_abstract_dom(nextTalkHere, time)}
|
2021-12-24 02:16:26 +01:00
|
|
|
</div>
|
|
|
|
<div class="right">
|
2021-12-26 21:23:15 +01:00
|
|
|
${next_up_list_all_dom(allTalks, time)}
|
2021-12-24 02:16:26 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>`;
|
|
|
|
};
|
2021-12-26 05:29:23 +01:00
|
|
|
var music_changed = (current, time) => time - current.since <= musicAge;
|
|
|
|
var changed_music_class = (current, time) => music_changed(current, time) ? "changed" : "";
|
2021-12-27 16:11:53 +01:00
|
|
|
var music_license_dom = (current) => current.license !== void 0 ? html`<span class="license">(${current.license})</span>` : html``;
|
|
|
|
var music_title_dom = (current) => current.license !== void 0 ? html`<span class="title">«${current.title}»</span>` : html``;
|
|
|
|
var music_artist_dom = (current) => current.license !== void 0 ? html`<span class="by">by</span><span class="artist">${current.artist}</span>` : html``;
|
2021-12-26 05:29:23 +01:00
|
|
|
var music_playing_now_dom = (music, time) => {
|
2021-12-26 21:23:15 +01:00
|
|
|
return html`
|
2021-12-25 07:28:56 +01:00
|
|
|
<div class="music-box">
|
2021-12-26 05:29:23 +01:00
|
|
|
${music.map((current) => html`
|
|
|
|
<div class="music ${changed_music_class(current, time)}">
|
2021-12-26 02:57:42 +01:00
|
|
|
<div class="line1">
|
|
|
|
<span>
|
|
|
|
<span class="note">
|
2021-12-26 05:29:23 +01:00
|
|
|
<span class="fa fa-music glyph"></span>
|
2021-12-26 02:57:42 +01:00
|
|
|
</span>
|
2021-12-24 02:16:26 +01:00
|
|
|
<span class="header">Now playing:</span>
|
2021-12-26 02:57:42 +01:00
|
|
|
</span>
|
2021-12-27 16:11:53 +01:00
|
|
|
${music_license_dom(current)}
|
2021-12-26 02:57:42 +01:00
|
|
|
</div>
|
|
|
|
<div class="line2">
|
2021-12-27 16:11:53 +01:00
|
|
|
${music_title_dom(current)}
|
|
|
|
${music_artist_dom(current)}
|
2021-12-26 05:29:23 +01:00
|
|
|
</div>
|
|
|
|
</div>`)}
|
2021-12-24 02:16:26 +01:00
|
|
|
</div>`;
|
|
|
|
};
|
2021-12-26 02:57:42 +01:00
|
|
|
var post_time = (date) => moment(date).format("H:mm, D. MMMM YYYY");
|
2021-12-25 22:19:20 +01:00
|
|
|
var social_network_dom = (post) => {
|
|
|
|
let icon = "";
|
|
|
|
if (post.source === "twitter") {
|
|
|
|
icon = "fa-twitter";
|
|
|
|
} else if (post.source === "mastodon") {
|
|
|
|
icon = "fa-mastodon";
|
|
|
|
}
|
|
|
|
return html`<span class="source fa ${icon}"></span>`;
|
|
|
|
};
|
|
|
|
var single_post_dom = (post) => {
|
2021-12-24 23:18:02 +01:00
|
|
|
let inner = html`
|
2021-12-25 22:19:20 +01:00
|
|
|
<div class="post slider">
|
2021-12-24 23:18:02 +01:00
|
|
|
<div class="container">
|
2021-12-25 22:19:20 +01:00
|
|
|
<img class="profile-image" src="${post.image}"/>
|
2021-12-24 23:18:02 +01:00
|
|
|
<div class="content">
|
2021-12-25 22:19:20 +01:00
|
|
|
<div class="meta">
|
|
|
|
${social_network_dom(post)}
|
|
|
|
<span class="username">@${post.author}</span>
|
|
|
|
<span class="time">${post_time(post.time)}</span>
|
2021-12-25 07:28:56 +01:00
|
|
|
</div>
|
2021-12-25 22:19:20 +01:00
|
|
|
<div class="text">${post.text}</div>
|
2021-12-24 23:18:02 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>`;
|
|
|
|
return inner;
|
|
|
|
};
|
2021-12-25 22:19:20 +01:00
|
|
|
var social_container_dom = (posts) => {
|
2021-12-25 07:28:56 +01:00
|
|
|
let inner = html`
|
2021-12-24 23:18:02 +01:00
|
|
|
<div id="bottom-bar" class="visible bottom-bar">
|
|
|
|
<div id="ticker-wrap" class="ticker-wrap">
|
|
|
|
<div class="ticker switcher">
|
2021-12-25 22:19:20 +01:00
|
|
|
${posts.map((p) => single_post_dom(p))}
|
2021-12-24 23:18:02 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>`;
|
|
|
|
return inner;
|
|
|
|
};
|
2021-12-25 22:19:20 +01:00
|
|
|
var hashtag_dom = () => {
|
|
|
|
let inner = html`
|
|
|
|
<div id="hashtags" class="visible hashtags">
|
|
|
|
<div class="box">
|
|
|
|
<div class="header">For Questions:</div>
|
2021-12-25 22:44:44 +01:00
|
|
|
<div class="text">Please use the Hashtag <span class="hashtag">#rc3cwtv</span> or join our IRC Channel <span class="irc">#rc3-cwtv</span></div>
|
2021-12-25 22:19:20 +01:00
|
|
|
</div>
|
|
|
|
</div>`;
|
|
|
|
return inner;
|
|
|
|
};
|
2021-12-26 02:57:42 +01:00
|
|
|
function update_main_slide(data, time) {
|
2021-12-24 02:16:26 +01:00
|
|
|
let schedule = data.schedule;
|
|
|
|
let music = data.music;
|
2021-12-25 22:19:20 +01:00
|
|
|
let postings = data.posts;
|
2021-12-24 02:16:26 +01:00
|
|
|
let inner = html`
|
2021-12-26 21:23:15 +01:00
|
|
|
${schedule_dom(schedule, time)}
|
|
|
|
${hashtag_dom()}
|
|
|
|
${music_playing_now_dom(music, time)}
|
|
|
|
${social_container_dom(postings)}
|
2021-12-25 22:19:20 +01:00
|
|
|
`;
|
2021-12-24 02:16:26 +01:00
|
|
|
const anchorElId = "main";
|
|
|
|
const el = document.getElementById(anchorElId);
|
|
|
|
preact.render(inner, el);
|
|
|
|
}
|
|
|
|
|
|
|
|
// <stdin>
|
2021-12-24 23:18:02 +01:00
|
|
|
var scheduleData = [];
|
|
|
|
var musicData = [];
|
|
|
|
var twitterData = [];
|
2021-12-25 07:28:56 +01:00
|
|
|
var mastodonData = [];
|
2021-12-24 02:16:26 +01:00
|
|
|
if (window.Worker) {
|
|
|
|
const workerBaseURL = window.infoBeamerConfig.get("workerBaseURL");
|
2021-12-25 22:19:20 +01:00
|
|
|
const fetchWorkerCode = workerBaseURL + "js/generic_fetch_worker.js";
|
|
|
|
const scheduleWorker = new Worker(fetchWorkerCode);
|
|
|
|
const scheduleType = "Schedule";
|
2021-12-24 02:16:26 +01:00
|
|
|
const scheduleURL = window.infoBeamerConfig.get("scheduleURL");
|
|
|
|
const scheduleFetchInterval = window.infoBeamerConfig.get("scheduleFetchInterval");
|
|
|
|
scheduleWorker.postMessage({
|
2021-12-25 22:19:20 +01:00
|
|
|
fetchType: scheduleType,
|
|
|
|
fetchURL: scheduleURL,
|
|
|
|
fetchInterval: scheduleFetchInterval
|
2021-12-24 02:16:26 +01:00
|
|
|
});
|
|
|
|
scheduleWorker.onmessage = function(e) {
|
2021-12-25 22:19:20 +01:00
|
|
|
if (e.data.msgType === scheduleType) {
|
|
|
|
scheduleData = schedule_filter(e.data.json);
|
2021-12-24 02:16:26 +01:00
|
|
|
update_screen();
|
|
|
|
}
|
|
|
|
};
|
2021-12-25 22:19:20 +01:00
|
|
|
const musicWorker = new Worker(fetchWorkerCode);
|
2021-12-24 02:16:26 +01:00
|
|
|
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) {
|
2021-12-25 22:19:20 +01:00
|
|
|
if (e.data.msgType === musicType) {
|
2021-12-26 02:57:42 +01:00
|
|
|
let musicDataUpdate = [e.data.json];
|
2021-12-26 05:29:23 +01:00
|
|
|
musicData = music_update(musicData, musicDataUpdate);
|
2021-12-24 02:16:26 +01:00
|
|
|
update_screen();
|
|
|
|
}
|
|
|
|
};
|
2021-12-25 22:19:20 +01:00
|
|
|
const twitterWorker = new Worker(fetchWorkerCode);
|
2021-12-24 02:16:26 +01:00
|
|
|
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) {
|
2021-12-25 22:19:20 +01:00
|
|
|
if (e.data.msgType === twitterType) {
|
2021-12-24 23:18:02 +01:00
|
|
|
twitterData = [e.data.json];
|
2021-12-25 07:28:56 +01:00
|
|
|
twitterData = twitter_filter(twitterData);
|
2021-12-24 02:16:26 +01:00
|
|
|
update_screen();
|
|
|
|
}
|
|
|
|
};
|
2021-12-25 22:19:20 +01:00
|
|
|
const mastodonWorker = new Worker(fetchWorkerCode);
|
2021-12-25 07:28:56 +01:00
|
|
|
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) {
|
2021-12-25 22:19:20 +01:00
|
|
|
if (e.data.msgType === mastodonType) {
|
2021-12-25 07:28:56 +01:00
|
|
|
mastodonData = [e.data.json];
|
|
|
|
mastodonData = mastodon_filter(mastodonData);
|
|
|
|
update_screen();
|
|
|
|
}
|
|
|
|
};
|
2021-12-24 02:16:26 +01:00
|
|
|
} else {
|
|
|
|
console.log("Your browser doesn't support web workers.");
|
|
|
|
}
|
2021-12-27 00:26:02 +01:00
|
|
|
var fakeTimeDelta = 0;
|
2021-12-24 02:16:26 +01:00
|
|
|
function update_screen() {
|
2021-12-25 22:19:20 +01:00
|
|
|
let realTime = new Date();
|
2021-12-26 21:23:15 +01:00
|
|
|
let now = Date.now() + fakeTimeDelta;
|
2021-12-25 07:28:56 +01:00
|
|
|
update_main_slide({
|
2021-12-25 22:19:20 +01:00
|
|
|
schedule: future_events(scheduleData, now),
|
2021-12-25 07:28:56 +01:00
|
|
|
music: musicData,
|
2021-12-25 22:19:20 +01:00
|
|
|
posts: social_limiter(twitterData, mastodonData)
|
2021-12-26 02:57:42 +01:00
|
|
|
}, now);
|
2021-12-24 02:16:26 +01:00
|
|
|
}
|
|
|
|
function main_loop() {
|
|
|
|
update_screen();
|
2021-12-27 00:26:02 +01:00
|
|
|
setTimeout(main_loop, 1 * 1e3);
|
2021-12-24 02:16:26 +01:00
|
|
|
}
|
|
|
|
main_loop();
|
|
|
|
})();
|