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 = [];
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;