From 54a17f303e9ba559f3c9ca872f2077b34bf0033d Mon Sep 17 00:00:00 2001 From: ketmar Date: Wed, 12 Aug 2015 01:00:00 +0000 Subject: [PATCH] universal preferences engine FossilOrigin-Name: 1240fc3bc930e49db005f0556f34feb509c263b30f6df7a7a9c8ead62d04f096 --- chrome/guerilla-overlay.js | 11 ++++---- chrome/guerilla-overlay.xul | 30 ++++++++++---------- main/init.js | 20 +++++++------ main/main.js | 2 +- main/prefs/prefs.js | 35 +++++++++++++++++++++++ main/{prefs.js => prefsengine.js} | 59 +++++++++++---------------------------- 6 files changed, 85 insertions(+), 72 deletions(-) rewrite chrome/guerilla-overlay.xul (68%) create mode 100644 main/prefs/prefs.js rename main/{prefs.js => prefsengine.js} (77%) diff --git a/chrome/guerilla-overlay.js b/chrome/guerilla-overlay.js index cae3548..ce51cfc 100644 --- a/chrome/guerilla-overlay.js +++ b/chrome/guerilla-overlay.js @@ -10,10 +10,10 @@ //////////////////////////////////////////////////////////////////////////////// // all our code will live in this nice closure (function (global) { - window.addEventListener("load", function () { - const {utils:Cu, classes:Cc, interfaces:Ci, results:Cr} = Components; + global.window.addEventListener("load", function () { + const {utils:Cu, classes:Cc, interfaces:Ci, results:Cr} = global.Components; - // load "main/init.js" + // load "mainjs:init.js" let uri = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService).newURI("chrome://guerilla-script-jscode/content/init.js", null, null); let initfn = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader).loadSubScript(uri.spec, this, "UTF-8"); try { @@ -24,11 +24,12 @@ ); if (!addonobj) return; // alas, something is wrong // add "isBootstrapped" flag - //const isBootstrapped = ("__SCRIPT_URI_SPEC__" in this); addonobj.defProp("isBootstrapped", {get: function () false}); // add more URLs addonobj.defProp("gsdoxURL", {get: function () "chrome://guerilla-script-dox/content/"}); - window.addEventListener("unload", function () { addonobj.onShutdown(); }, false); + // setup shutdown hook + global.window.addEventListener("unload", function () { addonobj.onShutdown(); }, false); + // initialize subsystems addonobj.onStartup(); } catch (e) { Components.utils.reportError(e.stack); diff --git a/chrome/guerilla-overlay.xul b/chrome/guerilla-overlay.xul dissimilarity index 68% index e8d1775..f1a0539 100644 --- a/chrome/guerilla-overlay.xul +++ b/chrome/guerilla-overlay.xul @@ -1,16 +1,14 @@ - - - -