From b41084f89311bcd25493642953eb675432e2bb63 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 20 Mar 2016 12:02:19 +0100 Subject: [PATCH 1/1] Split off move highlighting updates. --- www/js/remoteglot.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index b2b80eb..33ae193 100644 --- a/www/js/remoteglot.js +++ b/www/js/remoteglot.js @@ -942,6 +942,7 @@ var update_board = function(current_data, display_data) { update_refutation_lines(); clear_arrows(); update_displayed_line(); + update_move_highlight(); return; } @@ -976,6 +977,7 @@ var update_board = function(current_data, display_data) { // Update the board itself. fen = data['position']['fen']; update_displayed_line(); + update_move_highlight(); // Print the PV. $("#pv").html(add_pv(data['position']['fen'], data['pv_pretty'], data['position']['move_num'], data['position']['toplay'])); @@ -1353,6 +1355,7 @@ var prev_move = function() { } update_historic_analysis(); update_displayed_line(); + update_move_highlight(); } window['prev_move'] = prev_move; @@ -1362,6 +1365,7 @@ var next_move = function() { } update_historic_analysis(); update_displayed_line(); + update_move_highlight(); } window['next_move'] = next_move; @@ -1430,10 +1434,19 @@ var update_imbalance = function(fen) { $('#blackimbalance').html(black_imbalance); } -var update_displayed_line = function() { +/** Mark the currently selected move in red. + */ +var update_move_highlight = function() { if (highlighted_move !== null) { highlighted_move.removeClass('highlight'); } + if (current_display_line !== null) { + highlighted_move = $("#automove" + current_display_line.line_number + "-" + current_display_move); + highlighted_move.addClass('highlight'); + } +} + +var update_displayed_line = function() { if (current_display_line === null) { $("#linenav").hide(); $("#linemsg").show(); @@ -1456,9 +1469,6 @@ var update_displayed_line = function() { $("#nextmove").html("Next"); } - highlighted_move = $("#automove" + current_display_line.line_number + "-" + current_display_move); - highlighted_move.addClass('highlight'); - var hiddenboard = chess_from(current_display_line.start_fen, current_display_line.pretty_pv, current_display_move); board.position(hiddenboard.fen()); update_imbalance(hiddenboard.fen()); -- 2.39.2