diff options
author | Kris Maglione <maglione.k@gmail.com> | 2008-12-18 18:21:01 -0500 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2008-12-18 18:21:01 -0500 |
commit | c094a2dd2b648a3e5717652d6e2439858e5e7108 (patch) | |
tree | d9560ba605ed4578678c1ddb9bcaec824999e79d /common/content/options.js | |
parent | ac0b476988cebdc9032a1a62b3668cd1b0f61fe0 (diff) | |
download | pentadactyl-c094a2dd2b648a3e5717652d6e2439858e5e7108.tar.gz |
Fix */#
Diffstat (limited to 'common/content/options.js')
-rw-r--r-- | common/content/options.js | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/common/content/options.js b/common/content/options.js index ed2887f5..460490bb 100644 --- a/common/content/options.js +++ b/common/content/options.js @@ -302,7 +302,9 @@ function Options() //{{{ const SAVED = "liberator.saved."; const prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); - var optionHash = {}; + const optionHash = {}; + + const prefContexts = []; function optionObserver(key, event, option) { @@ -320,6 +322,13 @@ function Options() //{{{ function storePreference(name, value) { + if (prefContexts.length) + { + let val = loadPreference(name, null); + if (val != null) + prefContexts[prefContexts.length - 1][name] = val; + } + var type = prefService.getPrefType(name); switch (typeof value) { @@ -988,7 +997,31 @@ function Options() //{{{ this.setPref(name, !this.getPref(name)); else liberator.echoerr("E488: Trailing characters: " + name + "!"); - } + }, + + pushContext: function () + { + prefContexts.push({}); + }, + + popContext: function () + { + for (let [k, v] in Iterator(prefContexts.pop())) + storePreference(k, v); + }, + + temporaryContext: function (fn, self) + { + try + { + this.pushContext(); + return fn.call(self); + } + finally + { + this.popContext(); + } + }, }; //}}} }; //}}} |