+/**
+ * If we are in admin mode, send this move to the backend.
+ *
+ * @param {string} fen
+ * @param {string} move
+ */
+function send_chosen_move(fen, move) {
+ if (admin_password !== null) {
+ let history = current_analysis_data['position']['history'];
+ let url = '/manual-override.pl';
+ url += '?fen=' + encodeURIComponent(fen);
+ url += '&history=' + encodeURIComponent(JSON.stringify(history));
+ url += '&move=' + encodeURIComponent(move);
+ 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.
+ }
+}
+
+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) {