X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=www%2Fjs%2Fremoteglot.js;h=d36bf9e5117bed15911ea36263ed5084fc6f0c48;hb=5a1f6c832883367ca4925443c63ed2aefb6514fd;hp=ceeff7b3c94de6c10ff6f013d837b414c500227f;hpb=6bc75bbe9c7b761ebce2844cf204c14c12bf5bf9;p=remoteglot
diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js
index ceeff7b..d36bf9e 100644
--- a/www/js/remoteglot.js
+++ b/www/js/remoteglot.js
@@ -1319,7 +1319,7 @@ function update_board() {
document.getElementById("searchstats").textContent = "";
}
if (admin_password !== null) {
- document.getElementById("searchstats").innerHTML += " | ADMIN MODE (if password is right)";
+ document.getElementById("searchstats").innerHTML += " | ADMIN MODE (if password is right) | Undo move";
}
// Update the board itself.
@@ -2258,6 +2258,29 @@ function send_chosen_move(fen, move) {
}
}
+function undo_move() {
+ if (admin_password !== null) {
+ let history = current_analysis_data['position']['history'];
+ history = history.slice(0, history.length - 1);
+
+ let position = current_analysis_data['position']['start_fen'];
+ let hiddenboard = chess_from(position, history, history.length);
+ let fen = hiddenboard.fen();
+
+ let url = '/manual-override.pl';
+ url += '?fen=' + encodeURIComponent(fen);
+ url += '&history=' + encodeURIComponent(JSON.stringify(history));
+ url += '&move=null';
+ 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);
+
+ console.log(fen, history);
+ fetch(url); // Ignore the result.
+ }
+}
+window['undo_move'] = undo_move;
+
function onSnapEnd(source, target) {
if (source === target && recommended_move !== null) {
source = recommended_move.from;