game-client.js
function drawTurnInfo(pdata) {
    var my_game = $.cookie("game");
    var my_player = pdata[$.cookie("player")];

    $(PIECES).empty();
    $(ADDPIECE).show();

    // allow player to end his turn
    if (my_player.has_turn) {
        $(ENDTURN).removeAttr('disabled');
        $(TURN).html("It's your turn! You have " +
                     "<span id='countdown'>0m 0s</span> left.");
        $(ENDTURN)[0].onclick = function() {
            $.post("/games/" + enc(my_game) + "/players", {end_turn: true}, function() {
                getPlayers();

                /* Typically we let HAVETURN get updated from the server
                 * in onGetPlayers(), but if there is only one player this
                 * doesn't work very well (the player has to refresh manually).
                 * So we force it to false here in this special case.
                 */
                if (Object.keys(pdata).length === 1) {
                    HAVETURN = false;
                    clearTimeout(COUNTDOWNTID);
                }
            });
        };
    } else {
        $(ENDTURN).attr('disabled', '');
        $(TURN).html("It's not your turn.");
    }
    getPiecesLeft();
    getBoard();
    getMyPieces(my_player);
}
function drawTurnInfo(pdata) {
    var my_game = $.cookie("game");
    var my_player = pdata[$.cookie("player")];

    $(PIECES).empty();
    $(ADDPIECE).show();

    // allow player to end his turn
    if (my_player.has_turn) {
        $(ENDTURN).removeAttr('disabled');
        $(TURN).html("It's your turn! You have " +
                     "<span id='countdown'>0m 0s</span> left.");
        $(ENDTURN)[0].onclick = function() {
            $.post("/games/" + enc(my_game) + "/players", {end_turn: true}, function() {
                getPlayers();

                /* Typically we let HAVETURN get updated from the server
                 * in onGetPlayers(), but if there is only one player this
                 * doesn't work very well (the player has to refresh manually).
                 * So we force it to false here in this special case.
                 */
                if (Object.keys(pdata).length === 1) {
                    HAVETURN = false;
                    clearTimeout(COUNTDOWNTID);
                }
            });
        };
    } else {
        $(ENDTURN).attr('disabled', '');
        $(TURN).html("It's not your turn.");
    }
    getPiecesLeft();
    getBoard();
    getMyPieces(my_player);
}
function drawTurnInfo ( pdata ) { var my_game = $ . cookie ( "game" ) ; var my_player = pdata [ $ . cookie ( "player" ) ] ; $ ( PIECES ) . empty ( ) ; $ ( ADDPIECE ) . show ( ) ; // allow player to end his turn if ( my_player . has_turn ) { $ ( ENDTURN ) . removeAttr ( 'disabled' ) ; $ ( TURN ) . html ( "It's your turn! You have " + "<span id='countdown'>0m 0s</span> left." ) ; $ ( ENDTURN ) [ 0 ] . onclick = function ( ) { $ . post ( "/games/" + enc ( my_game ) + "/players" , { end_turn : true } , function ( ) { getPlayers ( ) ; /* Typically we let HAVETURN get updated from the server
                 * in onGetPlayers(), but if there is only one player this
                 * doesn't work very well (the player has to refresh manually).
                 * So we force it to false here in this special case.
                 */ if ( Object . keys ( pdata ) . length === 1 ) { HAVETURN = false ; clearTimeout ( COUNTDOWNTID ) ; } } ) ; } ; } else { $ ( ENDTURN ) . attr ( 'disabled' , '' ) ; $ ( TURN ) . html ( "It's not your turn." ) ; } getPiecesLeft ( ) ; getBoard ( ) ; getMyPieces ( my_player ) ; }
Draw player's pieces and It's Your Turn info.
@param {obj} pdata json data from the server
Draw player s pieces and It s Your Turn info .