Skip to content

Commit

Permalink
fix timer
Browse files Browse the repository at this point in the history
  • Loading branch information
Closer2U committed Feb 28, 2024
1 parent 3f7a40a commit c9a3126
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions js/timer.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
function startTimer(duration, display) {
var timer = duration, minutes, seconds;
// clearInterval(interval);
var interval = setInterval(function () {
setInterval(function () {
minutes = parseInt(timer / 60, 10)
seconds = parseInt(timer % 60, 10);

minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;

display.textContent = minutes + ":" + seconds;

fadeTimer();

if (--timer < 0) {
timer = duration;

// Put all CSS back to First Iteration
clearInterval(interval);
document.getElementById("Pulse").style.animation = "";
document.getElementById("Start").style.display = "";
}
}, 1000);
}

window.onclick = function () {
display = document.getElementById('Timer');
var oneMinute = 60 ; //,
// display = document.getElementById('Timer');
window.onload = function () {
var oneMinute = 60,
display = document.getElementById('Timer');
startTimer(oneMinute, display);
};

Expand Down

0 comments on commit c9a3126

Please sign in to comment.