From bcae12d78459730f30039137cbdbe1cf8f490e5b Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 10 Nov 2014 21:20:55 +0100 Subject: [PATCH] Support promotion when displaying lines. --- www/js/remoteglot.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index 078aba6..bf43403 100644 --- a/www/js/remoteglot.js +++ b/www/js/remoteglot.js @@ -763,9 +763,18 @@ var update_displayed_line = function() { hiddenboard.position(current_display_line.start_fen, false); for (var i = 0; i <= current_display_move; ++i) { var move = current_display_line.uci_pv[i]; + var promo = move.substr(4, 1); move = move.substr(0, 2) + "-" + move.substr(2, 2); hiddenboard.move(move, false); + // Do promotion if needed. + if (promo != "") { + var pos = hiddenboard.position(); + var target = move.substr(3, 2); + pos[target] = pos[target].substr(0, 1) + promo.toUpperCase(); + hiddenboard.position(pos, false); + } + // chessboard.js does not automatically move the rook on castling // (issue #51; marked as won't fix), so update it ourselves. if (move == "e1-g1" && hiddenboard.position().g1 == "wK") { // white O-O -- 2.39.2