MCPcopy
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / updateCountDown

Function updateCountDown

assets/js/newyearcountdown.js:15–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13year.innerText = currentYear;
14
15function updateCountDown(){
16 const currentTime = new Date();
17 const diff = newYearTime - currentTime;
18 // const diff = 0;
19
20 const daysLeft = Math.floor(diff/1000/60/60/24);
21 const hoursLeft = Math.floor(diff/1000/60/60) %24;
22 const minutesLeft = Math.floor(diff/1000/60) %60;
23 const secondsLeft = Math.floor(diff/1000) %60;
24
25 days.innerHTML = daysLeft;
26 hours.innerHTML = hoursLeft <10 ? '0'+hoursLeft :hoursLeft;
27 mins.innerHTML = minutesLeft <10? '0'+minutesLeft:minutesLeft;
28 secs.innerHTML = secondsLeft <10? '0'+secondsLeft:secondsLeft;
29 if(diff === 0){
30 setTimeout(function () {
31 confetti.start();
32 }, 1000);
33 setTimeout(function () {
34 confetti.stop();
35 }, 5000);
36 }
37}
38
39setTimeout(()=>{
40 loading.remove();

Callers

nothing calls this directly

Calls 1

startMethod · 0.80

Tested by

no test coverage detected