X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=www%2Fjs%2Fbook.js;h=d95b6e8acdd6e3f1040b76d78ac80b05ed55c274;hb=ef20c7b10b72bf9dbad4e2507e994b19229701ea;hp=c54fb94e700d9a8e1338f8c9db38ebada169f20e;hpb=7948ff31ce0c53b85cccb9c851dbbf36d46f9c0c;p=remoteglot-book diff --git a/www/js/book.js b/www/js/book.js index c54fb94..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; } @@ -177,6 +177,10 @@ var show_lines = function(data, game) { var line = lines[i]; var tr = document.createElement("tr"); + if (line[0] === undefined || line[0] === null) { + $(tr).addClass("totals"); + } + for (var j = 0; j < line.length; ++j) { if (line[j] === null) { add_td(tr, ""); @@ -202,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; @@ -218,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(); } @@ -247,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