X-Git-Url: https://git.sesse.net/?p=remoteglot;a=blobdiff_plain;f=www%2Fjs%2Fremoteglot.js;h=8df6085e9355ac55a92efc0c28ba56c65e787579;hp=43b2e1ddbb7c304b2450349fbaef79e23e355d92;hb=f47758f678c7343382e835b8cd8e2c420500936d;hpb=d39bafd9fb4cc0725786ab815bf7dd5fb03ef15e diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index 43b2e1d..8df6085 100644 --- a/www/js/remoteglot.js +++ b/www/js/remoteglot.js @@ -692,10 +692,9 @@ var update_board = function(current_data, display_data) { if (display_data) { // Displaying some non-current position, pick out the last move // from the history. This will work even if the fetch failed. - last_move = format_move_with_number( + last_move = format_halfmove_with_number( current_display_line.pretty_pv[current_display_move], - Math.floor((current_display_move + 1) / 2) + 1, - (current_display_move % 2 == 1)); + current_display_move + 1); headline += ' after ' + last_move; } else if (data['position']['last_move'] !== 'none') { last_move = format_move_with_number( @@ -1011,6 +1010,17 @@ var format_move_with_number = function(move, move_num, white_to_play) { return ret; } +/** + * @param {string} move + * @param {Number} halfmove_num + */ +var format_halfmove_with_number = function(move, halfmove_num) { + return format_move_with_number( + move, + Math.floor(halfmove_num / 2) + 1, + halfmove_num % 2 == 0); +} + /** * @param {boolean} sort_by_score */