www.franconian.net/static/infobeamer/index.html

126 lines
4.0 KiB
HTML
Raw Normal View History

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) {
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();
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);
}
const time = new Date();
2021-12-23 21:40:48 +01:00
document.getElementById("list").innerHTML = content;
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}`;
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">
2021-12-26 01:08:28 +01:00
<a class="nav-logo" href="/"><img src="/franconianNet.svg" alt="Logo of franconian.net">
<span class="logotype">
<span>franc</span>
<span>onian</span>
<span>.net</span>
</span>
</a>
2021-12-23 23:13:01 +01:00
<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>