game-client.js
function countdownTimer() {
    $(COUNTDOWN).html("0m 0s");
    var end_t = COUNTDOWNTIME;
    var start_t = (new Date()).getTime()/1000;
    function countdown() {
        var cur_t = (new Date()).getTime()/1000;
        var timeleft = (end_t - (cur_t - start_t));
        if (timeleft >= 0) {
            var min = Math.floor(timeleft / 60);
            var sec = Math.floor(timeleft % 60);
            $(COUNTDOWN).html(min + "m " + sec + "s");
            COUNTDOWNTID = setTimeout(countdown, 1000);
        } else {
            $.post("/games/" + enc($.cookie("game")) + "/players",
                   {end_turn: true}, function() {
                getPlayers();
            });
        }
    }
    countdown();
}
function countdownTimer() {
    $(COUNTDOWN).html("0m 0s");
    var end_t = COUNTDOWNTIME;
    var start_t = (new Date()).getTime()/1000;
    function countdown() {
        var cur_t = (new Date()).getTime()/1000;
        var timeleft = (end_t - (cur_t - start_t));
        if (timeleft >= 0) {
            var min = Math.floor(timeleft / 60);
            var sec = Math.floor(timeleft % 60);
            $(COUNTDOWN).html(min + "m " + sec + "s");
            COUNTDOWNTID = setTimeout(countdown, 1000);
        } else {
            $.post("/games/" + enc($.cookie("game")) + "/players",
                   {end_turn: true}, function() {
                getPlayers();
            });
        }
    }
    countdown();
}
function countdownTimer ( ) { $ ( COUNTDOWN ) . html ( "0m 0s" ) ; var end_t = COUNTDOWNTIME ; var start_t = ( new Date ( ) ) . getTime ( ) / 1000 ; function countdown ( ) { var cur_t = ( new Date ( ) ) . getTime ( ) / 1000 ; var timeleft = ( end_t - ( cur_t - start_t ) ) ; if ( timeleft >= 0 ) { var min = Math . floor ( timeleft / 60 ) ; var sec = Math . floor ( timeleft % 60 ) ; $ ( COUNTDOWN ) . html ( min + "m " + sec + "s" ) ; COUNTDOWNTID = setTimeout ( countdown , 1000 ) ; } else { $ . post ( "/games/" + enc ( $ . cookie ( "game" ) ) + "/players" , { end_turn : true } , function ( ) { getPlayers ( ) ; } ) ; } } countdown ( ) ; }
Countdown timer. Update onscreen timer and end turn if time gets too low.
Countdown timer . Update onscreen timer and end turn if time gets too low .