Files
timer/js/main.js
T
Tchi f8fd5d167b Edit color and add sound
Sound do not play because there is a security on Chrome. User need to interact with the page.
2021-07-04 16:37:21 +02:00

23 lines
621 B
JavaScript

/* HTML contents */
var body = document.body;
var timerHTML = document.getElementById("timer");
var ding = document.getElementById("ding");
/* GET url variable */
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
time = getTimeUrl();
/* Set the timer */
let timer = new Timer(time)
let localTimer = setInterval(() => {
timerHTML.innerHTML = timer.toString();
timer.decrement();
if(timer.getTime() < 0) {
clearInterval(localTimer);
body.style.backgroundColor = "red";
timerHTML.style.color = "white";
ding.play();
}
}, 1000);