]> git.sesse.net Git - remoteglot-book/commitdiff
Make move history clickable.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 14 Dec 2014 10:45:33 +0000 (11:45 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 14 Dec 2014 10:45:33 +0000 (11:45 +0100)
www/js/book.js

index 1f2ec371b7d2647635edc7c2036da09cc6dc4098..47e540e9a5c23535d90979662d5ca13e943ba6a8 100644 (file)
@@ -35,7 +35,7 @@ var update = function() {
                if (i == move_override) {
                        text += '<strong>' + history[i] + '</strong>';
                } else {
-                       text += history[i];
+                       text += '<a href="javascript:set_move(' + i + ')">' + history[i] + '</a>';
                }
                text += " ";
        }
@@ -258,6 +258,12 @@ var next_move = function() {
 }
 window['next_move'] = next_move;
 
+var set_move = function(n) {
+       move_override = n;
+       update();
+}
+window['set_move'] = set_move;
+
 // almost all of this stuff comes from the chessboard.js example page
 var onDragStart = function(source, piece, position, orientation) {
        var game = get_game();