mirror of
https://github.com/LucasVbr/timer.git
synced 2026-05-13 17:22:04 +00:00
f8fd5d167b
Sound do not play because there is a security on Chrome. User need to interact with the page.
23 lines
621 B
JavaScript
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); |