From 6d9d07875ec06bf235757311c8bc0ea2b9190781 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Sat, 28 Nov 2015 14:41:29 +0100 Subject: [PATCH] integration des eventuels fichiers javascript des arenes --- html/index.php | 9 +++++++++ src/arenas/tictactoe/js.js | 39 ++++++++++++++++++++++++++++++++++++++ src/arenas_lists.php | 3 ++- 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/arenas/tictactoe/js.js diff --git a/html/index.php b/html/index.php index fabc222..ebb19b9 100644 --- a/html/index.php +++ b/html/index.php @@ -77,6 +77,15 @@ if($currentArena == ""){ + '; + } + ?> + diff --git a/src/arenas/tictactoe/js.js b/src/arenas/tictactoe/js.js new file mode 100644 index 0000000..6ff0855 --- /dev/null +++ b/src/arenas/tictactoe/js.js @@ -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 = '

Please wait...

'; + 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'); + } + \ No newline at end of file diff --git a/src/arenas_lists.php b/src/arenas_lists.php index 99a99df..32235cd 100644 --- a/src/arenas_lists.php +++ b/src/arenas_lists.php @@ -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",