/** @type {?number} @private */
let unique = null;
+/** @type {?string} @private */
+let admin_password = null;
+
/** @type {boolean} @private */
let enable_sound = false;
ret.appendChild(document.createTextNode(move_num + '. … '));
}
for (; i < pv.length; ++i) {
- let link = document.createElement('a');
- link.className = 'move';
- link.setAttribute('id', 'automove' + line_num + '-' + i);
- link.textContent = pv[i];
- link.href = 'javascript:show_line(' + line_num + ', ' + i + ');';
+ let prefix = '';
if (splicepos === i) {
- ret.appendChild(document.createTextNode('(TB: '));
+ prefix = '(TB: ';
in_tb = true;
}
} else if (toplay == 'W') {
if (i > opt_limit && !opt_showlast) {
if (in_tb) {
- ret.appendChild(document.createTextNode(')'));
+ prefix += ')';
}
- ret.appendChild(document.createTextNode(' (…)'));
+ ret.appendChild(document.createTextNode(prefix + ' (…)'));
return ret;
}
- ret.appendChild(document.createTextNode(' ' + move_num + '. '));
+ prefix += ' ' + move_num + '. ';
++move_num;
toplay = 'B';
} else {
- ret.appendChild(document.createTextNode(' '));
+ prefix += ' ';
toplay = 'W';
}
+ ret.appendChild(document.createTextNode(prefix));
+
+ let link = document.createElement('a');
+ link.className = 'move';
+ link.setAttribute('id', 'automove' + line_num + '-' + i);
+ link.textContent = pv[i];
+ link.href = 'javascript:show_line(' + line_num + ', ' + i + ');';
ret.appendChild(link);
}
if (in_tb) {
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'];
document.getElementById("score").textContent = "No analysis for this move";
document.getElementById("pvtitle").textContent = "PV:";
document.getElementById("pv").replaceChildren();
- document.getElementById("searchstats").textContent = " ";
+ document.getElementById("searchstats").innerHTML = " ";
document.getElementById("refutationlines").replaceChildren();
document.getElementById("whiteclock").replaceChildren();
document.getElementById("blackclock").replaceChildren();
// 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']) {
} else {
document.getElementById("searchstats").textContent = "";
}
+ if (admin_password !== null) {
+ document.getElementById("searchstats").innerHTML += " | <span style=\"color: red;\">ADMIN MODE (if password is right)</span>";
+ }
// Update the board itself.
base_fen = data['position']['fen'];
// This matches what DGT clocks do.
let show_seconds = (white_clock_ms < 60 * 20 * 1000 || black_clock_ms < 60 * 20 * 1000);
- if (color) {
+ if (color && remaining_ms > 0) {
// See when the clock will change next, and update right after that.
let next_update_ms;
if (show_seconds) {
document.getElementById("pvtitle").textContent = "Exploring:";
current_display_line.start_display_move_num = 0;
display_lines.push(current_display_line);
- document.getElementById("pv").append(print_pv(display_lines.length - 1, null)); // FIXME
+ document.getElementById("pv").replaceChildren(print_pv(display_lines.length - 1, null)); // FIXME
display_line_num = display_lines.length - 1;
// Clear out the PV, so it's not selected by anything later.
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;
}
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 &&
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; },
document.getElementById("board").addEventListener('mousedown', mousedownSquare);
document.getElementById("board").addEventListener('mouseup', mouseupSquare);
+ if (window['inline_json']) {
+ let j = window['inline_json'];
+ process_update_response(j['data'], { 'get': (h) => j['headers'][h] });
+ delete window['inline_json'];
+ }
request_update();
window.addEventListener('resize', function() {
board.resize();
update_board_highlight();
redraw_arrows();
});
+ new ResizeObserver(() => update_sparkline(displayed_analysis_data || current_analysis_data)).observe(document.getElementById('scoresparkcontainer'));
window.addEventListener('keyup', function(event) {
if (event.which == 39) { // Left arrow.
next_move();