jeudi 28 janvier 2016

pomodoro clock not stopping at zero

The clock works fine until it gets to zero which is where it is supposed to start the break timer. the issue is that it gets to zero then starts counting down in negative numbers. here is the function that has that code. By the way, I have the interval at 100 so I do not have to wait a long time when testing the clock.

function start(){
   $("#start").addClass("disabled");
   $("#myreset").addClass("disabled");
   var secs = Number("59");

   var min = document.getElementById("sessiontime").innerHTML; 
   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;
                           } else if(secs === 0 && min === 0){
                              clearInterval(startcounter); 
                              var x =      document.getElementById("arrownumid").innerHTML;
                        mybreak(x);
                     }
      },100);

   }
}

Aucun commentaire:

Enregistrer un commentaire