2021-12-23 21:40:48 +01:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
2021-12-23 21:53:57 +01:00
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
|
|
<title>
|
|
|
|
Infobeamer
|
|
|
|
</title>
|
2021-12-23 23:13:01 +01:00
|
|
|
<link rel="stylesheet" href="/style.css">
|
|
|
|
<script>
|
2021-12-23 21:40:48 +01:00
|
|
|
main().then(() => console.log("loaded"));
|
|
|
|
|
2021-12-23 23:13:01 +01:00
|
|
|
function parseDuration(duration) {
|
|
|
|
if (!/^\d+:\d+$/.test(duration)) {
|
2021-12-23 21:40:48 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-23 23:13:01 +01:00
|
|
|
|
2021-12-23 21:40:48 +01:00
|
|
|
const [hours, minutes] = duration.split(":");
|
|
|
|
return (hours * 60 * 60 + minutes * 60) * 1000;
|
|
|
|
}
|
|
|
|
|
2021-12-23 23:13:01 +01:00
|
|
|
function sanitize(unsafe) {
|
|
|
|
const element = document.createElement("div");
|
|
|
|
element.innerHTML = unsafe;
|
|
|
|
return element.innerText;
|
|
|
|
}
|
|
|
|
|
2021-12-23 21:40:48 +01:00
|
|
|
function render(talk) {
|
2021-12-24 15:48:07 +01:00
|
|
|
const now = Date.now();
|
2021-12-23 21:40:48 +01:00
|
|
|
const max = talk.end - talk.start;
|
2021-12-23 23:13:01 +01:00
|
|
|
|
|
|
|
let value = 0;
|
2021-12-23 21:40:48 +01:00
|
|
|
if (talk.start < now && talk.end > now) {
|
|
|
|
value = talk.end - now;
|
|
|
|
value = max - value
|
2021-12-23 23:13:01 +01:00
|
|
|
} else if (talk.end < now) {
|
2021-12-23 21:40:48 +01:00
|
|
|
value = max;
|
|
|
|
}
|
|
|
|
|
|
|
|
return `
|
|
|
|
<li class="box">
|
2021-12-23 23:13:01 +01:00
|
|
|
<h2 class="box-header">${sanitize(talk.title)}</h2>
|
2021-12-23 23:43:55 +01:00
|
|
|
<div class="box-content clamp-height">
|
2021-12-23 21:40:48 +01:00
|
|
|
<p class="date">
|
2021-12-23 23:13:01 +01:00
|
|
|
Speakers: ${sanitize(talk.persons.join(", ") || "---")}<br>
|
|
|
|
Stage: ${sanitize(talk.room)}<br>
|
|
|
|
Time: ${sanitize(talk.start_string)}<br>
|
|
|
|
Duration: ${sanitize(talk.duration)}<br>
|
2021-12-23 21:40:48 +01:00
|
|
|
</p>
|
2021-12-23 23:13:01 +01:00
|
|
|
<p>${sanitize(talk.abstract)}</p>
|
2021-12-23 23:43:55 +01:00
|
|
|
</div>
|
|
|
|
<div class="box-footer">
|
|
|
|
<div class="progress"><div class="fill" style="width: ${value / max * 100}%"></div></div>
|
2021-12-23 21:40:48 +01:00
|
|
|
</div>
|
|
|
|
</li>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function main() {
|
|
|
|
const resp = await fetch("https://static.rc3.world/schedule/everything.json");
|
|
|
|
const schedule = await resp.json();
|
|
|
|
|
2021-12-24 15:48:07 +01:00
|
|
|
const now = Date.now();
|
2021-12-23 21:40:48 +01:00
|
|
|
|
2021-12-23 23:13:01 +01:00
|
|
|
const upcoming = [];
|
2021-12-23 21:40:48 +01:00
|
|
|
for (const day of schedule.schedule.conference.days) {
|
|
|
|
for (const [channel, talks] of Object.entries(day.rooms)) {
|
|
|
|
for (const talk of talks) {
|
2021-12-23 23:13:01 +01:00
|
|
|
const talk_end = Date.parse(talk.date) + parseDuration(talk.duration);
|
2021-12-23 21:40:48 +01:00
|
|
|
if (talk_end > now) {
|
2021-12-23 23:13:01 +01:00
|
|
|
const parsed = {
|
2021-12-23 21:40:48 +01:00
|
|
|
start: Date.parse(talk.date),
|
|
|
|
date_string: talk.date,
|
|
|
|
end: talk_end,
|
|
|
|
start_string: talk.start,
|
|
|
|
duration: talk.duration,
|
|
|
|
room: talk.room,
|
|
|
|
title: talk.title,
|
|
|
|
abstract: talk.abstract,
|
|
|
|
persons: talk.persons.map(person => person.public_name),
|
|
|
|
};
|
|
|
|
upcoming.push(parsed);
|
|
|
|
break;
|
|
|
|
}
|
2021-12-23 23:13:01 +01:00
|
|
|
}
|
2021-12-23 21:40:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-23 23:13:01 +01:00
|
|
|
let content = "";
|
2021-12-23 21:40:48 +01:00
|
|
|
upcoming.sort((a, b) => a.end - b.end);
|
2021-12-23 23:13:01 +01:00
|
|
|
for (const talk of upcoming.slice(0, 6)) {
|
2021-12-23 21:40:48 +01:00
|
|
|
content += render(talk);
|
|
|
|
}
|
|
|
|
|
2021-12-24 18:04:05 +01:00
|
|
|
const time = new Date();
|
|
|
|
|
2021-12-23 21:40:48 +01:00
|
|
|
document.getElementById("list").innerHTML = content;
|
2021-12-24 18:04:05 +01:00
|
|
|
const hours = `${time.getHours()}`.padStart(2, '0');
|
|
|
|
const minutes = `${time.getMinutes()}`.padStart(2, '0');
|
2021-12-23 23:13:01 +01:00
|
|
|
document.getElementById("time").innerText = `${hours}:${minutes}`;
|
|
|
|
|
2021-12-24 18:04:05 +01:00
|
|
|
setTimeout(main, (60-time.getSeconds())*1000+500);
|
2021-12-23 21:40:48 +01:00
|
|
|
}
|
2021-12-23 23:43:55 +01:00
|
|
|
</script>
|
2021-12-23 21:40:48 +01:00
|
|
|
</head>
|
2021-12-23 23:43:55 +01:00
|
|
|
<body class="infobeamer">
|
2021-12-23 21:53:57 +01:00
|
|
|
<header>
|
|
|
|
<nav class="nav nav-main">
|
|
|
|
<a class="nav-logo" href="/">
|
2021-12-23 23:43:55 +01:00
|
|
|
<img src="/franconianNet.svg"
|
2021-12-23 23:13:01 +01:00
|
|
|
alt="Logo of franconian.net">
|
|
|
|
franconian.net
|
|
|
|
</a>
|
|
|
|
<a class="nav-link" id="time"></a>
|
2021-12-23 21:53:57 +01:00
|
|
|
</nav>
|
|
|
|
</header>
|
2021-12-23 21:40:48 +01:00
|
|
|
<main>
|
|
|
|
<h1>running / upcoming</h1>
|
|
|
|
<ul class="box-grid" id="list">
|
2021-12-23 21:53:57 +01:00
|
|
|
</ul>
|
2021-12-23 21:40:48 +01:00
|
|
|
</main>
|
|
|
|
</body>
|
|
|
|
</html>
|