update 'bauchbinde'
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Luca 2020-12-27 13:32:40 +01:00
parent 345f727ac7
commit 3407da6fa9
1 changed files with 55 additions and 26 deletions

View File

@ -1,23 +1,31 @@
(() => { (() => {
const scheduleUrl = 'https://schedule2.broken.equipment/everything.schedule.json'; const scheduleUrl = 'https://schedule2.broken.equipment/everything.schedule.json';
let data = null;
let textEl; let textEl;
let headline = '¯\\_(ツ)_/¯'; let headline = null;
let speaker = ''; let speaker = null;
let isIntro = false; let isIntro = false;
let holdDuration = 4000; let holdDuration = 4000;
let room = null; let room = null;
let time = null; let time = null;
let startDelay = 1000; let startDelay = 1000;
let gracePeriod = 5;
async function getCurrentTalkByRoomName(roomName) { async function getCurrentTalkByRoomName(roomName, offset) {
let now = Date.now(); if (!offset) {
offset = 0;
}
let now = Date.now() + offset;
if (time) { if (time) {
now = Date.parse(time) now = Date.parse(time) + offset;
} }
if (!data) {
const response = await fetch(scheduleUrl); const response = await fetch(scheduleUrl);
const data = await response.json(); data = await response.json();
}
const days = data.schedule.conference.days; const days = data.schedule.conference.days;
const today = days.find(day => { const today = days.find(day => {
const start = Date.parse(day.day_start); const start = Date.parse(day.day_start);
@ -85,14 +93,24 @@
if (key === 'width') { if (key === 'width') {
root.style.setProperty('--width', value); root.style.setProperty('--width', value);
} }
if (key === 'gracePeriod') {
gracePeriod = parseInt(value, 10)
}
} }
} }
if (room) { if (room) {
const talk = await getCurrentTalkByRoomName(room); let offset = gracePeriod * 60 * 1000;
let talk = await getCurrentTalkByRoomName(room);
if (!talk) { if (!talk) {
headline = '¯\\_(ツ)_/¯'; talk = await getCurrentTalkByRoomName(room, -offset);
speaker = ''; }
if (!talk) {
talk = await getCurrentTalkByRoomName(room, offset);
}
if (!talk) {
headline = null;
speaker = null;
} else { } else {
headline = talk.title; headline = talk.title;
if (talk.persons) { if (talk.persons) {
@ -101,7 +119,11 @@
} }
} }
if (speaker) { if (!headline) {
return false;
}
if (speaker && headline) {
headline += ','; headline += ',';
} }
@ -110,18 +132,22 @@
const speakerEl = document.createElement('span'); const speakerEl = document.createElement('span');
speakerEl.classList.add('speaker'); speakerEl.classList.add('speaker');
if (headline) {
Array.from(headline).forEach(letter => { Array.from(headline).forEach(letter => {
const letterEl = document.createElement('span'); const letterEl = document.createElement('span');
letterEl.classList.add('letter'); letterEl.classList.add('letter');
letterEl.innerText = letter; letterEl.innerText = letter;
headlineEl.appendChild(letterEl); headlineEl.appendChild(letterEl);
}) })
}
if (speaker) {
Array.from(speaker).forEach(letter => { Array.from(speaker).forEach(letter => {
const letterEl = document.createElement('span'); const letterEl = document.createElement('span');
letterEl.classList.add('letter'); letterEl.classList.add('letter');
letterEl.innerText = letter; letterEl.innerText = letter;
speakerEl.appendChild(letterEl); speakerEl.appendChild(letterEl);
}) })
}
textEl.appendChild(headlineEl); textEl.appendChild(headlineEl);
textEl.appendChild(document.createTextNode(' ')); textEl.appendChild(document.createTextNode(' '));
@ -149,6 +175,8 @@
} }
secondaryTilesEl.appendChild(tile); secondaryTilesEl.appendChild(tile);
} }
return true;
} }
async function animate() { async function animate() {
@ -256,8 +284,9 @@
} }
window.addEventListener('load', async () => { window.addEventListener('load', async () => {
await init(); if (await init()) {
await new Promise(r => setTimeout(r, startDelay)); await new Promise(r => setTimeout(r, startDelay));
await animate(); await animate();
}
}); });
})(); })();