Problème de boutons.
Résolu
Max747
Messages postés
258
Date d'inscription
Statut
Membre
Dernière intervention
-
jordane45 Messages postés 38486 Date d'inscription Statut Modérateur Dernière intervention -
jordane45 Messages postés 38486 Date d'inscription Statut Modérateur Dernière intervention -
Bonjour,
Ayant construit un site de jeu d'échec, j'ai remarqué qu'il y a 3 boutons qui ne fonctionnent pas.
Ce sont les boutons situés en ligne 394 à 396 comme indiqué dans le fichier chess.php ci dessous:
Les identifiants concernant ces 3 boutons se trouvent dans le fichier commands.js ci dessous en lignes 7,8 et 9.
Ne connaissant aucunement le JavaScript, pouvez vous m' aider à résoudre ce problème de boutons?
Merci.
Ayant construit un site de jeu d'échec, j'ai remarqué qu'il y a 3 boutons qui ne fonctionnent pas.
Ce sont les boutons situés en ligne 394 à 396 comme indiqué dans le fichier chess.php ci dessous:
// set the session cookie parameters so the cookie is only valid for this game $parts = pathinfo($_SERVER['REQUEST_URI']); $path = $parts['dirname']; if (empty($parts['extension'])) { $path .= '/'.$parts['jeuxechecs_fr']; } $path = str_replace('\\', '/', $path).'/'; session_set_cookie_params(time()+365*24*3600, $path); session_start( ); //print_r($_COOKIE); // load 'always needed' settings require_once './includes/config.inc.php'; require_once './includes/html.inc.php'; // include outside functions require_once './includes/chessconstants.inc.php'; require_once './includes/chessutils.inc.php'; require_once './includes/gui.inc.php'; require_once './includes/chessdb.inc.php'; //****************************************************************************** // load basic information //****************************************************************************** // check if loading game if (isset($_POST['game_id'])) { $_SESSION['game_id'] = (int) $_POST['game_id']; } // make sure we have game id data if (empty($_SESSION['game_id'])) { header('Location: index.php'); exit; } if (isset($_SESSION['game_id']) || ! isset($_SESSION['white'])) { // get White's data $query = " SELECT p_id , p_username , p_email FROM ".T_PLAYER." , ".T_GAME." WHERE ".T_PLAYER.".p_id = ".T_GAME.".g_white_player_id AND ".T_GAME.".g_id = '{$_SESSION['game_id']}' "; $_SESSION['white'] = $mysql->fetch_assoc($query, __LINE__, __FILE__); // get Black's data $query = " SELECT p_id , p_username , p_email FROM ".T_PLAYER." , ".T_GAME." WHERE ".T_PLAYER.".p_id = ".T_GAME.".g_black_player_id AND ".T_GAME.".g_id = '{$_SESSION['game_id']}' "; $_SESSION['black'] = $mysql->fetch_assoc($query, __LINE__, __FILE__); // get players' color if ($_SESSION['white']['p_username'] == $_SESSION['username']) { $_SESSION['player'] = &$_SESSION['white']; $_SESSION['player']['p_color'] = 'white'; $_SESSION['opponent'] = &$_SESSION['black']; $_SESSION['opponent']['p_color'] = 'black'; } else { $_SESSION['player'] = &$_SESSION['black']; $_SESSION['player']['p_color'] = 'black'; $_SESSION['opponent'] = &$_SESSION['white']; $_SESSION['opponent']['p_color'] = 'white'; } // get id960 and position $query = " SELECT g_id960 FROM ".T_GAME." WHERE g_id = '{$_SESSION['game_id']}' "; $_SESSION['id960'] = $mysql->fetch_value($query, __LINE__, __FILE__); } $initpos = id960_to_pos($_SESSION['id960']); $promoting = false; // init the promotion flag $undoing = false; // init the undo flag // get FEN array (this should probably be in an include somewhere) $i = 0; $query = " SELECT h_fen FROM ".T_HISTORY." WHERE h_game_id = '{$_SESSION['game_id']}' ORDER BY h_time "; $FENarray = $mysql->fetch_value_array($query, __LINE__, __FILE__); $num_moves = count($FENarray) - 1; // remove one for initpos loadGame( ); // sets up board using last entry in ".T_HISTORY." table (chessdb.inc.php) FENtomoves( ); // creates movesArray from FENarray (chessutils.inc.php) // find out if it's the current player's turn $FENitems = explode(' ',$FENarray[$num_moves]); $curTurn = $colorArray[$FENitems[1]]; // convert w -> white, b -> black $isPlayersTurn = ($curTurn == $_SESSION['player']['p_color']) ? true : false; //*/ //****************************************************************************** // save incoming information //****************************************************************************** checkDatabase( ); // check the database data against the current FEN to make sure the game is ended properly (chessdb.inc.php) processMessages( ); // processes the messages (undo, resign, etc) (chessdb.inc.php) // are we undoing ? if ($undoing && 0 < $num_moves) { call("UNDO REQUEST"); // just remove the last FEN entered into the history table $query = " SELECT MAX(h_time) FROM ".T_HISTORY." WHERE h_game_id = '{$_SESSION['game_id']}' "; $max_time = $mysql->fetch_value($query, __LINE__, __FILE__); $query = " DELETE FROM ".T_HISTORY." WHERE h_game_id = '{$_SESSION['game_id']}' AND h_time = '{$max_time}' LIMIT 1 "; $mysql->query($query, __LINE__, __FILE__); if (!DEBUG) header("Location: ./chess.php"); } // or saving the promotion elseif ( isset($_POST['promotion']) && '' != $_POST['promotion'] && false != $_POST['promoting'] ) { call("SAVING PROMOTION"); savePromotion( ); // inserts promoted piece and saves to database (chessdb.inc.php) if (!DEBUG) header("Location: ./chess.php"); } // or making a move elseif ( ( isset($_POST['fromRow']) && '' != $_POST['fromRow'] && '' != $_POST['fromCol'] && '' != $_POST['toRow'] && '' != $_POST['toCol'] ) || ( isset($_POST['castleMove']) && 'false' != $_POST['castleMove'] ) ) { call("MAKING A MOVE"); call($_POST); call($_POST['fromRow']); /* ensure it's the current player moving */ /* NOTE: if not, this will currently ignore the command... */ /* perhaps the status should be instead? */ /* (Could be confusing to player if they double-click or something */ $is_valid = true; if ('white' == $curTurn) // white's move { call("WHITE"); call($board[$_POST['fromRow']][$_POST['fromCol']]); // ensure that piece being moved isn't black (and is a piece) if (('black' == $pieceColor[$board[$_POST['fromRow']][$_POST['fromCol']]]) || ('0' == $board[$_POST['fromRow']][$_POST['fromCol']])) $is_valid = false; // if test passes, piece was black } else // black' move { call("BLACK"); call($pieceColor[$board[$_POST['fromRow']][$_POST['fromCol']]]); // ensure that piece being moved isn't white (and is a piece) if (("white" == $pieceColor[$board[$_POST['fromRow']][$_POST['fromCol']]]) || ('0' == $board[$_POST['fromRow']][$_POST['fromCol']])) $is_valid = false; // if test passes, piece was white } if ($is_valid) { call("IS VALID"); saveGame( ); // (chessdb.inc.php) // reload a fresh page to avoid errors // and to display the new database data if (!DEBUG) header("Location: ./chess.php"); } } // or we need to select the promoting piece elseif ('P' == strtoupper($movesArray[$num_moves]['piece']) && ( ! isset($movesArray[$num_moves]['promo']) || null == $movesArray[$num_moves]['promo'])) { if($movesArray[$num_moves]['toRow'] == 7 || $movesArray[$num_moves]['toRow'] == 0) { $promoting = true; } } //*/ //****************************************************************************** // submit chat message //****************************************************************************** if (isset($_POST['txtChatbox']) && ('' != $_POST['txtChatbox'])) { $_POST = sani($_POST); $private = (isset($_POST['private']) && 'on' == $_POST['private']) ? 'Yes' : 'No'; // select the last post entered and make sure it is not a IE error duplicate message // (same message within 1 second) $query = " SELECT COUNT(*) FROM ".T_CHAT." WHERE c_message = '{$_POST['txtChatbox']}' AND c_time BETWEEN DATE_SUB(NOW( ), INTERVAL 1 SECOND) AND DATE_ADD(NOW( ), INTERVAL 1 SECOND) "; $count = $mysql->fetch_value($query, __LINE__, __FILE__); date_default_timezone_set('Europe/Paris'); $test = new DateTime(); $d= date_format($test, 'Y-m-d H:i:s'); if (0 == $count) { //$dat= date('d-m-Y-G-i',strtotime("+1 hours")); $query = " INSERT INTO ".T_CHAT." (c_game_id, c_player_id, c_time, c_message, c_private) VALUES ('{$_SESSION['game_id']}', '{$_SESSION['player_id']}', '{$d}', '{$_POST['txtChatbox']}', '{$private}') "; $mysql->query($query, __LINE__, __FILE__); } // refresh the page to avoid double posts if (!DEBUG) header('Location: chess.php'); } //*/ //****************************************************************************** // send wake up email //****************************************************************************** $wake_up_sent = false; if ( isset($_POST['wakeID']) && $_SESSION['game_id'] == $_POST['wakeID'] ) { call("webchessMail('wakeup',{$_SESSION['opponent']['p_email']},'',{$_SESSION['username']},{$_SESSION['game_id']})"); $wake_up_sent = webchessMail('wakeup',$_SESSION['opponent']['p_email'],'',$_SESSION['username'],$_SESSION['game_id']); } //*/ //****************************************************************************** // load game from database for display //****************************************************************************** // get FEN array $query = " SELECT h_fen FROM ".T_HISTORY." WHERE h_game_id = '{$_SESSION['game_id']}' ORDER BY h_time "; $FENarray = $mysql->fetch_value_array($query, __LINE__, __FILE__); $num_moves = count($FENarray) - 1; // remove one for initpos loadGame( ); // sets up board using last entry in ".T_HISTORY." table (chessdb.inc.php) // convert the current FEN array to an array of standard moves FENtomoves( ); // (chessutils.inc.php) // find out if it's the current player's turn $FENitems = explode(' ',$FENarray[$num_moves]); $curTurn = $colorArray[$FENitems[1]]; $isPlayersTurn = ($curTurn == $_SESSION['player']['p_color']) ? true : false; //*/ // set the display to show whos turn, or shared if ($_SESSION['shared']) { $turn = "Partagé"; } elseif ($isPlayersTurn) { $turn = "Votre coup"; } else { $turn = "Coup adverse"; } $head_extra = ' <script type="text/javascript">//<![CDATA[ var watchgame = false; function redo( ) { window.location.replace(\'chess.php\'); } '; // ouput confirmation for wake up email if ($wake_up_sent) { $head_extra .= "alert('Envoi Wake Up par e-mail effectué.');\n "; } elseif (isset($_POST['wakeID']) && ! $wake_up_sent) { $head_extra .= "alert('Envoi Wake Up par e-mail échoué !!');\n "; } // transfer game data to javacript vars $head_extra .= getJSFEN( ); // writes 'FEN' array, and 'result' (gui.inc.php) $head_extra .= getTurn( ); // writes 'isBoardDisabled', 'isPlayersTurn', and 'perspective' (gui.inc.php) $head_extra .= getMoves( ); // writes the 'moves' array (gui.inc.php) $head_extra .= getStatus( ); // writes 'whosMove', 'gameState', and 'statusMsg' (gui.inc.php) $head_extra .= "var DEBUG = ".JS_DEBUG.";\n "; $head_extra .= "var numMoves = FEN.length - 1;\n "; // if it's not the player's turn, enable auto-refresh $autoRefresh = ( ! $isPlayersTurn && ! isBoardDisabled( ) && ! $_SESSION['shared'] ); $head_extra .= "var autoreload = "; if ( ! $autoRefresh || (0 == $CFG_MINAUTORELOAD) ) { $head_extra .= "0"; } elseif ( $_SESSION['pref_auto_reload'] >= $CFG_MINAUTORELOAD ) { $head_extra .= $_SESSION['pref_auto_reload']; } else { $head_extra .= $CFG_MINAUTORELOAD; } $vs = get_medal($_SESSION['white']['p_username']).$_SESSION['white']['p_username']." - ".get_medal($_SESSION['black']['p_username']).$_SESSION['black']['p_username']; $head_extra .= "; var gameId = '{$_SESSION['game_id']}'; var players = '{$vs}'; var promoting = '{$promoting}'; var isGameOver = '{$isGameOver}'; var lastMoveIndicator = '{$_SESSION['pref_show_last_move']}'; var id960 = '{$_SESSION['id960']}'; var initpos = '{$initpos}'; var parties_gagnees = '{$_SESSION['wins']}'; "; $head_extra .= "var currentTheme = '"; $head_extra .= (isset($_SESSION['pref_theme']) ? $_SESSION['pref_theme'] : "Style A") . '\'; //]]> </script> <!-- the \'variables\' javascript must come first !! --> <script type="text/javascript" src="javascript/variables.js"></script> <script type="text/javascript" src="javascript/chessutils.js"></script> <script type="text/javascript" src="javascript/commands.js"></script> <script type="text/javascript" src="javascript/validation.js"></script> '; if ($isPlayersTurn || $_SESSION['shared'] || $promoting) { $head_extra .= "\n <script type=\"text/javascript\" src=\"javascript/isCheckMate.js\"></script>"; } if ( ! isBoardDisabled( ) || $_SESSION['shared']) { $head_extra .= "\n <script type=\"text/javascript\" src=\"javascript/squareclicked.js\"></script>"; } $head_extra .= '<script type="text/javascript" src="javascript/board.js"></script> <script type="text/javascript" src="javascript/highlight.js"></script> '; echo get_header(null, $turn, $head_extra) ?> <div id='centrer_jeu'> <div id="centrer_menu_partie"> <a href="index.php"> <input type="button" class="button" value="Page d' accueil"/> <input type="button" id="btnUndo" class="button" value="Demande à rejouer" disabled="disabled" /> <input type="button" id="btnDraw" class="button" value="Demande la nulle" disabled="disabled" /> <input type="button" id="btnResign" class="button" value="Abandonner" disabled="disabled" /> </a> <br/><br/> </div> <div id="history"> <?php // case avec dernier coup : ?> <span style='display:none;' id="curmove"> </span> <h2 id="players"></h2> <h2 id="gameid"></h2> <div id="gamebody"></div> </div> <div id="board"> <div id="checkmsg"></div> <div id="statusmsg"></div> <br> <div id="gamebuttons"> <span id="castle">Pour roquer : cliquez sur le roi, et ensuite sur la tour du côté du roque. <a href="#" class="help" onclick="window.open('./help/c960castling.html','help','resizable,scrollbars,width=550,height=500,top=50,left=50','_blank');return false;">?</a></span> </div> <h3>Pièces capturées:</h3> <div id="captheading"></div> <div id="captures"></div> <br> <div id="date"> <?php /*timezone(); setlocale(LC_TIME,'fr_FR'); echo 'Nous sommes '.strftime("%A %d %B %Y").'. '; echo ' Il est: '.strftime("%Hh %M").'<br/>';*/ ?> </div> <form name="gamedata" method="post" action="chess.php"> <div id="chessboard"></div> <?php if ($promoting && ( ! $isPlayersTurn || $_SESSION['shared'])) // Write promotion dialog only to the correct player { echo getPromotion( ); } if ($isUndoRequested) { echo getUndoRequest( ); } if ($isDrawRequested) { echo getDrawRequest( ); } ?> <input type="hidden" name="requestUndo" value="no" /> <input type="hidden" name="requestDraw" value="no" /> <input type="hidden" name="resign" value="no" /> <input type="hidden" name="fromRow" value="" /> <input type="hidden" name="fromCol" value="" /> <input type="hidden" name="toRow" value="" /> <input type="hidden" name="toCol" value="<?php if ($promoting) echo $movesArray[$num_moves]['toCol']; ?>" /> <input type="hidden" name="castleMove" value="false" /> <input type="hidden" name="promoting" value="<?php echo ($promoting ? 'true' : 'false'); ?>" /> </form> <div id="gamenav"></div> <form name="gamemenu" id="gamemenu" method="post" action="chess.php" style="display:inline;"> <input type="button" id="btnReload" value="Recharger" disabled="disabled" /> <input type="button" id="btnReplay" value="Revoir partie" disabled="disabled" /> <input type="button" id="btnPGN" value="PGN" disabled="disabled" /> </form> <form name="wakeup" id="wakeup" method="post" action="chess.php" style="display:inline;"> <?php // test for opponents email, and if none, disable the wake up button $temp = ('' == $_SESSION['opponent']['p_email']) ? ' disabled="disabled"' : ''; // check the var and disable if no email is found ?> <input type="button" id="btnWakeUp" value="Rappel" onclick="wakeUp( );"<?php echo $temp; ?> /> <input type="hidden" name="wakeID" value="<?php echo $_SESSION['game_id']; ?>" /><a href="#" class="help" onclick="window.open('./help/wakeup.html','help','resizable,scrollbars,width=550,height=500,top=50,left=50','_blank');return false;">?</a> </form> </div> <?php // collect the public chat messages $query = " SELECT distinct c_message , c_private , p_username ,DAY(c_time) AS jour, MONTH(c_time) AS mois, Year(c_time) AS annee, HOUR(c_time) AS heure, MINUTE(c_time) AS minute FROM ".T_CHAT." LEFT JOIN ".T_PLAYER." ON ".T_CHAT.".c_player_id = ".T_PLAYER.".p_id WHERE c_game_id = '{$_SESSION['game_id']}' AND ( (c_private = 'No') "; // include private message data if game is not shared if ('1' != $_SESSION['shared']) { $query .= " OR (c_private='Yes' AND ".T_CHAT.".c_player_id = '{$_SESSION['player_id']}') "; } $query .= " ) ORDER BY c_time DESC "; $result = $mysql->fetch_array($query, __LINE__, __FILE__); $i = 0; // on n'affiche pas le tableau si on a pas de résultats .. $nb_res = count($result); if($nb_res > 0){ ?> <div id="chat"> <h2><center>Chat<center></h2> <div id="date"> <?php setlocale(LC_TIME,'fr_FR'); //$a=strftime("%A %d %B %Y"); //echo htmlentities($a); //$y='Nous sommes le '.strftime("%A %d %B %Y").'. '; echo 'Nous sommes le '.strftime("%A %d %B %Y").'. '; //echo $y; echo ' Il est: '.strftime("%Hh %M").'<br/>'; ?></div> <div class="info"></div> <div id="chatholder"> <table class="chat" style='table-layout: fixed;'> <col /> <col class="message" /> <tr> <th style='width:90px' >Joueurs</th> <th >Messages</th> </tr> <?php }else{ ?> <div id="chat"> <h2>chat</h2> <div class="info"></div> <div id="chatholder"> <table class="chat"> <col /> <col class="message" /> <tr> <th>Aucun message</th> </tr> <?php } foreach ($result as $chat) { $alt = ' class="'; $alt .= (0 == $i % 2) ? ' alt' : ''; $alt .= ('Yes' == $chat['c_private']) ? ' mine' : ''; $alt .= ( $_SESSION['username'] != $chat['p_username'] ) ? ' opp' : ''; $alt .= '"'; $mois=array("","/ 01 /","/ 02 /","/ 03 /","/ 04 /","/ 05 /","/ 06 /","/ 07 /","/ 08 /","/ 09 /","/ 10 /","/ 11 /","/ 12 /"); //$mois=array("","janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"); $chat['c_message']=nl2br($chat['c_message']); if($chat['minute'] < 10 ){$chat['minute'] = "0".$chat['minute'];} echo " <tr{$alt}> <td class=\"player\">{$chat['p_username']}:<br/> {$chat['jour']} {$mois[$chat['mois']]} {$chat['annee']}<br/> {$chat['heure']}:{$chat['minute']}</td> <td style = 'hyphens: auto;word-wrap: break-word;'> {$chat['c_message']}</td> </tr>"; $i++; } ?> </table> </div> <br> <br> <form action="chess.php" method="post" name="chatdata" style="display:inline;"> <textarea style="width:339px;max-width:373px;max-height:90px;" name="txtChatbox" tabindex="2" cols="39" rows="4" onfocus="clearTimeout(intervalId);" onblur="if(''==this.value){intervalId = setTimeout('redo( )', autoreload * 1000);}" tabindex="2" placeholder="Ecrivez vos commentaires ici..."></textarea> <br> <!--<label for="private"><input type="checkbox" id="private" name="private" tabindex="1" />Privé</label> --> <input type="submit" id="btnSubmit" name="chat" tabindex="3" value="Envoi" /> </form> </div> </div> </div> <div id="footerspacer"> </div> <?php // NE PAS ENLEVER FENBLOCK : sinon on ne peu plus revoir les coups précédents ?> <div id="FENblock"></div> <?php call($GLOBALS);?> </body> </html> <!-- </table> </div> <br> <br> <form action="chess.php" method="post" name="chatdata" style="display:inline;"> <textarea style="width:339px;max-width:373px;max-height:60px;" name="txtChatbox" tabindex="2" cols="39" rows="4" onfocus="clearTimeout(intervalId);" onblur="if(''==this.value){intervalId = setTimeout('redo( )', autoreload * 1000);}"></textarea> <br> <label for="private"><input type="checkbox" id="private" name="private" tabindex="1" />Privé</label> <input type="submit" id="btnSubmit" name="chat" tabindex="3" value="Envoi" /> </form> </div> </div> </div> <div id="footerspacer_jeu"> </div> <?php call($GLOBALS);?>
Les identifiants concernant ces 3 boutons se trouvent dans le fichier commands.js ci dessous en lignes 7,8 et 9.
// these functions interact with the server function disableButtons( ) { if ( ! watchgame) { getObject("btnUndo").disabled = true; getObject("btnDraw").disabled = true; getObject("btnResign").disabled = true; //document.querySelector('btnUndo').disabled = true; //document.querySelector('btnDraw').disabled = true; //document.querySelector('btnResign').disabled = true; } } function undo( ) { disableButtons( ); document.gamedata.requestUndo.value = "yes"; my_alert("gamedata.requestUndo = " + document.gamedata.requestUndo.value); document.gamedata.submit( ); } function draw( ) { disableButtons( ); document.gamedata.requestDraw.value = "yes"; my_alert("gamedata.requestDraw = " + document.gamedata.requestDraw.value); document.gamedata.submit( ); } function resigngame( ) { disableButtons( ); document.gamedata.resign.value = "yes"; my_alert("gamedata.resign = " + document.gamedata.resign.value); document.gamedata.submit( ); } function displayMainmenu( ) { this.disabled = true; disableButtons( ); window.open('index.php', '_self'); } function reloadPage(btnReload) { btnReload.disabled = true; disableButtons( ); window.open('chess.php', '_self'); } function downloadPGN( ) { window.open('./includes/openpgn.inc.php', '_self') } function replay( ) { if (document.gamemenu.btnReplay.value == "Revoir partie") { document.gamemenu.btnReplay.value = "Continue"; // pause the refresh timer clearTimeout(intervalId); // disable the board isBoardDisabled = true; // run the replay scripts var replayBoard = htmlBoard( ); getObject('chessboard').innerHTML = replayBoard; // reset the moves with movable ones displayMoves(true); // get the FEN array currMoveIdx = FEN.length - 1; // display the captured pieces FENToCapt(numMoves); displayCaptPieces( ); // make the replay buttons and hide game buttons getObject('gamebuttons').style.display = 'none'; var navButtons = '<form id="navigation" action="">'; navButtons += '<span id="navbuttons">'; navButtons += '<input id="start" title="Début" type="button" value="Début" />'; navButtons += '<input id="jmpback" title="5 demi-coups avant" type="button" value=" << " />'; navButtons += '<input id="prev" title="1 demi-coup avant" type="button" value=" < " />'; navButtons += '<input id="next" title="1 demi-coup après" type="button" value=" > " />'; navButtons += '<input id="jmpfwd" title="5 demi-coups après" type="button" value=" >> " />'; navButtons += '<input id="end" title="Fin" type="button" value="Fin" /><br>'; navButtons += '<input style="width:100px" id="invert" title="Inverser" type="button" value="< Tourner" />'; navButtons += '<input style="width:100px" id="invert2" title="Inverser" type="button" value="Tourner >" disabled />'; navButtons += '</span>'; navButtons += '</form>'; getObject('gamenav').innerHTML = navButtons; function invert1(){ /*toggleInvert( )*/ document.getElementById("invert").disabled = true; document.getElementById("invert2").disabled = false; document.getElementById("theBoard").style.transform = "rotate(180deg)"; document.getElementById("theBoard").style.transition = ".3s"; for (var i=0; i < 64; i++) { var element = document.getElementById("sq"+i); if (typeof(element) != 'undefined' && element != null) { document.getElementById("sq"+i).style.transform = "rotate(180deg)"; } } }; function invert2(){ /*toggleInvert( )*/ document.getElementById("invert2").disabled = true; document.getElementById("invert").disabled = false; document.getElementById("theBoard").style.transform = "rotate(0deg)"; document.getElementById("theBoard").style.transition = ".3s"; for (var i=0; i < 64; i++) { var element = document.getElementById("sq"+i); if (typeof(element) != 'undefined' && element != null) { document.getElementById("sq"+i).style.transform = "rotate(0deg)"; //document.getElementById("theBoard").style.transition = ".3s"; } } //document.getElementById("invert").style.display = "block"; //document.getElementById("invert2").style.display = "none"; }; // set the replay button actions - définir les actions du bouton de relecture getObject("start").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(-10000);invert1();}else{moveJmp(-10000)} ;}; getObject("jmpback").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(-5);invert1();}else{moveJmp(-5)};}; getObject("prev").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(-1);invert1();}else{moveJmp(-1)};}; getObject("next").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(1);invert1();}else{moveJmp(1)};}; getObject("jmpfwd").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(5);invert1();}else{moveJmp(5)};}; getObject("end").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(10000);invert1();}else{moveJmp(10000)};}; getObject("invert").onclick = function( ){invert1()}; getObject("invert2").onclick = function( ){invert2()}; //document.querySelector('start').onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(-10000);invert1();}else{moveJmp(-10000)} ;}; //document.querySelector('jmpback').onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(-5);invert1();}else{moveJmp(-5)};}; //document.querySelector('prev').onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(-1);invert1();}else{moveJmp(-1)};}; //document.querySelector('next').onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(1);invert1();}else{moveJmp(1)};}; //document.querySelector('jmpfwd').onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(5);invert1();}else{moveJmp(5)};}; //document.querySelector('end').onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(10000);invert1();}else{moveJmp(10000)};}; //document.querySelector('invert').onclick = function( ){invert1()}; //document.querySelector('invert2').onclick = function( ){invert2()}; } else if (document.gamemenu.btnReplay.value == "Continue") { // just refresh the page, everything resets itself window.location.replace('chess.php'); } } function wakeUp( ) { if (confirm('Confirmez le mail de rappel.')) { document.wakeup.submit( ); } } function promotepawn( ) { var blackPawnFound = false; var whitePawnFound = false; var i = -1; // search for the promoting pawn while ( ! blackPawnFound && ! whitePawnFound && i < 8) { i++; /* check for black pawn being promoted */ if (board[0][i] == (BLACK | PAWN)) blackPawnFound = true; /* check for white pawn being promoted */ if (board[7][i] == (WHITE | PAWN)) whitePawnFound = true; } /* to which piece is the pawn being promoted to? */ var promotedTo = 0; for (var j = 0; j <= 3; j++) { if (document.gamedata.promotion[j].checked) promotedTo = parseInt(document.gamedata.promotion[j].value); } /* change pawn to promoted piece */ var enemyColor = "black"; if (blackPawnFound) { enemyColor = "white"; board[0][i] = (BLACK | promotedTo); my_alert("Promotion pour: (noirs) " + board[0][i]); } else if (whitePawnFound) { board[7][i] = (WHITE | promotedTo); my_alert("Promotion pour: (blancs) " + board[7][i]); } else { alert("ATTENTION ! : Le site ne trouve pas le pion à promouvoir"); } /* update board and database */ document.gamedata.submit( ); }
Ne connaissant aucunement le JavaScript, pouvez vous m' aider à résoudre ce problème de boutons?
Merci.
A voir également:
- Problème de boutons.
- A quoi servent les boutons de couleur sur une telecommande - Guide
- Comment réinitialiser un téléphone avec les boutons - Guide
- Application pour reconnaître les boutons - Accueil - Outils
- Comment déverrouiller un samsung avec les boutons - Guide
- Pas de bouton acheter sur le bon coin ✓ - Forum Consommation & Internet
5 réponses
Bonjour,
A quelle endroit as tu assigné des actions à ces boutons ?
As tu vérifié qu'il n'y a avait pas d'erreur dans la console du navigateur ?
Tu postes dans le forum PHP .... mais ta question concerne le javascript non ??
Tu dis avoir construit le site... mais que tu ne connais rien au javascript... ce n'est pas toi qui a codé le script que tu nous montres ?
A quelle endroit as tu assigné des actions à ces boutons ?
As tu vérifié qu'il n'y a avait pas d'erreur dans la console du navigateur ?
Tu postes dans le forum PHP .... mais ta question concerne le javascript non ??
Tu dis avoir construit le site... mais que tu ne connais rien au javascript... ce n'est pas toi qui a codé le script que tu nous montres ?
A quelle endroit as tu assigné des actions à ces boutons ?
Dans le fichier commands.js en ligne 7,8 et 9.
Voici l'image de la console:

