I am finishing up a pomodoro clock and I have everything working just fine, until the timer gets to zero which is the time it is supposed to switch over the break timer. Below is the link to codepen where I have my code. Please note that from all the code the start function and the mybreak function are the ones to look at to avoid all the other clutter.
function start(){
$("#start").addClass("disabled");
$("#myreset").addClass("disabled");
var secs = Number("59");
var minutes = document.getElementById('mytimer').innerHTML;
var num = minutes.split("");
var min = document.getElementById("sessiontime").innerHTML;
var min = min-=1;
if(min > -1){
startcounter = setInterval(function(){
secs--;
if(secs > 9){
document.getElementById("mytimer").innerHTML = min +":"+ secs;
} else if(secs >= 0 && secs < 10){
secs = "0"+secs;
document.getElementById("mytimer").innerHTML = min +":"+ secs;
} else if(secs === 0){
min--;
secs = 59;
}
},1000);
}else if (min === 0 && secs === 00){
var x = document.getElementById("arrownumid").innerHTML;
mybreak(x);
}
}
function mybreak(bt){
var b = bt;
var secs = Number("59");
//document.getElementById("mytimer").innerHTML = mybt;
min--;
startBreak = setInterval(function(){
secs--;
if(min > -1){
if(secs > 9){
document.getElementById("mytimer").innerHTML = b + ":" + secs;
}else if(secs > 0 && secs < 10){
secs = "0" + secs;
document.getElementById("mytimer").innerHTML = b + ":" + secs;
}else if(secs === 0){
document.getElementById("mytimer").innerHTML = "Break Over";
}
}
}, 1000);
}
thank you
Aucun commentaire:
Enregistrer un commentaire