-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
46 lines (40 loc) · 1.13 KB
/
index.js
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
var plakate = [],
news = [],
currentHour = 0,
currentPlakat = 0,
plakatTimeout = null,
plakatTouchHandler = null;
// updates display content that changes rarely (rescans the plakate and news directories and refreshes mensaplan)
function reloadDisplayContent() {
loadPlakate();
loadNews();
loadMensa();
}
function updateClock() {
// update the clock
var time = new Date(),
hours = leadingChar(" ", time.getHours()),
minutes = leadingChar("0", time.getMinutes()),
msecondsuntilrefresh = (60-time.getSeconds())*1000;
document.getElementById("uhr").innerHTML = hours + ":" + minutes;
window.setTimeout(updateClock, msecondsuntilrefresh);
// every full hour reload rarely changing display content
if (time.getHours() != currentHour) {
currentHour = time.getHours();
reloadDisplayContent();
}
// helper
function leadingChar(char, int) {
var result = int;
if (int < 10) result = char + int;
return result;
}
}
function init() {
currentHour = new Date().getHours();
updateClock();
reloadDisplayContent();
refreshFahrplan();
refreshWetter();
refreshRegenradarGif();
}