]> git.sesse.net Git - remoteglot/blobdiff - www/js/remoteglot.js
Add a 50-move counter.
[remoteglot] / www / js / remoteglot.js
index 2ba3fe95248401613e28c4498dbdcf1ba1c0f6a7..be95b1a8449a1d4e8f86e442692a10eeea94f638 100644 (file)
@@ -754,7 +754,6 @@ var update_history = function() {
                        '(<a class="move" href="javascript:collapse_history(true)">collapse</a>) ' +
                        print_pv(0));
        }
-       update_move_highlight();
 }
 
 /**
@@ -1340,6 +1339,7 @@ var update_sparkline = function(data) {
                        }
                        // FIXME: at some widths, calling sparkline() seems to push
                        // #scorecontainer under the board.
+                       $('#scorespark').unbind('sparklineClick');
                        $("#scorespark").sparkline(scores, {
                                type: 'bar',
                                zeroColor: 'gray',
@@ -1351,6 +1351,7 @@ var update_sparkline = function(data) {
                                        return format_tooltip(data, fields[0].offset + first_move_num - 1);
                                }
                        });
+                       $('#scorespark').unbind('sparklineClick');
                        $('#scorespark').bind('sparklineClick', function(event) {
                                var sparkline = event.sparklines[0];
                                var region = sparkline.getCurrentRegionFields();
@@ -1370,13 +1371,22 @@ var update_sparkline = function(data) {
  * @param {number} num_viewers
  */
 var update_num_viewers = function(num_viewers) {
+       var text = "";
        if (num_viewers === null) {
-               $("#numviewers").text("");
+               text = "";
        } else if (num_viewers == 1) {
-               $("#numviewers").text("You are the only current viewer");
+               text = "You are the only current viewer";
        } else {
-               $("#numviewers").text(num_viewers + " current viewers");
+               text = num_viewers + " current viewers";
+       }
+       if (display_fen !== null) {
+               var counter = Math.floor(display_fen.split(" ")[4] / 2);
+               if (counter >= 20) {
+                       text = text.replace("current ", "");
+                       text += " | 50-move rule: " + counter;
+               }
        }
+       $("#numviewers").text(text);
 }
 
 var update_clock = function() {