]> git.sesse.net Git - remoteglot/blobdiff - www/js/remoteglot.js
Fix a crash that happens if we were looking at a PV line while new information came in.
[remoteglot] / www / js / remoteglot.js
index 80a5db9d9bb9696961c94002f90213ec24b077c0..8bb49d27a539f4c14ae5d567b0e54b0c079c092f 100644 (file)
@@ -33,8 +33,12 @@ var request_update = function(board) {
 
 var clear_arrows = function() {
        for (var i = 0; i < arrows.length; ++i) {
-               jsPlumb.detach(arrows[i].connection1);
-               jsPlumb.detach(arrows[i].connection2);
+               if (arrows[i].connection1) {
+                       jsPlumb.detach(arrows[i].connection1);
+               }
+               if (arrows[i].connection2) {
+                       jsPlumb.detach(arrows[i].connection2);
+               }
        }
        arrows = [];
 
@@ -261,7 +265,7 @@ var find_nonstupid_moves = function(data, margin) {
                        moves.push(move);
                }
        }
-       moves = moves.sort(function(a, b) { return compare_by_score(data.refutation_lines, a, b) });
+       moves = moves.sort(function(a, b) { return compare_by_score(data.refutation_lines, data.position.toplay, a, b) });
        moves.unshift(data.pv_uci[0]);
 
        return moves;