log init message

This commit is contained in:
Gnieark 2016-07-01 07:50:35 +02:00
parent 71e6f526c0
commit c3d0f628e5
2 changed files with 25 additions and 12 deletions

View File

@ -69,16 +69,12 @@ switch ($_POST['act']){
} }
} }
/*
if($_POST['fullLogs'] == "true"){ return json_encode(array(
$fullLogs='Arena send to '.$playerName.'<em>'.htmlentities($tempPlayer['messageSend']).'</em><br/> 'status' => 'OK',
HTTP status: <em>'.htmlentities($tempPlayer['httpStatus']).'</em><br/> 'logs' => $logs
Bot anwser: <em>'.htmlentities($tempPlayer['response']).'</em><br/>'; ));
}else{
$fullLogs='';
}
*/
die; die;
break; break;
default: default:

View File

@ -4,6 +4,14 @@ function createElem(type,attributes){
{elem.setAttribute(i,attributes[i]);} {elem.setAttribute(i,attributes[i]);}
return elem; return elem;
} }
function addLog(message){
var divLogs = document.getElementById("logs");
var p=createElem('p',{});
p.innerHTML=message;
divLogs.appendChild(p);
divLogs.scrollTop = divLogs.scrollHeight;
}
function createElemNS(type,attributes){ function createElemNS(type,attributes){
//same as createElem but with ns for svg file //same as createElem but with ns for svg file
var elem=document.createElementNS("http://www.w3.org/2000/svg",type); var elem=document.createElementNS("http://www.w3.org/2000/svg",type);
@ -52,7 +60,14 @@ function applyInitMessage(req){
//callback function when init game request //callback function when init game request
if(req.readyState == 4){ if(req.readyState == 4){
if(req.status == 200) { if(req.status == 200) {
alert (req.responseText); //alert (req.responseText);
try{
var ret = JSON.parse(req.responseText);
}catch(e){
addLog('erreur' +xhr.responseText);
return;
}
addLog(ret['logs']);
}else{ }else{
alert ('error ' + req.status); alert ('error ' + req.status);
@ -71,7 +86,9 @@ function tron(xd_check){
var rect=createElemNS('rect',{'x':'0','y':'0','width':'1000','height':'1000','style':'stroke:#000000; fill:none;'}); var rect=createElemNS('rect',{'x':'0','y':'0','width':'1000','height':'1000','style':'stroke:#000000; fill:none;'});
svg.appendChild(rect); svg.appendChild(rect);
document.getElementById("fightResult").appendChild(svg); document.getElementById("fightResult").appendChild(svg);
var plogs = createElem("p",{'id':'logs'});
document.getElementById("fightResult").appendChild(plogs);
//get bot list //get bot list
var botsList=[]; var botsList=[];
var i=0; var i=0;