affichage grilles
This commit is contained in:
parent
fba016b651
commit
00f4db1653
|
@ -12,8 +12,38 @@ function Ajx(){
|
|||
}
|
||||
return request;
|
||||
}
|
||||
function battleship(bot1,bot2,xd_check){
|
||||
document.getElementById('fightResult').innerHTML = '<p>Please wait...</p>';
|
||||
function createElem(type,attributes)
|
||||
{
|
||||
var elem=document.createElement(type);
|
||||
for (var i in attributes)
|
||||
{elem.setAttribute(i,attributes[i]);}
|
||||
return elem;
|
||||
}
|
||||
|
||||
function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShip4,nbShip5,nbShip6,xd_check){
|
||||
|
||||
document.getElementById('fightResult').innerHTML = '';
|
||||
//dessiner les deux grilles
|
||||
tableAdv=createElem("table",{"id":"tblAdv","className":"battleshipGrid");
|
||||
tableMe=createElem("table",{"id":"tblAdv","className":"battleshipGrid");
|
||||
|
||||
for (i=0; i < gridHeight ; i++){
|
||||
trAdv=createElem("tr");
|
||||
trMe=createElem("tr");
|
||||
for (j=0; j < gridwidth ; i++){
|
||||
tdAdv=createElem("td",{"id":"adv" + i +"-" + j,"className": "empty");
|
||||
tdMe=createElem("td",{"id":"me" + i +"-" + j,"className": "empty");
|
||||
trAdv.appendChild(tdAdv);
|
||||
trMe.appendChild(tdMe);
|
||||
}
|
||||
tableAdv.appendChild(trAdv);
|
||||
tableMe.appendChild(trMe);
|
||||
}
|
||||
document.getElementById('fightResult').appendChild(tableAdv);
|
||||
document.getElementById('fightResult').appendChild(tableMe);
|
||||
|
||||
/*
|
||||
|
||||
var xhr = Ajx();
|
||||
xhr.onreadystatechange = function(){if(xhr.readyState == 4){
|
||||
if(xhr.status == 200) {
|
||||
|
@ -23,4 +53,5 @@ function battleship(bot1,bot2,xd_check){
|
|||
xhr.open("POST", '/Battleship', true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.send('act=fight&bot1=' + bot1 + '&bot2=' + bot2 + '&xd_check=' + xd_check);
|
||||
*/
|
||||
}
|
|
@ -48,6 +48,7 @@ if(!$postParams){
|
|||
?>
|
||||
</select></em>
|
||||
</p>
|
||||
<p><label> </label><input type="button" value="<?php echo $lang['FIGHT']; ?>" onclick="battleship(document.getElementById('bot1').value,document.getElementById('bot2').value,'<?php echo xd_check_input(2); ?>');"></p>
|
||||
<!-- battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShip4,nbShip5,nbShip6,xd_check) -->
|
||||
<p><label> </label><input type="button" value="<?php echo $lang['FIGHT']; ?>" onclick="battleship(document.getElementById('bot1').value,document.getElementById('bot2').value,getElementById('width').value,getElementById('height').value,getElementById('ship1').value,getElementById('ship2').value,getElementById('ship3').value,getElementById('ship4').value,getElementById('ship5').value,getElementById('ship6').value,'<?php echo xd_check_input(2); ?>');"></p>
|
||||
<div id="fightResult"></div>
|
||||
</article>
|
|
@ -1,3 +1,3 @@
|
|||
article p {width: 100%;}
|
||||
article p label {float:left; text-align:right; width:70%}
|
||||
article p label {float:left; text-align:right; width:60%}
|
||||
article p select {}
|
Loading…
Reference in New Issue
Block a user