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