Last active
August 29, 2015 13:58
-
-
Save nadeemelahi/10367539 to your computer and use it in GitHub Desktop.
Revisions
-
nadeemelahi revised this gist
Apr 19, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,9 +2,9 @@ <button id="start">start</button> <button id="stop">stop</button> var secs = 599; function decrementTimer() { var currentMinutes = "0" + Math.floor(secs / 60); var currentSeconds = Math.floor((secs % 60)); if(currentSeconds <= 9) currentSeconds = "0" + currentSeconds; var timeLeft = currentMinutes + ":" + currentSeconds; -
nadeemelahi revised this gist
Apr 10, 2014 . 1 changed file with 34 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -19,4 +19,37 @@ $("#start").click(function(){ }); $("#stop").click(function(){ clearInterval(clearDecrementTimer); }); =============================================================================================================== <p id="whiteTimeLeft"></p> var decrementTimer = function(secs) { var currentMinutes = "0" + Math.floor(secs / 6000); var currentSeconds = Math.floor((secs%60)); if(currentSeconds <= 9) currentSeconds = "0" + currentSeconds; var timeLeft = currentMinutes + ":" + currentSeconds; console.log(timeLeft); $("#whiteTimeLeft").text(timeLeft); if(secs > 0) setTimeout(function(){decrementTimer(secs-1)},1000); }; decrementTimer(59999); =============================================================================================================== <p id="whiteTimeLeft"></p> var element = document.getElementById("whiteTimeLeft"); var time = new Date(); time.setMinutes(10); time.setSeconds(0); function decrementTimer() { element.innerHTML = time.getMinutes() + ":" + time.getSeconds(); // todo: pad zeroes time.setSeconds(time.getSeconds() - 1); setTimeout(decrementTimer, 1000); } decrementTimer(); -
nadeemelahi revised this gist
Apr 10, 2014 . No changes.There are no files selected for viewing
-
nadeemelahi created this gist
Apr 10, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ <p id="whiteTimeLeft"></p> <button id="start">start</button> <button id="stop">stop</button> var secs = 59999; function decrementTimer() { var currentMinutes = "0" + Math.floor(secs / 6000); var currentSeconds = Math.floor((secs % 60)); if(currentSeconds <= 9) currentSeconds = "0" + currentSeconds; var timeLeft = currentMinutes + ":" + currentSeconds; $("#whiteTimeLeft").text(timeLeft); secs-- } var clearDecrementTimer; $("#start").click(function(){ clearDecrementTimer = setInterval(function(){ decrementTimer() }, 1000); }); $("#stop").click(function(){ clearInterval(clearDecrementTimer); });