-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.html
81 lines (70 loc) · 3.19 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8" />
<meta http-equiv="refresh" content="3600" />
<title>Presentation</title>
<link rel="stylesheet" href="css/style.css" />
</head>
<body onload="startTime()">
<iframe
src="https://docs.google.com/presentation/d/e/2PACX-1vQbS6bGPlyTibcjsUPI1uHspUBsRSv_z_dVast1ZTcZ9Qt_GqXeHU0xWxluPZ2yCL9kftF0frYksy2h/embed?start=true&loop=true&delayms=10000&rm=minimal"
></iframe>
<footer>
<img style="filter: invert()" src="resources/images/logo.svg" alt="" />
<section id="food-schedule" title="Food schedule"></section>
<section id="clock" title="Digital Clock"></section>
</footer>
<script title="Clock">
function startTime() {
const today = new Date();
let h = today.getHours();
let m = today.getMinutes();
let s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById("clock").innerHTML = h + ":" + m;
setTimeout(startTime, 1000);
}
function checkTime(i) {
if (i < 10) {
i = "0" + i;
} // add zero in front of numbers < 10
return i;
}
</script>
<script title="Food schedule">
AddFoodSchedule(3);
var weekDays = ["Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag", "Söndag"];
const today = new Date(
new Date().getFullYear(),
new Date().getMonth(),
new Date().getDate()
).getTime();
function AddFoodSchedule(numDays) {
fetch("food-schedule/data.json")
.then((response) => response.json())
.then((data) => {
const allDays = data.weeks[0].days;
const comingDays = allDays.filter((d) => new Date(d.date * 1000) >= today);
const chosenDays = comingDays.slice(0, numDays).sort((a, b) => b.date - a.date);
const foodScheduleContainer = document.getElementById("food-schedule");
for (const day of chosenDays) {
const title = document.createElement("h3");
const dayOfWeek = new Date(day.date * 1000).getDay();
title.innerHTML = `${weekDays[dayOfWeek - 1]} - Vecka ${
data.weeks[0].number
}`;
const body = document.createElement("p");
body.innerHTML = day.items.join("<br/>");
const section = document.createElement("section");
section.appendChild(title);
section.appendChild(body);
foodScheduleContainer.prepend(section.cloneNode(true));
}
})
.catch(console.error);
}
</script>
</body>
</html>