Add pickup of games from old history.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 16 Nov 2018 11:46:53 +0000 (12:46 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 16 Nov 2018 11:46:53 +0000 (12:46 +0100)
www/js/remoteglot.js

index 4ff9d64..d89da33 100644 (file)
@@ -298,7 +298,9 @@ var request_update = function() {
                }
 
                // Next update.
-               current_analysis_request_timer = setTimeout(function() { request_update(); }, timeout);
+               if (!backend_url.match(/history/)) {
+                       current_analysis_request_timer = setTimeout(function() { request_update(); }, timeout);
+               }
        }).fail(function(jqXHR, textStatus, errorThrown) {
                if (textStatus === "abort") {
                        // Aborted because we are switching backends. Abandon and don't retry,
@@ -938,6 +940,18 @@ var update_game_list = function(games) {
  * and switch to it if we're not already displaying it.
  */
 var possibly_switch_game_from_hash = function() {
+       var history_match = window.location.hash.match(/^#history=([a-zA-Z0-9_-]+)/);
+       if (history_match !== null) {
+               var game_id = history_match[1];
+               var fake_game = {
+                       url: '/history/' + game_id + '.json',
+                       hashurl: '',
+                       id: 'history=' + game_id
+               };
+               switch_backend(fake_game);
+               return;
+       }
+
        if (current_games === null) {
                return;
        }
@@ -2241,6 +2255,7 @@ var init = function() {
                }
        });
        window.addEventListener('hashchange', possibly_switch_game_from_hash, false);
+       possibly_switch_game_from_hash();
 };
 $(document).ready(init);