aboutsummaryrefslogtreecommitdiffstats
path: root/src/chrome/content/options/options.js
blob: ecd4ea971a67521fc5509203acbc5826c4a7209e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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;	
}