Skip to content

Commit

Permalink
Use onhashchange event instead of polling for hash changes
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Atkinson <atkinson.tommy@nsoft.com>
  • Loading branch information
Nibbler999 committed Oct 4, 2019
1 parent 5cc6709 commit 4ddea61
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions js/config.js
Expand Up @@ -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();
});

//
Expand Down

0 comments on commit 4ddea61

Please sign in to comment.