]> git.sesse.net Git - remoteglot/blobdiff - www/js/remoteglot.js
Add support for switching /hash backends when switching regular backends at the same...
[remoteglot] / www / js / remoteglot.js
index cff91cee612020e1a4aac339973104fa7323105f..bff8e9cd75aac0691bd9c95acbefbc36977a23d6 100644 (file)
@@ -822,7 +822,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);
@@ -908,7 +912,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;
                }
@@ -1866,7 +1870,7 @@ var onSnapEnd = function(source, target) {
 
        if (current_display_line &&
            current_display_move < current_display_line.pretty_pv.length - 1 &&
-           current_display_line.pretty_pv[current_display_move] === move.san) {
+           current_display_line.pretty_pv[current_display_move + 1] === move.san) {
                next_move();
                return;
        }
@@ -1907,6 +1911,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 +1999,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 +2029,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();