disable button while game
This commit is contained in:
parent
92db3755c5
commit
be5b07fa9a
|
|
@ -21,10 +21,14 @@ function createElem(type,attributes){
|
||||||
function connectFour(bot1,bot2,xd_check, gameId, newGame){
|
function connectFour(bot1,bot2,xd_check, gameId, newGame){
|
||||||
if (newGame === undefined){
|
if (newGame === undefined){
|
||||||
newGame = true;
|
newGame = true;
|
||||||
gameId=0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newGame){
|
if (newGame){
|
||||||
|
gameId=0;
|
||||||
|
//don't touch the button while game is not ended
|
||||||
|
document.getElementById('fightButton').disabled=true;
|
||||||
|
|
||||||
//empty
|
//empty
|
||||||
while (document.getElementById('fightResult').firstChild) {
|
while (document.getElementById('fightResult').firstChild) {
|
||||||
document.getElementById('fightResult').removeChild(document.getElementById('fightResult').firstChild);
|
document.getElementById('fightResult').removeChild(document.getElementById('fightResult').firstChild);
|
||||||
|
|
@ -65,6 +69,7 @@ function connectFour(bot1,bot2,xd_check, gameId, newGame){
|
||||||
document.getElementById('td' + reponse['strikeX'] + '_' + reponse['strikeY']).innerHTML = reponse['strikeSymbol'];
|
document.getElementById('td' + reponse['strikeX'] + '_' + reponse['strikeY']).innerHTML = reponse['strikeSymbol'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//colorise cells that win
|
||||||
if(reponse['cellsWin'] === undefined){
|
if(reponse['cellsWin'] === undefined){
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
@ -79,12 +84,15 @@ function connectFour(bot1,bot2,xd_check, gameId, newGame){
|
||||||
//if game isn't finished, continue
|
//if game isn't finished, continue
|
||||||
if(reponse['continue'] == 1){
|
if(reponse['continue'] == 1){
|
||||||
connectFour(bot1,bot2,xd_check,reponse['gameId'], false);
|
connectFour(bot1,bot2,xd_check,reponse['gameId'], false);
|
||||||
|
}else{
|
||||||
|
document.getElementById('fightButton').disabled=false;
|
||||||
}
|
}
|
||||||
}else if(xhr.status == 512){
|
}else if(xhr.status == 512){
|
||||||
//just forget
|
//just forget
|
||||||
return;
|
return;
|
||||||
}else{
|
}else{
|
||||||
alert ('error ' + xhr.status);
|
alert ('error ' + xhr.status);
|
||||||
|
document.getElementById('fightButton').disabled=false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
|
|
|
||||||
|
|
@ -23,5 +23,5 @@ $bots=get_Bots_Array('connectFou');
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
<p><input type="button" value="<?php echo $lang['FIGHT']; ?>" onclick="connectFour(document.getElementById('bot1').value,document.getElementById('bot2').value,'<?php echo xd_check_input(2); ?>',0);"></p>
|
<p><input id="fightButton" type="button" value="<?php echo $lang['FIGHT']; ?>" onclick="connectFour(document.getElementById('bot1').value,document.getElementById('bot2').value,'<?php echo xd_check_input(2); ?>',0);"></p>
|
||||||
<div id="fightResult"></div>
|
<div id="fightResult"></div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user