diff options
author | Jesús <heckyel@hyperbola.info> | 2019-12-30 15:55:13 -0500 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2019-12-30 15:55:13 -0500 |
commit | 288df6a7bf8b933e2dc499e38f4915fcf974c14b (patch) | |
tree | 77bba994f260c064d3ee7f76c427ddfaa4f91710 /js/start.js | |
parent | a2c9deaa145b780722e93b3899600f287c8094a4 (diff) | |
download | ematrix-288df6a7bf8b933e2dc499e38f4915fcf974c14b.tar.lz ematrix-288df6a7bf8b933e2dc499e38f4915fcf974c14b.tar.xz ematrix-288df6a7bf8b933e2dc499e38f4915fcf974c14b.zip |
backport
- Flush caches on upgrade
- Properly handle FrameModule's unloading
- Use the new module and remove the old implementation
Diffstat (limited to 'js/start.js')
-rw-r--r-- | js/start.js | 64 |
1 files changed, 22 insertions, 42 deletions
diff --git a/js/start.js b/js/start.js index 31a89d8..3a09551 100644 --- a/js/start.js +++ b/js/start.js @@ -25,33 +25,25 @@ // ORDER IS IMPORTANT -/******************************************************************************/ - // Load everything (function() { + let ηm = ηMatrix; - /******************************************************************************/ - - var ηm = ηMatrix; - - /******************************************************************************/ - - var processCallbackQueue = function(queue, callback) { - var processOne = function() { - var fn = queue.pop(); - if ( fn ) { + let processCallbackQueue = function (queue, callback) { + let processOne = function () { + let fn = queue.pop(); + if (fn) { fn(processOne); - } else if ( typeof callback === 'function' ) { + } else if (typeof callback === 'function') { callback(); } }; + processOne(); }; - /******************************************************************************/ - - var onAllDone = function() { + let onAllDone = function () { ηm.webRequest.start(); ηm.assets.addObserver(ηm.assetObserver.bind(ηm)); @@ -60,50 +52,38 @@ vAPI.cloud.start([ 'myRulesPane' ]); }; - /******************************************************************************/ - - var onTabsReady = function(tabs) { - var tab; - var i = tabs.length; - // console.debug('start.js > binding %d tabs', i); - while ( i-- ) { - tab = tabs[i]; + let onTabsReady = function (tabs) { + for (let i=tabs.length-1; i>=0; --i) { + // console.debug('start.js > binding %d tabs', i); + let tab = tabs[i]; ηm.tabContextManager.push(tab.id, tab.url, 'newURL'); } onAllDone(); }; - /******************************************************************************/ - - var onUserSettingsLoaded = function() { + let onUserSettingsLoaded = function () { ηm.loadHostsFiles(); }; - /******************************************************************************/ - - var onPSLReady = function() { + let onPSLReady = function () { ηm.loadUserSettings(onUserSettingsLoaded); ηm.loadRawSettings(); ηm.loadMatrix(); - // rhill 2013-11-24: bind behind-the-scene virtual tab/url manually, since the - // normal way forbid binding behind the scene tab. + // rhill 2013-11-24: bind behind-the-scene virtual tab/url + // manually, since the normal way forbid binding behind the + // scene tab. // https://github.com/gorhill/httpswitchboard/issues/67 - ηm.pageStores[vAPI.noTabId] = ηm.pageStoreFactory(ηm.tabContextManager.mustLookup(vAPI.noTabId)); - ηm.pageStores[vAPI.noTabId].title = vAPI.i18n('statsPageDetailedBehindTheScenePage'); + ηm.pageStores[vAPI.noTabId] = + ηm.pageStoreFactory(ηm.tabContextManager.mustLookup(vAPI.noTabId)); + ηm.pageStores[vAPI.noTabId].title = + vAPI.i18n('statsPageDetailedBehindTheScenePage'); vAPI.tabs.getAll(onTabsReady); }; - /******************************************************************************/ - - processCallbackQueue(ηm.onBeforeStartQueue, function() { + processCallbackQueue(ηm.onBeforeStartQueue, function () { ηm.loadPublicSuffixList(onPSLReady); }); - - /******************************************************************************/ - })(); - -/******************************************************************************/ |