X-Git-Url: https://git.sesse.net/?p=remoteglot;a=blobdiff_plain;f=www%2Fjs%2Fremoteglot.js;fp=www%2Fjs%2Fremoteglot.js;h=51a470f502c59af3788255da7c719bab1694b336;hp=54fc90b46afc5d5e818ddb87bd9a7cfaa41b33b6;hb=8733e976299634c8bce83bc8908a99ff669bc2fd;hpb=f120f5172ba09d12928acc7228e4aa331cbdc190 diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index 54fc90b..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; @@ -1277,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']; @@ -2214,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 && @@ -2459,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; },