From: Steinar H. Gunderson Date: Sat, 13 Dec 2014 23:08:50 +0000 (+0100) Subject: Rename the moves variable so it doesn't clash anymore. X-Git-Url: https://git.sesse.net/?p=remoteglot-book;a=commitdiff_plain;h=ef20c7b10b72bf9dbad4e2507e994b19229701ea;hp=4fa00c4fbfb86465b2d50bb0b5642f00c6b9329b Rename the moves variable so it doesn't clash anymore. --- diff --git a/www/js/book.js b/www/js/book.js index 0b1e437..d95b6e8 100644 --- a/www/js/book.js +++ b/www/js/book.js @@ -1,7 +1,7 @@ (function() { var board = null; -var moves = []; +var history = []; var move_override = 0; var entity_map = { @@ -21,7 +21,7 @@ function escape_html(string) { var get_game = function() { var game = new Chess(); for (var i = 0; i < move_override; ++i) { - game.move(moves[i]); + game.move(history[i]); } return game; } @@ -206,9 +206,9 @@ var show_lines = function(data, game) { } var make_move = function(move) { - moves.length = move_override; - moves.push(move); - move_override = moves.length; + history.length = move_override; + history.push(move); + move_override = history.length; update(); } window['make_move'] = make_move; @@ -222,7 +222,7 @@ var prev_move = function() { window['prev_move'] = prev_move; var next_move = function() { - if (move_override < moves.length) { + if (move_override < history.length) { ++move_override; update(); } @@ -251,8 +251,8 @@ var onDrop = function(source, target) { // illegal move if (move === null) return 'snapback'; - moves = game.history({ verbose: true }); - move_override = moves.length; + history = game.history({ verbose: true }); + move_override = history.length; }; // update the board position after the piece snap