Client/JavaScript/game.js
// initializes the game and calls the poll function
initializes the game and calls the poll function
initializes the game and calls the poll function
function main() {
	var turn=0;
	$.ajax({
		type: "POST",
		url: "/HTML/getGameState",
		data: {gameId:window.location.search.substring(3)},
		dataType: 'json',
		complete: function(xhr) {
			if(xhr.responseText == "Game not found" || xhr.responseText == "Access denied" || xhr.responseText=="Not authorized") window.location.pathname = "/HTML/not_found.html";
			else {
				game = xhr.responseJSON;
				if(game.players.length == 2) {
					$("div#player_3 div.userDivs").css({"background-color":"rgb(128, 0, 0)", "display":"block"});
				}
				else {
					$("div#player_3 div.userDivs").css({"background-color":"rgb(0, 51, 102)", "display":"block"});
					$("div#player_2 div.userDivs").css({"background-color":"rgb(128, 0, 0)", "display":"block"});
					$("div#player_4 div.userDivs").css({"background-color":"rgb(128, 0, 0)", "display":"block"});
				}
				updateOtherPlayers();
				updateOwnCards();
				updateTurn();
				updateTableCards();
				updateScore();
				displayMessages();
				poll();
			}
		}
	});
}
function main ( ) { var turn = 0 ; $ . ajax ( { type : "POST" , url : "/HTML/getGameState" , data : { gameId : window . location . search . substring ( 3 ) } , dataType : 'json' , complete : function ( xhr ) { if ( xhr . responseText == "Game not found" || xhr . responseText == "Access denied" || xhr . responseText == "Not authorized" ) window . location . pathname = "/HTML/not_found.html" ; else { game = xhr . responseJSON ; if ( game . players . length == 2 ) { $ ( "div#player_3 div.userDivs" ) . css ( { "background-color" : "rgb(128, 0, 0)" , "display" : "block" } ) ; } else { $ ( "div#player_3 div.userDivs" ) . css ( { "background-color" : "rgb(0, 51, 102)" , "display" : "block" } ) ; $ ( "div#player_2 div.userDivs" ) . css ( { "background-color" : "rgb(128, 0, 0)" , "display" : "block" } ) ; $ ( "div#player_4 div.userDivs" ) . css ( { "background-color" : "rgb(128, 0, 0)" , "display" : "block" } ) ; } updateOtherPlayers ( ) ; updateOwnCards ( ) ; updateTurn ( ) ; updateTableCards ( ) ; updateScore ( ) ; displayMessages ( ) ; poll ( ) ; } } } ) ; }
initializes the game and calls the poll function
initializes the game and calls the poll function