X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=www%2Fjs%2Fremoteglot.js;h=3dacd5809b73a281b0cd4cf73a8fba1d7fe1c133;hb=c4bae043e7f74f313b2b9862640796702b646ddf;hp=486ca8de6c1bb45c755de95a6de78d62ff38d831;hpb=960b6ea34239ae508e3ab9841665fd7ba390fba3;p=remoteglot diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index 486ca8d..3dacd58 100644 --- a/www/js/remoteglot.js +++ b/www/js/remoteglot.js @@ -1672,6 +1672,7 @@ var explore_hash = function(fen) { clearTimeout(current_hash_display_timer); current_hash_display_timer = null; } + $("#refutationlines").empty(); current_hash_xhr = $.ajax({ url: backend_hash_url + "?fen=" + fen }).done(function(data, textstatus, xhr) { @@ -1773,6 +1774,15 @@ var get_best_move = function(game, source, target) { move_hash[moves[i].san] = moves[i]; } + // History and PV take priority over the display lines. + for (var i = 0; i < 2; ++i) { + var line = display_lines[i]; + var first_move = line.pretty_pv[line.start_display_move_num]; + if (move_hash[first_move]) { + return move_hash[first_move]; + } + } + var best_move = null; var best_move_score = null; @@ -1784,9 +1794,10 @@ var get_best_move = function(game, source, target) { } var first_move = line['pv_pretty'][0]; if (move_hash[first_move]) { - if (best_move_score === null || line['score_sort_key'] > best_move_score) { + var score = parseInt(line['score_sort_key'], 10); + if (best_move_score === null || score > best_move_score) { best_move = move_hash[first_move]; - best_move_score = line['score_sort_key']; + best_move_score = score; } } }