From 6b412ffcd5797613037e4d69c39f8b4a3f0254f9 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Fri, 16 Nov 2018 12:46:53 +0100 Subject: [PATCH] Add pickup of games from old history. --- www/js/remoteglot.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index 4ff9d64..d89da33 100644 --- a/www/js/remoteglot.js +++ b/www/js/remoteglot.js @@ -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); -- 2.39.2