-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
126 lines (102 loc) · 2.89 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<img src="NICD_Secondary Logo_Landscape_White.png" width="50%">
<div>
<div id="minutes" class="countdown"></div>
<div id="seconds" class="countdown"></div>
</div>
<div>
<button onclick="start()" id="start">Start</button>
<button onclick="reset()" id="reset">Reset</button>
</div>
<style>
@font-face {
font-family: Derailed;
src: url('derailed-bold-webfont.ttf');
}
.countdown {
font-family: Derailed;
font-size: 30vw;
color: white;
/* overflow: hidden; */
width: 49vw;
display: inline-block;
}
body {
background-color: black;
}
img {
display: block;
margin-left: auto;
margin-right: auto;
}
button {
background-color: black;
font-family: Derailed;
border-color: white;
color: white;
font-size: 12pt;
border-radius: 10px;
padding-left:10;
padding-right:10;
padding-top:5;
padding-bottom:5;
margin-left: 10;
}
button:disabled {
background-color: grey;
color: lightgrey;
}
#minutes {
text-align: right
}
#seconds {
width: 40vw
}
*/
</style>
<script>
var timeout;
const initMinutes = 10;
const initSeconds = 0;
var minutes = initMinutes;
var seconds = initSeconds;
minutesElement = document.getElementById("minutes");
secondsElement = document.getElementById("seconds");
startElement = document.getElementById("start")
function fmt(number) {return number.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})}
reset()
function reset() {
clearTimeout(timeout)
startElement.innerHTML = 'Start'
startElement.onclick = start
minutesElement.innerHTML = fmt(initMinutes) + ':'
secondsElement.innerHTML = fmt(initSeconds)
minutes = initMinutes
seconds = initSeconds
}
function stop() {
clearTimeout(timeout)
startElement.innerHTML = 'Start'
startElement.onclick = start
}
function start() {
var endTime, msLeft, time;
startElement.innerHTML = 'Stop'
startElement.onclick = stop
function updateTimer() {
msLeft = endTime - (+new Date);
if (msLeft < 1000) {
seconds = 0
secondsElement.innerHTML = "00";
} else {
time = new Date(msLeft);
seconds = time.getUTCSeconds()
minutes = time.getUTCMinutes()
minutesElement.innerHTML = fmt(minutes) + ':'
secondsElement.innerHTML = fmt(seconds);
timeout = setTimeout(updateTimer, time.getUTCMilliseconds() + 500);
}
}
endTime = (+new Date) + 1000 * (60 * minutes + seconds) + 500;
updateTimer();
}
</script>