]> git.sesse.net Git - remoteglot/blobdiff - www/js/remoteglot.js
Include the score when showing other games.
[remoteglot] / www / js / remoteglot.js
index 04bc1493c9f37a51bf39d05208181b1bb000b7c4..b599ec8f2c50284b16f57b62bc389633920af6b4 100644 (file)
@@ -7,7 +7,7 @@
  * @type {Number}
  * @const
  * @private */
-var SCRIPT_VERSION = 2016032000;
+var SCRIPT_VERSION = 2016032200;
 
 /**
  * The current backend URL.
@@ -48,6 +48,7 @@ var displayed_analysis_data = null;
  *      name: string,
  *      url: string,
  *      id: string,
+ *      score: Object
  * }>}
  * @private
  */
@@ -822,7 +823,11 @@ var update_refutation_lines = function() {
                var depth_td = document.createElement("td");
                tr.appendChild(depth_td);
                $(depth_td).addClass("depth");
-               $(depth_td).text("d" + line['depth']);
+               if (line['depth'] && line['depth'] >= 0) {
+                       $(depth_td).text("d" + line['depth']);
+               } else {
+                       $(depth_td).text("—");
+               }
 
                var pv_td = document.createElement("td");
                tr.appendChild(pv_td);
@@ -891,6 +896,10 @@ var update_game_list = function(games) {
                        game_a.appendChild(game_name);
                        game_span.appendChild(game_a);
                }
+
+               var score = " (" + format_short_score(game['score']) + ")";
+               game_span.appendChild(document.createTextNode(score));
+
                games_div.appendChild(game_span);
        }
 }
@@ -908,7 +917,7 @@ var possibly_switch_game_from_hash = function() {
        for (var i = 0; i < current_games.length; ++i) {
                if (current_games[i]['id'] === hash) {
                        if (backend_url !== current_games[i]['url']) {
-                               switch_backend(current_games[i]['url']);
+                               switch_backend(current_games[i]['url'], current_games[i]['hashurl']);
                        }
                        return;
                }
@@ -1907,6 +1916,9 @@ var fmt_cp = function(v) {
 }
 
 var format_short_score = function(score) {
+       if (!score) {
+               return "???";
+       }
        if (score[0] === 'm') {
                if (score[2]) {  // Is a bound.
                        return score[2] + "\u00a0M" + pad(score[1], 3);
@@ -1992,7 +2004,7 @@ var compute_score_sort_key = function(score, invert) {
 /**
  * @param {string} new_backend_url
  */
-var switch_backend = function(new_backend_url) {
+var switch_backend = function(new_backend_url, new_backend_hash_url) {
        // Stop looking at historic data.
        current_display_line = null;
        current_display_move = null;
@@ -2022,6 +2034,7 @@ var switch_backend = function(new_backend_url) {
 
        // Request an immediate fetch with the new backend.
        backend_url = new_backend_url;
+       backend_hash_url = new_backend_hash_url;
        current_analysis_data = null;
        ims = 0;
        request_update();