-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcountdown.js
More file actions
24 lines (22 loc) · 745 Bytes
/
countdown.js
File metadata and controls
24 lines (22 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var countdown = document.getElementById('countdown');
var timeLeft = 3;
function renderCountdown() {
countdown.innerHTML = "<span class='countdown-number'>" + timeLeft + '</span>';
timeLeft--;
}
var timer = setInterval(function () {
if (timeLeft >= 0) {
renderCountdown();
countdown.querySelector('.countdown-number').classList.add('pulse');
setTimeout(function () {
countdown.querySelector('.countdown-number').classList.remove('pulse');
}, 200);
} else {
clearInterval(timer);
countdown.innerHTML = "<span class='countdown-number'>Closing...</span>";
countdown.querySelector('.countdown-number').classList.add('pulse');
setTimeout(function () {
window.close();
}, 1000);
}
}, 1000);