integration des eventuels fichiers javascript des arenes

pull/4/head
Gnieark 9 years ago
parent 298a612287
commit 6d9d07875e

@ -77,6 +77,15 @@ if($currentArena == ""){
<style type="text/css">
@import url(/style.css);
</style>
<?php
//script js de l'arene
if(isset($currentArenaArr['jsFile'])){
echo '<script type="text/javascript"><!--';
echo file_get_contents("../src/arenas/".$currentArena."/".$currentArenaArr['jsFile']);
echo '--></script>';
}
?>
</head>
<body>

@ -0,0 +1,39 @@
function Ajx(){
var request = false;
try {request = new ActiveXObject('Msxml2.XMLHTTP');}
catch (err2) {
try {request = new ActiveXObject('Microsoft.XMLHTTP');}
catch (err3) {
try { request = new XMLHttpRequest();}
catch (err1) {
request = false;
}
}
}
return request;
}
function tictactoe(bot1,bot2,xd_check){
document.getElementById('fightResult').innerHTML = '<p>Please wait...</p>';
var xhr = Ajx();
xhr.onreadystatechange = function(){if(xhr.readyState == 4){
if(xhr.status == 200) {
document.getElementById('fightResult').innerHTML = xhr.responseText;
}
}};
xhr.open("POST", 'index.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send('act=fight&bot1=' + bot1 + '&bot2=' + bot2 + '&xd_check=' + ,xd_check);
}
function refreshBots(){
var xhr = Ajx();
xhr.onreadystatechange = function(){if(xhr.readyState == 4){
if(xhr.status == 200) {
window.location.reload();
}
}};
xhr.open("POST", 'index.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send('act=reDownloadBotsList');
}

@ -3,7 +3,8 @@ $arenas=array(
array(
'id' => "tictactoe",
'url' => "/tictactoe",
'title' => "Tic Tac Toe"
'title' => "Tic Tac Toe",
'jsFile'=> "js.js"
),
array(
'id' => "Battleship",

Loading…
Cancel
Save