]> git.sesse.net Git - remoteglot/blobdiff - www/js/remoteglot.js
Fix an issue where the Previous link would wrongly reappear.
[remoteglot] / www / js / remoteglot.js
index 078aba6cdf674cda3840e2f16d4714b5c1ef7001..a5cdc232a61ce3a6cfa2b90508411b467b4e6202 100644 (file)
@@ -749,7 +749,7 @@ var update_displayed_line = function() {
        $("#linenav").show();
        $("#linemsg").hide();
 
-       if (current_display_move == 0) {
+       if (current_display_move <= 0) {
                $("#prevmove").html("Previous");
        } else {
                $("#prevmove").html("<a href=\"javascript:prev_move();\">Previous</a></span>");
@@ -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