From c8a692cf39979962c72e8d3ec9108b85105feeb0 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Fri, 23 Dec 2016 21:40:46 +0100 Subject: Some changes that were lying around --- gameserver/gameserver.html | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'gameserver/gameserver.html') 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