diff options
Diffstat (limited to 'gameserver')
| -rw-r--r-- | gameserver/gameserver.html | 18 | ||||
| -rwxr-xr-x | gameserver/gameserver.js | 1 | 
2 files changed, 13 insertions, 6 deletions
diff --git a/gameserver/gameserver.html b/gameserver/gameserver.html index 7fc27fc..fdce5a8 100644 --- a/gameserver/gameserver.html +++ b/gameserver/gameserver.html @@ -39,6 +39,7 @@ function preinit(){  		var spaceidx=msg.indexOf(" "),  		    cmd=msg.slice(0,spaceidx),  		    arg=JSON.parse(msg.slice(spaceidx+1)); +		var alerttext;  		console.log(cmd,arg);  		if(cmd=="nick"){  			nick=arg; @@ -96,10 +97,11 @@ function preinit(){  		} else if(cmd=="game_win"){  			bgcell(neuidx).classList.add("win");  			if(arg==imPlayer){ -				alert("You have won the game!"); +				alerttext="You have won the game!";  			} else { -				alert("You have lost the game! Better luck next time."); +				alerttext="You have lost the game! Better luck next time.";  			} +			setTimeout(function(){alert(alerttext);},canclick?500:1000);  		} else alert("Unrecognised message "+msg);  	});  	ws.addEventListener("open",function(){ @@ -242,14 +244,18 @@ function enableClicking(en,disneu){  	en=en?true:false;  	disneu=disneu?true:false;  	for(i=0;i<8;i++){ -		document.getElementById("input_neudir"+i)[en&&!disneu?"removeAttribute":"setAttribute"]("disabled"); -		document.getElementById("input_dir"+i)[en?"removeAttribute":"setAttribute"]("disabled"); +		if(en&&!disneu)document.getElementById("input_neudir"+i).removeAttribute("disabled"); +		else document.getElementById("input_neudir"+i).setAttribute("disabled",""); +		if(en)document.getElementById("input_dir"+i).removeAttribute("disabled"); +		else document.getElementById("input_dir"+i).setAttribute("disabled","");  	}  	l=document.getElementsByName("inputstoneradio");  	for(i=0;i<l.length;i++){ -		l[i][en&&(imPlayer==-1||board[i]==imPlayer)?"removeAttribute":"setAttribute"]("disabled"); +		if(en&&(imPlayer==-1||board[i]==imPlayer))l[i].removeAttribute("disabled"); +		else l[i].setAttribute("disabled","");  	} -	document.getElementById("input_domovebtn")[en?"removeAttribute":"setAttribute"]("disabled"); +	if(en)document.getElementById("input_domovebtn").removeAttribute("disabled"); +	else document.getElementById("input_domovebtn").setAttribute("disabled","");  	clickenabled=[en,disneu];  } diff --git a/gameserver/gameserver.js b/gameserver/gameserver.js index 8ab4bbc..a9233e9 100755 --- a/gameserver/gameserver.js +++ b/gameserver/gameserver.js @@ -225,6 +225,7 @@ function handleMessage(conn,msg){  		c2.ws.send("other_turn "+JSON.stringify(mv));  		won=checkWin(game.board,3-game.onturn); //player that just moved  		if(won){ +			saveFinishedBoard(game.board);  			conn.ws.send("game_win "+won);  			c2.ws.send("game_win "+won);  			games.splice(findby(games,"id",conn.gameid),1);  | 
