aboutsummaryrefslogtreecommitdiffstats
path: root/src/chrome/content/options/options.js
diff options
context:
space:
mode:
authorjmccrohan <jmccrohan@gmail.com>2011-04-06 15:29:05 +0100
committerjmccrohan <jmccrohan@gmail.com>2011-04-06 15:29:05 +0100
commit67810a8a0b08fc8697ee8fc8843af3757c12a421 (patch)
treeb9117ba19c4eff31666aa76010a69a9950623457 /src/chrome/content/options/options.js
parentf5d92fb14f7bfc5105700e60fb6fc35fb4e31401 (diff)
downloadMultiproxy-Switch-67810a8a0b08fc8697ee8fc8843af3757c12a421.tar.gz
Initial Commit
Diffstat (limited to '')
-rw-r--r--src/chrome/content/options/options.js80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/chrome/content/options/options.js b/src/chrome/content/options/options.js
new file mode 100644
index 0000000..ecd4ea9
--- /dev/null
+++ b/src/chrome/content/options/options.js
@@ -0,0 +1,80 @@
+
+var oMain = null;
+var inMozOptions = false;
+
+function initOptions(){
+ try{
+
+ //Prefs
+ var oPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");
+
+ //Get Opener
+ if(opener.mproxy_menuShowing){
+ oMain = opener;
+ }
+ else if(opener.parent.opener && opener.parent.opener.mproxy_menuShowing){
+ oMain = opener.parent.opener
+ inMozOptions = true;
+ }
+
+ //Prefill
+ if(oPrefs.prefHasUserValue("mproxy.clear.cookies"))
+ document.getElementById("mproxy.clear.cookies").checked = oPrefs.getBoolPref("mproxy.clear.cookies");
+ if(oPrefs.prefHasUserValue("mproxy.reload.tab"))
+ document.getElementById("mproxy.reload.tab").checked = oPrefs.getBoolPref("mproxy.reload.tab");
+ if(oPrefs.prefHasUserValue("mproxy.display.context"))
+ document.getElementById("mproxy.display.context").checked = oPrefs.getBoolPref("mproxy.display.context");
+ if(oPrefs.prefHasUserValue("mproxy.display.statusbar"))
+ document.getElementById("mproxy.display.statusbar").checked = oPrefs.getBoolPref("mproxy.display.statusbar");
+
+ /*if(oPrefs.prefHasUserValue("mproxy.tabs.manager"))
+ document.getElementById("mproxy.tabs.manager").checked = oPrefs.getBoolPref("mproxy.tabs.manager");*/
+
+ //Set menushowing options
+ if(oMain != null){
+ document.getElementById("mproxy.display.toolbar").checked = oMain.mproxy_menuShowing("toolbar");
+ }
+ else{
+ document.getElementById("mproxy.display.toolbar").style.display = "none";
+ }
+
+ // Thunderbird
+ if(navigator.userAgent.search(/Thunderbird/gi) > -1){
+ document.getElementById("mproxy.display.context").style.display = "none";
+ document.getElementById("mproxy.display.toolbar").style.display = "none";
+ }
+
+ }catch(err){ alert(mproxy_getString("error.unknown") +"\n"+ err); }
+}
+
+function saveOptions(){
+
+ try{
+
+ //Save
+ var oPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");
+
+ oPrefs.setBoolPref("mproxy.clear.cookies", document.getElementById("mproxy.clear.cookies").checked);
+ oPrefs.setBoolPref("mproxy.reload.tab", document.getElementById("mproxy.reload.tab").checked);
+ oPrefs.setBoolPref("mproxy.display.statusbar", document.getElementById("mproxy.display.statusbar").checked);
+
+ // Not Thunderbird
+ if(navigator.userAgent.search(/Thunderbird/gi) < 0){
+ oPrefs.setBoolPref("mproxy.display.context", document.getElementById("mproxy.display.context").checked);
+
+ if(oMain != null){
+ oPrefs.setBoolPref("mproxy.display.toolbar", document.getElementById("mproxy.display.toolbar").checked);
+ }
+ }
+
+
+ if(oMain != null)
+ oMain.mproxy_showMenus();
+
+ }catch(err){ alert(mproxy_getString("error.unknown") +"\n"+err); }
+
+ if(oMain != null && !inMozOptions)
+ oMain.focus();
+
+ return true;
+}