diff --git a/src/arenas/tron/js.js b/src/arenas/tron/js.js index d41a3a6..00142cf 100644 --- a/src/arenas/tron/js.js +++ b/src/arenas/tron/js.js @@ -5,13 +5,25 @@ function createElem(type,attributes){ return elem; } function createElemNS(type,attributes){ + //same as createElem but with ns for svg file var elem=document.createElementNS("http://www.w3.org/2000/svg",type); for (var i in attributes) {elem.setAttributeNS(null,i,attributes[i]);} return elem; } +function applyInitMessage(){ + if(request.readyState == 4){ + if(request.status == 200) { + alert ("ok"); + }else{ + alert ('error ' + xhr.status); + document.getElementById('fightButton').disabled=false; + return; + } + } +} function tron(bot1,bot2,xdcheck){ //empty while (document.getElementById('fightResult').firstChild) { @@ -23,4 +35,15 @@ function tron(bot1,bot2,xdcheck){ svg.appendChild(rect); document.getElementById("fightResult").appendChild(svg); + + //ask arena to send bots init messages + var request = new XMLHttpRequest(); + request.onreadystatechange = applyInitMessage; + request.open("POST", '/tron', true); + request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + request.send('act=initGame&bot1=' + bot1 + '&bot2=' + bot2 + '&xd_check=' + xd_check + '&fullLogs=' + document.getElementById("fullLogs").checked); + } + + + }