Fix infobeamer
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Luca 2021-12-23 23:13:01 +01:00
parent b62b21df15
commit a009efe016
1 changed files with 35 additions and 32 deletions

View File

@ -6,45 +6,49 @@
<title> <title>
Infobeamer Infobeamer
</title> </title>
<link rel="stylesheet" href="/../../style.css"> <link rel="stylesheet" href="/style.css">
<script language="javascript" type="text/javascript"> <script>
main().then(() => console.log("loaded")); main().then(() => console.log("loaded"));
function parse_duration(duration) { function parseDuration(duration) {
if (duration == undefined) { if (!/^\d+:\d+$/.test(duration)) {
return 0; return 0;
} }
const [hours, minutes] = duration.split(":"); const [hours, minutes] = duration.split(":");
return (hours * 60 * 60 + minutes * 60) * 1000; return (hours * 60 * 60 + minutes * 60) * 1000;
} }
function sanitize(unsafe) {
const element = document.createElement("div");
element.innerHTML = unsafe;
return element.innerText;
}
function render(talk) { function render(talk) {
// const now = new Date(); // const now = new Date();
const now = Date.parse("2021-12-27T11:35:00+01:00"); const now = Date.parse("2021-12-27T11:35:00+01:00");
const max = talk.end - talk.start; const max = talk.end - talk.start;
var value = 0;
let value = 0;
if (talk.start < now && talk.end > now) { if (talk.start < now && talk.end > now) {
value = talk.end - now; value = talk.end - now;
value = max - value value = max - value
} else if ( talk.end < now ) { } else if (talk.end < now) {
value = max; value = max;
} }
const element = document.createElement("div")
element.innerHTML = talk.abstract;
const abstract = element.innerText;
return ` return `
<li class="box"> <li class="box">
<h2 class="box-header">${talk.title}</h2> <h2 class="box-header">${sanitize(talk.title)}</h2>
<div class="box-content"> <div class="box-content">
<p class="date"> <p class="date">
Speakers: ${talk.persons.join(", ") || "---"}<br> Speakers: ${sanitize(talk.persons.join(", ") || "---")}<br>
Stage: ${talk.room}<br> Stage: ${sanitize(talk.room)}<br>
Time: ${talk.start_string}<br> Time: ${sanitize(talk.start_string)}<br>
Duration: ${talk.duration}<br> Duration: ${sanitize(talk.duration)}<br>
</p> </p>
<p>${abstract}</p> <p>${sanitize(talk.abstract)}</p>
<progress max="${max}" value="${value}"> <progress max="${max}" value="${value}">
</div> </div>
</li>`; </li>`;
@ -56,14 +60,13 @@
const now = new Date(); const now = new Date();
var upcoming = []; const upcoming = [];
var content = "";
for (const day of schedule.schedule.conference.days) { for (const day of schedule.schedule.conference.days) {
for (const [channel, talks] of Object.entries(day.rooms)) { for (const [channel, talks] of Object.entries(day.rooms)) {
for (const talk of talks) { for (const talk of talks) {
talk_end = Date.parse(talk.date) + parse_duration(talk.duration); const talk_end = Date.parse(talk.date) + parseDuration(talk.duration);
if (talk_end > now) { if (talk_end > now) {
parsed = { const parsed = {
start: Date.parse(talk.date), start: Date.parse(talk.date),
date_string: talk.date, date_string: talk.date,
end: talk_end, end: talk_end,
@ -77,22 +80,22 @@
upcoming.push(parsed); upcoming.push(parsed);
break; break;
} }
}; }
} }
} }
let content = "";
upcoming.sort((a, b) => a.end - b.end); upcoming.sort((a, b) => a.end - b.end);
for (const talk of upcoming.splice(0, 6)) { for (const talk of upcoming.slice(0, 6)) {
content += render(talk); content += render(talk);
} }
document.getElementById("list").innerHTML = content; document.getElementById("list").innerHTML = content;
const hours = `${now.getHours()}`.padStart(2, '0'); const hours = `${now.getHours()}`.padStart(2, '0');
const minutes = `${now.getMinutes()}`.padStart(2, '0'); const minutes = `${now.getMinutes()}`.padStart(2, '0');
document.getElementById("time").innerHTML = `${hours}:${minutes}`; document.getElementById("time").innerText = `${hours}:${minutes}`;
setInterval(main, 60 * 1000); setTimeout(main, (60-new Date().getSeconds())*1000+500);
} }
</script> </script>
</head> </head>
@ -100,10 +103,11 @@
<header> <header>
<nav class="nav nav-main"> <nav class="nav nav-main">
<a class="nav-logo" href="/"> <a class="nav-logo" href="/">
<img src="/../../franconianNet.svg" <img src="/franconianNet.svg"
alt="Logo of franconian.net">franconian.net</a> alt="Logo of franconian.net">
<hr> franconian.net
<a class="nav-link" href="#" id="time"></a> </a>
<a class="nav-link" id="time"></a>
</nav> </nav>
</header> </header>
<main> <main>
@ -113,4 +117,3 @@
</main> </main>
</body> </body>
</html> </html>