Skip to content

Instantly share code, notes, and snippets.

@nadeemelahi
Last active August 29, 2015 13:58
Show Gist options
  • Select an option

  • Save nadeemelahi/10367539 to your computer and use it in GitHub Desktop.

Select an option

Save nadeemelahi/10367539 to your computer and use it in GitHub Desktop.

Revisions

  1. nadeemelahi revised this gist Apr 19, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.txt
    Original 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 = 59999;
    var secs = 599;
    function decrementTimer() {
    var currentMinutes = "0" + Math.floor(secs / 6000);
    var currentMinutes = "0" + Math.floor(secs / 60);
    var currentSeconds = Math.floor((secs % 60));
    if(currentSeconds <= 9) currentSeconds = "0" + currentSeconds;
    var timeLeft = currentMinutes + ":" + currentSeconds;
  2. nadeemelahi revised this gist Apr 10, 2014. 1 changed file with 34 additions and 1 deletion.
    35 changes: 34 additions & 1 deletion gistfile1.txt
    Original 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();

  3. nadeemelahi revised this gist Apr 10, 2014. No changes.
  4. nadeemelahi created this gist Apr 10, 2014.
    22 changes: 22 additions & 0 deletions gistfile1.txt
    Original 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);
    });