()
| 28 | |
| 29 | // Populate Countdown / Complete UI |
| 30 | function updateDOM() { |
| 31 | countdownActive = setInterval(() => { |
| 32 | const now = new Date().getTime(); |
| 33 | const distance = countdownValue - now; |
| 34 | const days = Math.floor(distance / day); |
| 35 | const hours = Math.floor((distance % day) / hour); |
| 36 | const minutes = Math.floor((distance % hour) / minute); |
| 37 | const seconds = Math.floor((distance % minute) / second); |
| 38 | // Hide Input |
| 39 | inputContainer.hidden = true; |
| 40 | // If the countdown has ended, show final state |
| 41 | if (distance < 0) { |
| 42 | countdownEl.hidden = true; |
| 43 | clearInterval(countdownActive); |
| 44 | completeElInfo.textContent = `${countdownTitle} finished on ${countdownDate}`; |
| 45 | completeEl.hidden = false; |
| 46 | } else { |
| 47 | // else, show the countdown in progress |
| 48 | countdownElTitle.textContent = `${countdownTitle}`; |
| 49 | timeElements[0].textContent = `${days}`; |
| 50 | timeElements[1].textContent = `${hours}`; |
| 51 | timeElements[2].textContent = `${minutes}`; |
| 52 | timeElements[3].textContent = `${seconds}`; |
| 53 | completeEl.hidden = true; |
| 54 | countdownEl.hidden = false; |
| 55 | } |
| 56 | }, second); |
| 57 | } |
| 58 | |
| 59 | function updateCountdown(e) { |
| 60 | e.preventDefault(); |
no outgoing calls
no test coverage detected