From 4ddea61846056ea45ac883c871d90a88da95d9a6 Mon Sep 17 00:00:00 2001 From: Tom Atkinson Date: Sat, 5 Oct 2019 00:40:36 +0200 Subject: [PATCH] Use onhashchange event instead of polling for hash changes Signed-off-by: Tom Atkinson --- js/config.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/js/config.js b/js/config.js index b8eb297b0f..c7c6c7a4d9 100644 --- a/js/config.js +++ b/js/config.js @@ -636,23 +636,18 @@ AJAX.registerOnload('config.js', function () { setupConfigTabs(); adjustPrefsNotification(); - // tab links handling, check each 200ms + // tab links handling // (works with history in FF, further browser support here would be an overkill) - var prevHash; - var tabCheckFnc = function () { - if (location.hash !== prevHash) { - prevHash = location.hash; - if (prevHash.match(/^#tab_[a-zA-Z0-9_]+$/)) { - // session ID is sometimes appended here - var hash = prevHash.substr(5).split('&')[0]; - if ($('#' + hash).length) { - setTab(hash); - } + window.onhashchange = function () { + if (location.hash.match(/^#tab_[a-zA-Z0-9_]+$/)) { + // session ID is sometimes appended here + var hash = location.hash.substr(5).split('&')[0]; + if ($('#' + hash).length) { + setTab(hash); } } }; - tabCheckFnc(); - setInterval(tabCheckFnc, 200); + window.onhashchange(); }); //