]> git.sesse.net Git - remoteglot/blobdiff - www/js/remoteglot.js
Turn off the depth secondary key sorting for the purpose of arrows.
[remoteglot] / www / js / remoteglot.js
index c5ab4379f05d14074e314876fc84cc6116a72521..26abd4ae14a382fe293975cdf3a757b087b2b793 100644 (file)
@@ -48,8 +48,8 @@ var displayed_analysis_data = null;
  *      name: string,
  *      url: string,
  *      id: string,
- *      score: =Object,
- *      result: =string,
+ *      score: Object=,
+ *      result: string=,
  * }>}
  * @private
  */
@@ -572,7 +572,7 @@ var compare_by_score = function(refutation_lines, invert, a, b) {
  * @param {!Object} data
  * @param {number} margin The maximum number of centipawns worse than the
  *     best move can be and still be included.
- * @param {boolean} margin Whether black is to play.
+ * @param {boolean} invert Whether black is to play.
  * @return {Array.<string>} The FEN representation (e.g. Ne4) of all
  *     moves, in score order.
  */
@@ -584,7 +584,7 @@ var find_nonstupid_moves = function(data, margin, invert) {
        var pv_score = undefined;
        for (var move in data['refutation_lines']) {
                var line = data['refutation_lines'][move];
-               var score = compute_score_sort_key(line['score'], line['depth'], invert);
+               var score = compute_score_sort_key(line['score'], line['depth'], invert, false);
                if (move == data['pv'][0]) {
                        pv_score = score;
                }
@@ -1076,7 +1076,7 @@ var update_board = function() {
                // from the start.
                var hiddenboard = chess_from(null, current_display_line.pv, current_display_move);
                var moves = hiddenboard.history({ verbose: true });
-               var last_move = moves.pop();
+               last_move = moves.pop();
                highlight_from = last_move.from;
                highlight_to = last_move.to;
        } else {
@@ -1204,7 +1204,7 @@ var update_board = function() {
                                break;
                        }
                        var line = data['refutation_lines'][nonstupid_moves[i]];
-                       var hiddenboard = new Chess(base_fen);
+                       hiddenboard = new Chess(base_fen);
                        hiddenboard.move(line['pv'][0]);
                        var this_response = hiddenboard.move(line['pv'][1]);
                        if (response.from !== this_response.from || response.to !== this_response.to) {
@@ -1336,7 +1336,6 @@ var update_clock = function() {
 
        var white_clock_ms = null;
        var black_clock_ms = null;
-       var show_seconds = false;
 
        // Static clocks.
        if (data['position'] &&
@@ -2062,9 +2061,10 @@ var compute_plot_score = function(score) {
  * @param score The score digest tuple.
  * @param {?number} depth Depth the move has been computed to, or null.
  * @param {boolean} invert Whether black is to play.
+ * @param {boolean=} depth_secondary_key
  * @return {number}
  */
-var compute_score_sort_key = function(score, depth, invert) {
+var compute_score_sort_key = function(score, depth, invert, depth_secondary_key) {
        var s;
        if (!score) {
                return -10000000;
@@ -2084,7 +2084,11 @@ var compute_score_sort_key = function(score, depth, invert) {
        }
        if (s) {
                if (invert) s = -s;
-               return s * 200 + (depth || 0);
+               if (depth_secondary_key) {
+                       return s * 200 + (depth || 0);
+               } else {
+                       return s;
+               }
        } else {
                return null;
        }