X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=www%2Fjs%2Fremoteglot.js;h=51a470f502c59af3788255da7c719bab1694b336;hb=8733e976299634c8bce83bc8908a99ff669bc2fd;hp=e14fffa2b81394d6c63645182414e7ca1a142119;hpb=66e4755548c69077058eecb08d907f59907bb2b4;p=remoteglot diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index e14fffa..51a470f 100644 --- a/www/js/remoteglot.js +++ b/www/js/remoteglot.js @@ -125,6 +125,9 @@ let reverse_dragging_from = null; /** @type {?number} @private */ let unique = null; +/** @type {?string} @private */ +let admin_password = null; + /** @type {boolean} @private */ let enable_sound = false; @@ -1114,15 +1117,6 @@ function update_board() { headline = 'Analysis'; } - // Credits, where applicable. Note that we don't want the footer to change a lot - // when e.g. viewing history, so if any of these changed during the game, - // use the current one still. - if (current_data['using_lomonosov']) { - document.getElementById("lomonosov").style.display = null; - } else { - document.getElementById("lomonosov").style.display = 'none'; - } - // Credits: The engine name/version. if (current_data['engine'] && current_data['engine']['name'] !== null) { document.getElementById("engineid").textContent = current_data['engine']['name']; @@ -1269,8 +1263,6 @@ function update_board() { // The search stats. if (data['searchstats']) { document.getElementById("searchstats").textContent = data['searchstats']; - } else if (data['tablebase'] == 1) { - document.getElementById("searchstats").textContent = "Tablebase result"; } else if (data['nodes'] && data['nps'] && data['depth']) { let stats = thousands(data['nodes']) + ' nodes, ' + thousands(data['nps']) + ' nodes/sec, depth ' + data['depth'] + ' ply'; if (data['seldepth']) { @@ -1288,6 +1280,9 @@ function update_board() { } else { document.getElementById("searchstats").textContent = ""; } + if (admin_password !== null) { + document.getElementById("searchstats").innerHTML += " | ADMIN MODE (if password is right)"; + } // Update the board itself. base_fen = data['position']['fen']; @@ -1987,7 +1982,8 @@ function update_displayed_line() { function set_board_position(new_fen) { board_is_animating = true; let old_fen = board.fen(); - board.position(new_fen); + let animate = old_fen !== '8/8/8/8/8/8/8/'; + board.position(new_fen, animate); if (board.fen() === old_fen) { board_is_animating = false; } @@ -2224,6 +2220,18 @@ function onSnapEnd(source, target) { promotion: 'q' // NOTE: always promote to a queen for example simplicity }); + if (admin_password !== null) { + let url = '/manual-override.pl'; + url += '?fen=' + encodeURIComponent(display_fen); + url += '&history=' + encodeURIComponent(JSON.stringify(current_analysis_data['position']['history'])); + url += '&move=' + encodeURIComponent(move.san); + url += '&player_w=' + encodeURIComponent(current_analysis_data['position']['player_w']); + url += '&player_b=' + encodeURIComponent(current_analysis_data['position']['player_b']); + url += '&password=' + encodeURIComponent(admin_password); + fetch(url); + return; + } + // Move ahead on the line we're on -- this includes history if we've // gone backwards. if (current_display_line && @@ -2469,6 +2477,11 @@ function init() { set_sound(false); } + let admin_match = window.location.href.match(/\?password=([a-zA-Z0-9_-]+)/); + if (admin_match !== null) { + admin_password = admin_match[1]; + } + // Create board. board = new window.ChessBoard('board', { onMoveEnd: function() { board_is_animating = false; },