X-Git-Url: https://git.sesse.net/?p=remoteglot;a=blobdiff_plain;f=www%2Fjs%2Fremoteglot.js;h=c103716d52bd7aaa314c5fb360f27ba2601a5e63;hp=cb38ebe91e5ea6413a236277effd25475e1d30c4;hb=0966daf10b49c2d42bb5689a1d34a4e125144f48;hpb=62c6bbdc00af3ddd63cdba48f53711fb4214f32c
diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js
index cb38ebe..c103716 100644
--- a/www/js/remoteglot.js
+++ b/www/js/remoteglot.js
@@ -377,8 +377,9 @@ var thousands = function(x) {
* @param {number} move_num
* @param {!string} toplay
* @param {number=} opt_limit
+ * @param {boolean=} opt_showlast
*/
-var print_pv = function(fen, uci_pv, pretty_pv, move_num, toplay, opt_limit) {
+var print_pv = function(fen, uci_pv, pretty_pv, move_num, toplay, opt_limit, opt_showlast) {
display_lines.push({
start_fen: fen,
uci_pv: uci_pv,
@@ -387,7 +388,16 @@ var print_pv = function(fen, uci_pv, pretty_pv, move_num, toplay, opt_limit) {
var pv = '';
var i = 0;
- if (toplay == 'B') {
+ if (opt_limit && opt_showlast) {
+ // Truncate the PV at the beginning (instead of at the end).
+ // We assume here that toplay is 'W'.
+ pv = '(â¦) ';
+ i = pretty_pv.length - opt_limit;
+ if (i % 2 == 1) {
+ ++i;
+ }
+ move_num += i / 2;
+ } else if (toplay == 'B') {
var move = "" + pretty_pv[0] + "";
pv = move_num + '. ⦠' + move;
toplay = 'W';
@@ -398,7 +408,7 @@ var print_pv = function(fen, uci_pv, pretty_pv, move_num, toplay, opt_limit) {
var move = "" + pretty_pv[i] + "";
if (toplay == 'W') {
- if (i > opt_limit) {
+ if (i > opt_limit && !opt_showlast) {
return pv + ' (â¦)';
}
if (pv != '') {
@@ -557,6 +567,13 @@ var update_board = function(data, num_viewers) {
}
update_highlight();
+ // Print the history.
+ if (data['position']['history']) {
+ $("#history").html(print_pv('start', data['position']['history'], data['position']['pretty_history'], 1, 'W', 8, true));
+ } else {
+ $("#history").html("No history");
+ }
+
// Print the PV.
$("#pv").html(print_pv(data['position']['fen'], data['pv_uci'], data['pv_pretty'], data['position']['move_num'], data['position']['toplay']));
@@ -651,7 +668,7 @@ var show_line = function(line_num, move_num) {
window['show_line'] = show_line;
var prev_move = function() {
- if (current_display_move > 0) {
+ if (current_display_move > -1) {
--current_display_move;
}
update_displayed_line();