-
Notifications
You must be signed in to change notification settings - Fork 0
/
clock.js
44 lines (38 loc) · 1 KB
/
clock.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
var defaultSecs = 0;
var defaultMinutes = 15;
var secs = defaultSecs;
var minutes = defaultMinutes;
function reset() {
container.classList.add("explosion");
setTimeout(function() {
container.classList.remove("explosion");
secs = defaultSecs;
minutes = defaultMinutes;
console.log('RESET');
insertData(); // function defined in prices.js
}, 1000);
}
function updateClock () {
if (secs == 0 && minutes == 0) {
reset();
}
if (secs == 0) {
secs = 60;
minutes--;
}
secs--;
}
function showTime() {
updateClock()
var m = (minutes < 10) ? "0" + minutes : minutes;
var s = (secs < 10) ? "0" + secs : secs;
if (minutes < 0) {
m = "00";
}
var time = m + ":" + s + " ";
document.getElementById("MyClockDisplay").innerText = time;
document.getElementById("MyClockDisplay").textContent = time;
setTimeout(showTime, 1000);
}
showTime();
var container = document.getElementById("container");