aboutsummaryrefslogtreecommitdiffstats
path: root/vorlesungen/stream/countdown.html
blob: 99e11975e1889516982135b8eb73825ccc83a41b (plain)
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
<!DOCTYPE HTML> 
<html> 
<head> 
<style> 
p { 
text-align: center; 
font-size: 60px; 
} 
div { 
font-family: "Courier";
text-align: center; 
font-size: 60px; 
color: #990000;
} 
</style> 
</head> 
<body> 
<div id="demo"></div> 
<script> 
var deadline = 0;

function	checkfor(d) {
	let now = new Date().getTime();
	let ds = new Date().toDateString().substr(0, 17) + " " + d + ":00";
	console.log("time string: " + ds);
	let start = new Date(ds).getTime();
	console.log("now: " + now);
	if ((start > now) && ((start-now) < 1800000)) {
		deadline = start;
		console.log("set deadline to: " + ds);
	} else {
		console.log("skipping: " + ds);
	}
}

checkfor("08:10");
checkfor("09:05");
checkfor("10:10");
checkfor("11:05");
checkfor("12:10");
checkfor("13:10");
checkfor("14:05");
checkfor("15:10");
checkfor("16:05");
checkfor("17:00");
checkfor("17:55");
checkfor("19:00");

checkfor("21:41");
checkfor("22:40");
checkfor("23:10");

var x = setInterval(function() { 
let now = new Date().getTime(); 
let t = deadline - now; 
if (t > 0) { 
	let days = Math.floor(t / (1000 * 60 * 60 * 24)); 
	let hours = Math.floor((t%(1000 * 60 * 60 * 24))/(1000 * 60 * 60)); 
	let minutes = Math.floor((t % (1000 * 60 * 60)) / (1000 * 60)); 
	let seconds = Math.floor((t % (1000 * 60)) / 1000); 
	document.getElementById("demo").innerHTML
		= ("00" + minutes).slice(-2) + ":" + ("00" + seconds).slice(-2); 
} else {
	document.getElementById("demo").innerHTML = "00:00"; 
}
}, 1000); 

</script> 

</body> 
</html>