]> git.sesse.net Git - remoteglot/blobdiff - www/js/remoteglot.js
Revert "Fix move highlights when collapsing/uncollapsing history."
[remoteglot] / www / js / remoteglot.js
index d89da33b3d5339f5b581c356ba2fb68af78f3389..d6a08a875b8642332f76f6bf60222797eec36f6e 100644 (file)
@@ -7,7 +7,7 @@
  * @type {Number}
  * @const
  * @private */
-var SCRIPT_VERSION = 2016113007;
+var SCRIPT_VERSION = 2016113008;
 
 /**
  * The current backend URL.
@@ -294,7 +294,7 @@ var request_update = function() {
                        update_num_viewers(num_viewers);
                } else {
                        console.log("Received invalid update, waiting five seconds and trying again.");
-                       location.reload(true);
+                       setTimeout(function() { location.reload(true); }, 5000);
                }
 
                // Next update.
@@ -780,6 +780,10 @@ var update_refutation_lines = function() {
        var tbl = $("#refutationlines");
        tbl.empty();
 
+       if (display_lines.length < 2) {
+               return;
+       }
+
        // Find out where the lines start from.
        var base_line = [];
        var base_scores = display_lines[1].scores;
@@ -796,7 +800,7 @@ var update_refutation_lines = function() {
        }
 
        var invert = (toplay === 'B');
-       if (current_display_line && current_display_move % 2 == 0) {
+       if (current_display_line && current_display_move % 2 == 0 && !current_display_line_is_history) {
                invert = !invert;
        }
        moves = moves.sort(function(a, b) { return compare_by_score(refutation_lines, invert, a, b) });
@@ -1260,7 +1264,7 @@ var update_board = function() {
                        if (!data['refutation_lines'] ||
                            !data['refutation_lines'][nonstupid_moves[i]] ||
                            !data['refutation_lines'][nonstupid_moves[i]]['pv'] ||
-                           data['refutation_lines'][nonstupid_moves[i]]['pv'].length < 1) {
+                           data['refutation_lines'][nonstupid_moves[i]]['pv'].length < 2) {
                                // Incomplete PV, abort.
                                response = undefined;
                                break;
@@ -1335,6 +1339,7 @@ var update_sparkline = function(data) {
                        }
                        // FIXME: at some widths, calling sparkline() seems to push
                        // #scorecontainer under the board.
+                       $('#scorespark').unbind('sparklineClick');
                        $("#scorespark").sparkline(scores, {
                                type: 'bar',
                                zeroColor: 'gray',
@@ -1346,6 +1351,7 @@ var update_sparkline = function(data) {
                                        return format_tooltip(data, fields[0].offset + first_move_num - 1);
                                }
                        });
+                       $('#scorespark').unbind('sparklineClick');
                        $('#scorespark').bind('sparklineClick', function(event) {
                                var sparkline = event.sparklines[0];
                                var region = sparkline.getCurrentRegionFields();