integration des eventuels fichiers javascript des arenes

This commit is contained in:
Gnieark 2015-11-28 14:41:29 +01:00
parent 298a612287
commit 6d9d07875e
3 changed files with 50 additions and 1 deletions

View File

@ -77,6 +77,15 @@ if($currentArena == ""){
<style type="text/css"> <style type="text/css">
@import url(/style.css); @import url(/style.css);
</style> </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> </head>
<body> <body>

View File

@ -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');
}

View File

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