X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=www%2Fjs%2Fremoteglot.js;h=0a4366cbf801180b79ab5eef25a1c515bca784fd;hb=fbc73d17f36578f7eb877322ea63a6b488868c69;hp=e478fb88225f37bd5559fdbdb971e6b03d961399;hpb=d4b3f24c6e2cfadf5b543f97dd7817c2826c03fb;p=remoteglot diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index e478fb8..0a4366c 100644 --- a/www/js/remoteglot.js +++ b/www/js/remoteglot.js @@ -1806,6 +1806,15 @@ var get_best_move = function(game, source, target, invert) { move_hash[moves[i].san] = moves[i]; } + // See if we're already exploring some line. + if (current_display_line && + current_display_move < current_display_line.pretty_pv.length - 1) { + var first_move = current_display_line.pretty_pv[current_display_move + 1]; + if (move_hash[first_move]) { + return move_hash[first_move]; + } + } + // History and PV take priority over the display lines. for (var i = 0; i < 2; ++i) { var line = display_lines[i]; @@ -1896,14 +1905,6 @@ var onSnapEnd = function(source, target) { } // End of dragging-related code. -var pad = function(val, num_digits) { - var s = val.toString(); - while (s.length < num_digits) { - s = " " + s; - } - return s; -} - var fmt_cp = function(v) { if (v === 0) { return "0.00"; @@ -1921,9 +1922,9 @@ var format_short_score = function(score) { } if (score[0] === 'm') { if (score[2]) { // Is a bound. - return score[2] + "\u00a0M" + pad(score[1], 3); + return score[2] + "\u00a0M " + score[1]; } else { - return "M" + pad(score[1], 3); + return "M " + score[1]; } } else if (score[0] === 'd') { return "TB draw"; @@ -1931,7 +1932,7 @@ var format_short_score = function(score) { if (score[2]) { // Is a bound. return score[2] + "\u00a0" + fmt_cp(score[1]); } else { - return pad(fmt_cp(score[1]), 5); + return fmt_cp(score[1]); } } return null;