Last active
December 20, 2022 09:54
-
-
Save abijaK/47171f0b60ae661a61cf3f181d1fdff7 to your computer and use it in GitHub Desktop.
Réinitialiser la muniterie
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add function that will be called onClick | |
let start = () => { | |
// Display break button and hide start button | |
breakButton.style.display = "block"; | |
startButton.style.display = "none"; | |
// Set minutes to start count down | |
let onWorking = initial.startTime; | |
let onBreaking = initial.breakTime - 1; | |
isSwitching = 0; | |
//Add function count down | |
let countDown = () => { | |
// Display values in DOM once countdown has start | |
min.innerHTML = onWorking; | |
sec.innerHTML = decrementSec;/* 24:59 */ | |
// Decrement seconds | |
decrementSec -=1 | |
// if seconds get value 0 then decrement minutes (onWorking) | |
if (decrementSec === 0) { | |
onWorking -= 1; | |
if (onWorking === -1) { | |
if (isSwitching % 2 === 0) { | |
// Start with breack timer | |
onWorking = initial.breakTime; | |
isSwitching+=1 | |
} else{ | |
// Continue working | |
onBreaking = initial.startTime; //25 | |
isSwitching = 0; | |
} | |
} | |
decrementSec = 59; | |
} | |
}; | |
// set the interval to execute the function countDown() | |
timer = setInterval(countDown, 1000); // 1000ms | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment