-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtimer.js
More file actions
85 lines (73 loc) · 2.53 KB
/
Copy pathtimer.js
File metadata and controls
85 lines (73 loc) · 2.53 KB
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
var countdownElement = document.getElementById('countdown-sec');
var countminElement = document.getElementById('countdown-min');
var counthourElement = document.getElementById('countdown-hour');
var startButton = document.getElementById('start-btn');
var pauseButton = document.getElementById('pause-btn');
var resetButton = document.getElementById('reset-btn');
var initialcountdown = countdownElement.innerHTML;
var mincount = countminElement.innerHTML;
var hourcount = counthourElement.innerHTML;
var min = 0;
var hour = 0;
var sec = 0;
var startInterval;
function timerStart() {
initialcountdown = parseInt(initialcountdown) + 1;
if (initialcountdown < 10) {
countdownElement.innerHTML = '0' + initialcountdown;
} else {
countdownElement.innerHTML = initialcountdown;
}
if (initialcountdown == 5) {
initialcountdown = 0;
mincount = parseInt(mincount) + 1;
if (mincount < 10) {
countminElement.innerHTML = '0' + mincount;
} else {
countminElement.innerHTML = mincount;
}
} else if (mincount == 15) {
initialcountdown = 0;
initialcountdown = initialcountdown + 1;
mincount = 0;
mincount = mincount + 1;
hourcount = parseInt(hourcount) + 1;
if (hourcount < 10) {
counthourElement.innerHTML = '0' + hourcount;
} else {
counthourElement.innerHTML = hourcount;
}
}
}
function startfunction() {
startInterval = setInterval(timerStart, 1000);
startButton.style.opacity = '0';
startButton.style.visibility = 'hidden';
setTimeout(function () {
startButton.style.display = 'none';
pauseButton.style.display = 'block';
pauseButton.style.opacity = '1';
pauseButton.style.visibility = 'visible';
}, 500);
}
function pausefunction() {
clearInterval(startInterval);
pauseButton.style.opacity = '0';
pauseButton.style.visibility = 'hidden';
setTimeout(function () {
startButton.style.display = 'block';
startButton.style.opacity = '1';
startButton.style.visibility = 'visible';
pauseButton.style.display = 'none';
}, 500);
}
function resetfunction() {
clearInterval(startInterval);
pausefunction();
initialcountdown = 0;
if (initialcountdown == 0) {
countminElement.innerHTML = '00';
counthourElement.innerHTML = '00';
countdownElement.innerHTML = '00';
}
}