Tu postes dans le forum PHP .... mais ta question concerne le javascript non ??
Je ne connais pas suffisament le JS pour aller poster dans les sujets s'y rapportant.
Tu dis avoir construit le site... mais que tu ne connais rien au javascript... ce n'est pas toi qui a codé le script que tu nous montres ?
Je n'ai pas tout codé en effet.J'y ai simplement apporté ma touche personnelle comme j'essaie de le faire avec les 3 boutons qui ne fonctionnent pas.
Dans le fichier commands.js en ligne 7,8 et 9.
Voici l'image de la console:

Tu postes dans le forum PHP .... mais ta question concerne le javascript non ??
Je ne connais pas suffisament le JS pour aller poster dans les sujets s'y rapportant.
Tu dis avoir construit le site... mais que tu ne connais rien au javascript... ce n'est pas toi qui a codé le script que tu nous montres ?
Je n'ai pas tout codé en effet.J'y ai simplement apporté ma touche personnelle comme j'essaie de le faire avec les 3 boutons qui ne fonctionnent pas.
Si , en parlant des lignes 7,8,9 tu veux dire
Non... ça n'assigne aucune action à tes boutons.......
il faut chercher un addEventListener dans le Javascript ou un ONCLICK dans le HTML ...
L'image de la console que tu nous montres... n'est pas sur l'onglet CONSOLE ... et donc ne nous sert à rien.
Même si tu ne connais rien au Javascript... le souci portant sur ce langage, il aurait fallu poster dans le bon forum.
Je déplace le sujet. Merci d'y penser la prochaine fois.
getObject("btnUndo").disabled = true; getObject("btnDraw").disabled = true; getObject("btnResign").disabled = true;
Non... ça n'assigne aucune action à tes boutons.......
il faut chercher un addEventListener dans le Javascript ou un ONCLICK dans le HTML ...
L'image de la console que tu nous montres... n'est pas sur l'onglet CONSOLE ... et donc ne nous sert à rien.
Même si tu ne connais rien au Javascript... le souci portant sur ce langage, il aurait fallu poster dans le bon forum.
Je déplace le sujet. Merci d'y penser la prochaine fois.
Voici la partie utile (à mon avis) concernant addEventListener qui se trouve dans un fichier nommé sortabletable.js
ONCLICK dans le fichier board.js aux lignes:
575, 576,
594,
639, 640,
645, 645, 646, 647,
710 à 717 et 727.
ONCLICK dans le fichier commands.js ci dessus aux lignes:
145 à 152
ONCLICK dans le fichier sortabletable.js ci dessus aux lignes:
65
88
176
223
411
Et l'image de l'onglet console:
// adds arrow containers and events // also binds sort type to the header cells so that reordering columns does // not break the sort types SortableTable.prototype.initHeader = function (oSortTypes) { if (!this.tHead) return; var cells = this.tHead.rows[0].cells; var doc = this.tHead.ownerDocument || this.tHead.document; this.sortTypes = oSortTypes || []; var l = cells.length; var img, c; for (var i = 0; i < l; i++) { c = cells[i]; if (this.sortTypes[i] != null && this.sortTypes[i] != "None") { // img = doc.createElement("IMG"); // img.src = "images/blank.png"; // c.appendChild(img); if (this.sortTypes[i] != null) c._sortType = this.sortTypes[i]; if (typeof c.addEventListener != "undefined") c.addEventListener("click", this._headerOnclick, false); else if (typeof c.attachEvent != "undefined") c.attachEvent("onclick", this._headerOnclick); else c.onclick = this._headerOnclick; } else { c.setAttribute( "_sortType", oSortTypes[i] ); c._sortType = "None"; } } // this.updateHeaderArrows(); };
ONCLICK dans le fichier board.js aux lignes:
575, 576,
594,
639, 640,
645, 645, 646, 647,
710 à 717 et 727.
function getObject(obj) { if (document.getElementById) { // Mozilla, FireFox, Explorer 5+, Opera 5+, Konqueror, Safari, iCab, Ice, OmniWeb 4.5 if (typeof obj == "string") { if (document.getElementById(obj)) { return document.getElementById(obj); } else { return document.getElementsByName(obj)[0]; } } else { return obj.style; } } if (document.all) { // Explorer 4+, Opera 6+, iCab, Ice, Omniweb 4.2- if (typeof obj == "string") { return document.all(obj); } else { return obj.style; } } if (document.layers) { // Netscape 4, Ice, Escape, Omniweb 4.2- if (typeof obj == "string") { return document.layers(obj); } else { return obj.style; } } alert('Objet non trouvé : ' + obj); return false; } function isGameDrawn( ) { var i,j; // Stalemate? // is all this needed, it is generated in php, so... if (gameState == 'stalemate') { var myColor = WHITE; if (0 <= numMoves && 'b' == FEN[FEN.length - 1].split(' ')[1]) { myColor = BLACK; } if (0 == countMoves(myColor)) { alert('Nulle (pat)\nVous devriez offrir la nulle à votre adversaire.'); } return "stalemate"; } // Is the game drawn due to insufficient material to checkmate? var count = 0; var canCheckmate = false; for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { if (board[i][j] != 0 && (board[i][j] & COLOR_MASK) != KING) { if ((board[i][j] & COLOR_MASK) != KNIGHT && (board[i][j] & COLOR_MASK) != BISHOP) canCheckmate = true; else count++; } } } if (count < 2 && ! canCheckmate) { alert('Nulle (materiel insuffisant pour mater)\nVous devriez offrir la nulle à votre adversaire.'); return "material"; } // Is the game drawn because this is the third time that the exact same position arises? if (numMoves >= 0 && isThirdTimePosDraw(FEN)) { alert('Nulle (cette position a été rencontrée trois fois)\nVous devriez offrir la nulle à votre adversaire.'); return "3"; } // Draw because of no capture or pawn move for the last 50 moves? if (numMoves >= 0 && isFiftyMoveDraw(FEN[FEN.length-1])) { alert('Nulle (règle des 50 coups)\nVous devriez offrir la nulle à votre adversaire.'); return "50"; } return false; } function displayCaptPieces( ) { var i,j; var color = 'white'; var html = '<div>'; var piece = ''; var item; for(i = 0; i < captPieces.length; i++) { for(j = 0; j < captPieces[i].length; j++) { piece = color + '_' + captPieces[i][j]; html += '<img src="images/' + currentTheme + '/' + piece + '.' + ((-1 !== currentTheme.indexOf('gnuchess')) ? 'png' : 'gif') + '" width="'; html += parseInt(50 * 3 / 5) + '" height="' + parseInt(50 * 3 / 5) + '" alt="' + piece + '" />'; } html += "</div>\n<div>"; color = 'black'; } html += '</div>'; getObject('captures').innerHTML = html; } if (0 < numMoves) { // if we have not made a move yet, don't get the previous move var prevMove = new previousMove( ); // the previous move info as object } var takenPiece = 0; // the captured piece img in the captures section var captEnPass = 0; // the square the en passant captured pawn was on function unhighlightCurMove( ) { unhighlight(getObject('tsq' + prevMove.fromSq)); unhighlight(getObject('tsq' + prevMove.toSq)); if (takenPiece) // if we have a captured piece highlighted { unhighlight(takenPiece); // unhighlight it takenPiece = 0; // and erase the var so we don't keep highlighting it } if (captEnPass) // if we have an en passant capture { unhighlight(captEnPass); // unhighlight it captEnPass = 0; // and erase the var so we don't keep highlighting it } } function highlightCurMove( ) { var item; // check for en passant move if (undefined != prevMove.captSq && prevMove.captSq != prevMove.toSq) { captEnPass = getObject('tsq' + prevMove.captSq); } if (prevMove.captPiece) { if ('w' == pieceColor[prevMove.captPiece]) { item = 'white_' + pieceLtrToName[prevMove.captPiece.toLowerCase( )]; } else { item = 'black_' + pieceLtrToName[prevMove.captPiece.toLowerCase( )]; } var capt = getObject('captures').getElementsByTagName('img'); var i; for (i = 0; i < capt.length; i++) { if (capt[i].alt == item) { takenPiece = capt[i]; break; } } } highlight(getObject('tsq' + prevMove.fromSq), 'highlighted'); setTimeout('highlightCurMoveTo( )', 300); setTimeout('unhighlightCurMove( )', 900); } function highlightCurMoveTo( ) { if (takenPiece) { highlight(takenPiece, 'taken_highlighted'); if (captEnPass) { highlight(captEnPass, 'taken_highlighted'); highlight(getObject('tsq' + prevMove.toSq), 'highlighted'); } else { highlight(getObject('tsq' + prevMove.toSq), 'taken_highlighted'); } } else { highlight(getObject('tsq' + prevMove.toSq), 'highlighted'); } } function displayCurFEN(moveIdx) { if (undefined != moveIdx) { getObject('FENblock').innerHTML = FEN[moveIdx]; } else { getObject('FENblock').innerHTML = FEN[FEN.length - 1]; } } // these will throw errors, but initializing them as 'undefined' is the // only way to ensure all-around compatibility no matter what the original colors are. function moveTo(objMoveId) { var theBoard; if (0 < currMoveIdx) // don't try to reset the empty span, it throws errors { unhighlight(getObject('m' + currMoveIdx)); // reset the previous move box background color } currMoveIdx = parseInt(objMoveId.id.slice(1)); // get the move number FENToBoard(FEN[currMoveIdx]); // convert that FEN to the board var displayCurFEN(currMoveIdx); // display that FEN FENToCapt(currMoveIdx); // get the captures up to that point displayCaptPieces( ); // display those captures theBoard = htmlBoard( ); // convert the board var to html code getObject('chessboard').innerHTML = theBoard; // display that board highlight(getObject('m' + currMoveIdx), 'curmove_highlighted'); // change the move box background color } function moveJmp(moveDelta) { var moveIdx = currMoveIdx; if (moveIdx + moveDelta > FEN.length - 1) { moveIdx = FEN.length - 1; } else if (moveIdx + moveDelta < 0) { moveIdx = 0; } else { moveIdx += moveDelta; } moveTo(getObject('m' + moveIdx + '')); } function displayMoves(replay) { var i; var alt = ''; var objGamebody = getObject('gamebody'); var theMoves = '\n<span id="m0"></span>'; var moveId = 1; theMoves += '\n<table class="moveList">\n'; for (i = 0; i < moves.length; i++) { if ( (i + 1) % 2 == 0) { alt = ' class="alt"'; } else { alt = ''; } if ('1' == isGameOver || replay || 'mate' == gameState) { theMoves += '<tr'+alt+'>\n<td class="mn">' + (i+1) + '.</td>\n'; theMoves += '<td id="m' + (moveId) + '" class="wm" onclick="moveTo(this);">' + moves[i][0] + '</td>\n'; theMoves += '<td id="m' + (moveId+1) + '" class="bm" onclick="moveTo(this);">' + moves[i][1] + '</td>\n</tr>'; moveId = moveId + 2; } else { theMoves += '<tr'+alt+'>\n<td class="mn">' + (i+1) + '.</td>\n<td class="wm">'; theMoves += moves[i][0] + '</td>\n<td class="bm">' + moves[i][1] + '</td>\n</tr>'; } } theMoves += '\n</table>\n'; if ('' != result) { theMoves += '<span class="ctr">Result: ' + result + '</span>\n'; } objGamebody.innerHTML = theMoves; element = document.getElementById('gamebody'); element.scrollTop = element.scrollHeight; } function toggleInvert( ) { if ('black' == perspective) perspective = 'white'; else perspective = 'black'; theBoard = htmlBoard( ); getObject('chessboard').innerHTML = theBoard; } function htmlBoard( ) { // Returns the HTML-code for the current chessboard (Note: Fixed square size and theme) var i,j,k; var classWSquare; var classBSquare; var classHeader; var fileLabel; var xtra; var mtra; var colorside; var invertBoard = (perspective == 'black'); var rank = 8; var rankLabel = rank; if ('' == isBoardDisabled && ! watchgame) { classWSquare = 'light_enabled'; classBSquare = 'dark_enabled'; classHeader = 'header_enabled'; } else { classWSquare = 'light_disabled'; classBSquare = 'dark_disabled'; classHeader = 'header_disabled'; } var sqBackground = [classBSquare, classWSquare]; if (invertBoard) { rankLabel = 1; colorside = "white"; } else { colorside = "black"; } j = 1; //changement du plateau selon le nombre de parteis gagnées if(parties_gagnees < 100){ theBoard = '\n<div id="theBoard" style="background: url(./images/bois.png);">\n'; var couleur = 'style="color:#111;"'; //correspond aux lettres et chiffres du bord de l'échiquier }else if(parties_gagnees >= 100){ theBoard = '\n<div id="theBoard" style="background: url(./images/marbre.png);">\n'; var couleur = 'style="color:#555;"'; //correspond aux lettres et chiffres du bord de l'échiquier } theBoard += '<div class="' + classHeader + ' ' + colorside + 'corner"> <\/div>\n'; for(i = 0; i < 8; i++) { if(invertBoard) fileLabel = Files[7-i]; else fileLabel = Files[i]; theBoard += '<div '+couleur+' id="file_t' + i + '" class="' + classHeader + ' horz">' + fileLabel + '<\/div>\n'; } theBoard += '<div class="' + classHeader + ' ' + colorside + 'corner"> <\/div>\n'; theBoard += '<div '+couleur+' id="rank_l' + rank-- + '" class="' + classHeader + ' vert">' + rankLabel + '</div>\n'; for (k = 63; k >= 0; k--) { if ((k+1) % 8 == 0) { i = k - 7; if (invertBoard) i = 63 - i; } else { if (invertBoard) i--; else i++; } var row = parseInt(i / 8); var col = i % 8; if (prevMove && row == prevMove.fromRow && col == prevMove.fromCol && '' == isBoardDisabled && ! watchgame && lastMoveIndicator) xtra = " fromSquare"; else if (prevMove && row == prevMove.toRow && col == prevMove.toCol && '' == isBoardDisabled && ! watchgame && lastMoveIndicator) xtra = " toSquare"; else xtra = ""; theBoard += '<div id="tsq' + i + '" class="' + sqBackground[j] + xtra + '">'; var piece = ''; var source = ''; if(board[row][col] != 0) { piece = getPieceColor(board[row][col]) + '_' + getPieceName(board[row][col]); source = 'images/' + currentTheme + '/' + piece + '.' + ((-1 !== currentTheme.indexOf('gnuchess')) ? 'png' : 'gif'); // Update the square theBoard += '<img alt="' + piece + '" id="sq' + i + '" '; theBoard += 'src="' + source + '" width="50" height="50" />'; } else { theBoard += ''; } theBoard += '<\/div>\n'; if ( (k % 8) === 0 ) { theBoard += '<div '+couleur+' id="rank_r' + (rank+1) + '" class="' + classHeader + ' vert">' + rankLabel + '<\/div>\n'; if (k != 0) { if(invertBoard) rankLabel = 9 - rank; else rankLabel = rank; theBoard += '<div '+couleur+' id="rank_l' + rank-- + '" class="' + classHeader + ' vert">' + rankLabel + '</div>\n'; } } else { j = 1 - j; } } if ("white" == colorside) colorside = "black"; else colorside = "white"; theBoard += '<div '+couleur+' class="' + classHeader + ' ' + colorside + 'corner"> <\/div>\n'; for (i = 0; i < 8; i++) { if (invertBoard) fileLabel = Files[7-i]; else fileLabel = Files[i]; xtra = "";mtra = ""; // erase any previous values if ("518" != id960 && "header_disabled" != classHeader) // if we are not in a normal game and not disabled { if ("c" == fileLabel || "g" == fileLabel) { xtra = "<span class=\"kingto\">K</span>"; mtra = "<span class=\"spacer\">K</span>"; } else if ("d" == fileLabel) { xtra = "<span class=\"rookato\">R</span>"; mtra = "<span class=\"spacer\">R</span>"; } else if ("f" == fileLabel) { xtra = "<span class=\"rookhto\">R</span>"; mtra = "<span class=\"spacer\">R</span>"; } var LorigARookPos = origARookPos; var LorigKingPos = origKingPos; var LorigHRookPos = origHRookPos; if (invertBoard) { LorigARookPos = 7 - LorigARookPos; LorigKingPos = 7 - LorigKingPos; LorigHRookPos = 7 - LorigHRookPos; } if (i == LorigARookPos) fileLabel = '<span class="origarook">' + fileLabel + '</span>'; else if (i == LorigKingPos) fileLabel = '<span class="origking">' + fileLabel + '</span>'; else if (i == LorigHRookPos) fileLabel = '<span class="orighrook">' + fileLabel + '</span>'; } theBoard += '<div '+couleur+' id="file_b' + i + '" class="' + classHeader + ' horz">' + mtra + fileLabel + xtra + '<\/div>\n'; } theBoard += '<div class="' + classHeader + ' ' + colorside + 'corner"> <\/div>\n<\/div>\n'; return theBoard; } // only do disabled = true for btnWakeUp, it is set as disabled if no email is present. FENToBoard(FEN[FEN.length - 1]); // save the last entry in the FEN array to the board var theBoard = htmlBoard( ); // The HTML code for the board var currMoveIdx = 0; var intervalId = 0; window.onload = function( ) { var i; var lastMove; var navButtons; var gameIdDisplay; var invertBoard = (perspective == 'black'); getObject('chessboard').innerHTML = theBoard; //displayCurFEN( ); FENToCapt(numMoves); displayCaptPieces( ); if (0 != gameId) // is it a database game ? { gameIdDisplay = 'Partie ' + gameId; getObject('btnPGN').disabled = false; } else // or a PGN file game { gameIdDisplay = 'PGN Game'; } if ( ! watchgame) { if ('518' != id960) // if it's a Chess960 game { gameIdDisplay += ' - ' + id960 // display the id } else // or a regular game { getObject("castle").style.display = 'none'; } } if ('1' != isBoardDisabled && ! watchgame) { if (0 < numMoves) { getObject("btnUndo").disabled = false; } getObject("btnDraw").disabled = false; getObject("btnResign").disabled = false; //document.querySelector('btnResign').disabled = false; } if ( ! watchgame) // are we playing the game { displayMoves( ); getObject("btnReload").disabled = false; getObject("btnReplay").disabled = false; getObject("btnReload").onclick = function( ) { reloadPage(this); }; getObject("btnReplay").onclick = function( ) { replay( ); }; if (0 < moves.length) // if there are moves { lastMove = moves.length + '-'; // get the move number if ('' != moves[moves.length-1][1]) // if we are showing a black move { getObject('curmove').innerHTML = lastMove + ' ... ' + moves[moves.length-1][1]; } else // we are showing a white move { getObject('curmove').innerHTML = lastMove + ' ' + moves[moves.length-1][0]; } if ('1' != isGameOver) { getObject("curmove").onclick = function( ) { highlightCurMove( ); }; } } if ('check' == gameState) { getObject('checkmsg').style.display = ''; getObject('checkmsg').innerHTML = 'Echec !'; // convert the board border to red if in check var divs = document.all ? document.all : document.getElementById("theBoard").getElementsByTagName("div"); for ( var i = 0; i < divs.length; i++) { if (divs[i].className.match(/.*?(horz|vert).*?/)) { divs[i].style.backgroundColor = "#BF2F35"; // TODO : stylefix } } } if ('' != statusMessage) { getObject('statusmsg').style.display = ''; getObject('statusmsg').innerHTML = statusMessage; // if the statusMessage says anything about undo's // prevent multiple undo's from being requested if (statusMessage.match(/ undo /i)) { getObject('btnUndo').disabled = true; } } } else // or just watching the game { displayMoves(true); } getObject('gameid').innerHTML = gameIdDisplay; getObject('players').innerHTML = players; //getObject('btnMainMenu').disabled = false; getObject('btnPGN').disabled = false; //getObject('btnMainMenu').onclick = function( ) { displayMainmenu( ); }; getObject('btnPGN').onclick = function( ) { downloadPGN( ); }; if ( ! watchgame) { getObject("btnUndo").onclick = function( ) { undo( ); }; getObject("btnDraw").onclick = function( ) { draw( ); }; getObject("btnResign").onclick = function( ) { resigngame( ); }; //document.querySelector('btnResign').onclick = function( ) { resigngame( ); }; } if ('1' == isGameOver || watchgame || 'mate' == gameState) // Allow game replay { if ( ! watchgame) { getObject('gamebuttons').style.display = 'none'; getObject('btnWakeUp').disabled = true; getObject('btnReload').disabled = true; getObject('btnReplay').disabled = true; } currMoveIdx = FEN.length - 1; navButtons = '<form id="navigation" action="">'; navButtons += '<span id="navbuttons">'; navButtons += '<input id="start" title="Début de la partie" type="button" value="Start" />'; navButtons += '<input id="jmpback" title="Retour en arrière de 5 demi-coups" type="button" value=" << " />'; navButtons += '<input id="prev" title="Retour en arrière d\'un demi-coup" type="button" value=" < " />'; navButtons += '<input id="next" title="Avancer d\'un demi-coup" type="button" value=" > " />'; navButtons += '<input id="jmpfwd" title="Avancer de 5 demi-coups" type="button" value=" >> " />'; navButtons += '<input id="end" title="Fin de la partie" type="button" value="End" /> <br> '; navButtons += '<input style="width:100px" id="invert" title="Inverser" type="button" value="< Tourner" />'; navButtons += '<input style="width:100px" id="invert2" title="Inverser" type="button" value="Tourner >" disabled />'; navButtons += '</span>'; navButtons += '</form>'; function invert1(){ /*toggleInvert( )*/ document.getElementById("invert").disabled = true; document.getElementById("invert2").disabled = false; document.getElementById("theBoard").style.transform = "rotate(180deg)"; document.getElementById("theBoard").style.transition = ".3s"; for (var i=0; i < 64; i++) { var element = document.getElementById("sq"+i); if (typeof(element) != 'undefined' && element != null) { document.getElementById("sq"+i).style.transform = "rotate(180deg)"; } } }; function invert2(){ /*toggleInvert( )*/ document.getElementById("invert2").disabled = true; document.getElementById("invert").disabled = false; document.getElementById("theBoard").style.transform = "rotate(0deg)"; document.getElementById("theBoard").style.transition = ".3s"; for (var i=0; i < 64; i++) { var element = document.getElementById("sq"+i); if (typeof(element) != 'undefined' && element != null) { document.getElementById("sq"+i).style.transform = "rotate(0deg)"; //document.getElementById("theBoard").style.transition = ".3s"; } } //document.getElementById("invert").style.display = "block"; //document.getElementById("invert2").style.display = "none"; }; getObject('gamenav').innerHTML = navButtons; getObject("start").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(-10000);invert1();}else{moveJmp(-10000)} ;}; getObject("jmpback").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(-5);invert1();}else{moveJmp(-5)};}; getObject("prev").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(-1);invert1();}else{moveJmp(-1)};}; getObject("next").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(1);invert1();}else{moveJmp(1)};}; getObject("jmpfwd").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(5);invert1();}else{moveJmp(5)};}; getObject("end").onclick = function( ){if(document.getElementById("invert").disabled == true){invert2();moveJmp(10000);invert1();}else{moveJmp(10000)};}; getObject("invert").onclick = function( ){invert1()}; getObject("invert2").onclick = function( ){invert2()}; } else // game is not over and we are not replaying it { isGameDrawn( ); // Alert the players it's stalemate, 50 move draw or the same position has occurred three times if (true == isPlayersTurn) { // No need to set event handlers unless it's the player's move for(i = 0; i < 64; i++) { getObject('tsq' + i).onclick = function( ) { squareClicked(this); }; } getObject('btnWakeUp').disabled = true; } if (autoreload > 0 && ! DEBUG) // if we need the board refreshed { intervalId = setTimeout("window.location.replace('chess.php')", autoreload * 1000); // start the refresh loop } } }
ONCLICK dans le fichier commands.js ci dessus aux lignes:
145 à 152
ONCLICK dans le fichier sortabletable.js ci dessus aux lignes:
65
88
176
223
411
Et l'image de l'onglet console:
l'image de la console, c'est lorsque tu as cliqué sur un des boutons ou pas ?
Sachant que par défaut il semble qu'ils soient en disabled...
il faudrait peut-être retirer cet attribut déjà pour tester
Sachant que par défaut il semble qu'ils soient en disabled...
il faudrait peut-être retirer cet attribut déjà pour tester
<input type="button" id="btnUndo" class="button" value="Demande à rejouer" /> <input type="button" id="btnDraw" class="button" value="Demande la nulle" /> <input type="button" id="btnResign" class="button" value="Abandonner" />
Cette image est effectuée en passant la souris sur le bouton "Abandonner".
Lorsque je clique sur ce bouton cela me renvoi à la page :
https://jeuxechecs.fr/echecs/login.php
J'ai modifié la ligne 396 comme ceci:
Sans aucun résultat.
Lorsque je clique sur ce bouton cela me renvoi à la page :
https://jeuxechecs.fr/echecs/login.php
J'ai modifié la ligne 396 comme ceci:
<input type="button" id="btnResign" class="button" value="Abandonner" />
Sans aucun résultat.
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question