]> git.sesse.net Git - remoteglot/blobdiff - www/js/remoteglot.js
Put the limit for showing seconds at 20 minutes instead of 10.
[remoteglot] / www / js / remoteglot.js
index 0748dcecef86a71cf14db1b15996a57eea853870..34e1863624ffdc7afd34a7913e54acd35bbc6028 100644 (file)
@@ -7,7 +7,7 @@
  * @type {Number}
  * @const
  * @private */
-var SCRIPT_VERSION = 2016091401;
+var SCRIPT_VERSION = 2016113002;
 
 /**
  * The current backend URL.
@@ -1060,10 +1060,20 @@ var update_board = function() {
                        headline += ' after ' + last_move;
                }
        } else if (data['position']['last_move'] !== 'none') {
+               // Find the previous move.
+               var previous_move_num, previous_toplay;
+               if (data['position']['toplay'] == 'B') {
+                       previous_move_num = data['position']['move_num'];
+                       previous_toplay = 'W';
+               } else {
+                       previous_move_num = data['position']['move_num'] - 1;
+                       previous_toplay = 'B';
+               }
+
                last_move = format_move_with_number(
                        data['position']['last_move'],
-                       data['position']['move_num'],
-                       data['position']['toplay'] == 'B');
+                       previous_move_num,
+                       previous_toplay == 'W');
                headline += ' after ' + last_move;
        } else {
                last_move = null;
@@ -1198,7 +1208,9 @@ var update_board = function() {
                for (var i = 1; i < alt_moves.length && i < 3; ++i) {
                        hiddenboard = new Chess(base_fen);
                        var move = hiddenboard.move(alt_moves[i]);
-                       create_arrow(move.from, move.to, '#f66', 1, 10);
+                       if (move !== null) {
+                               create_arrow(move.from, move.to, '#f66', 1, 10);
+                       }
                }
        }
 
@@ -1305,6 +1317,13 @@ var update_sparkline = function(data) {
                                        return format_tooltip(data, fields[0].offset + first_move_num - 1);
                                }
                        });
+                       $('#scorespark').bind('sparklineClick', function(event) {
+                               var sparkline = event.sparklines[0];
+                               var region = sparkline.getCurrentRegionFields();
+                               if (region[0].offset !== undefined) {
+                                       show_line(0, first_move_num + region[0].offset - 1);
+                               }
+                       });
                } else {
                        $("#scorespark").text("");
                }
@@ -1399,8 +1418,9 @@ var update_clock = function() {
                return;
        }
 
-       // If either player has ten minutes or less left, add the second counters.
-       var show_seconds = (white_clock_ms < 60 * 10 * 1000 || black_clock_ms < 60 * 10 * 1000);
+       // If either player has twenty minutes or less left, add the second counters.
+       // This matches what DGT clocks do.
+       var show_seconds = (white_clock_ms < 60 * 20 * 1000 || black_clock_ms < 60 * 20 * 1000);
 
        if (color) {
                // See when the clock will change next, and update right after that.