clean code

This commit is contained in:
gnieark 2016-05-15 14:31:50 +02:00
parent 553183b781
commit dfcaed4beb
2 changed files with 8 additions and 10 deletions

View File

@ -198,7 +198,7 @@ switch ($_POST['act']){
'strikeX' => $strikeX,
'strikeY' => $strikeY,
'strikeSymbol'=> $you,
'log' => $you." ".$currentBotName." a gagné"
'log' => $you." ".$currentBotName." joue colonne ". $anwserPlayer"et a gagné"
);
}else{
$anwserToJS=array(

View File

@ -29,7 +29,6 @@ function connectFour(bot1,bot2,xd_check, newGame){
document.getElementById('fightResult').removeChild(document.getElementById('fightResult').firstChild);
}
//create grid
var table=createElem('table',{'class':'battleGrid'});
for (var i=6; i > -1; i--){
var tr=createElem('tr');
@ -42,28 +41,27 @@ function connectFour(bot1,bot2,xd_check, newGame){
}
document.getElementById('fightResult').appendChild(table);
}
//send request
var xhr = Ajx();
xhr.onreadystatechange = function(){if(xhr.readyState == 4){
if(xhr.status == 200) {
//for debug
document.getElementById('logs').innerHTML += xhr.responseText + '<br/>';
if(xhr.status == 200) {
try{
var reponse = JSON.parse(xhr.responseText);
}catch(e){
document.getElementById('logs').innerHTML += 'erreur' +xhr.responseText;
return;
}
}
//log
document.getElementById('logs').innerHTML += reponse['log'] + '<br/>';
//fill the grid
if( reponse['strikeX'] > -1){
document.getElementById('td' + reponse['strikeX'] + '_' + reponse['strikeY']).innerHTML = reponse['strikeSymbol'];
}
//if game isn't finished, continue
if(reponse['continue'] == 1){
connectFour(bot1,bot2,xd_check, false);
}
}else{
alert ('error ' + xhr.status);
return;