]> git.sesse.net Git - remoteglot/blobdiff - www/js/remoteglot.js
Fix an issue where two PVs would be printed.
[remoteglot] / www / js / remoteglot.js
index de1bb1652c3960bde41bcac5ffea08a8476817f3..ae522e26113c9869d61ef81d47bce9d4f046c4d7 100644 (file)
@@ -755,13 +755,9 @@ function print_pv(line_num, splicepos, opt_limit, opt_showlast) {
                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;
                }
 
@@ -771,18 +767,25 @@ function print_pv(line_num, splicepos, opt_limit, opt_showlast) {
                } 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) {
@@ -1226,7 +1229,7 @@ function update_board() {
                document.getElementById("score").textContent = "No analysis for this move";
                document.getElementById("pvtitle").textContent = "PV:";
                document.getElementById("pv").replaceChildren();
-               document.getElementById("searchstats").textContent = "&nbsp;";
+               document.getElementById("searchstats").innerHTML = "&nbsp;";
                document.getElementById("refutationlines").replaceChildren();
                document.getElementById("whiteclock").replaceChildren();
                document.getElementById("blackclock").replaceChildren();
@@ -1595,7 +1598,7 @@ function update_clock() {
        // 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) {
@@ -1900,7 +1903,7 @@ function update_move_highlight() {
                        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.