2 * Beagle Extension: Index webpages you visit using the Beagle Indexing Engine.
\r
3 * An Extension for the Firefox (and Mozilla?) Browser.
\r
6 // Initiate a new preference instance.
\r
7 var gPref = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
\r
9 // Declare form variables.
\r
11 'beagle.context.active',
\r
12 'beagle.security.active',
\r
13 'beagle.security.filters'
16 function beaglePrefsInit()
\r
18 for( var i = 0; i < _elementIDs.length; i++ )
\r
20 var elementID = _elementIDs[i];
\r
21 var element = document.getElementById(elementID);
\r
27 else if (element.localName == 'checkbox')
\r
29 try { element.checked = gPref.getBoolPref(elementID); }
\r
30 catch(e) { element.checked = false; }
\r
32 else if (element.localName == 'radiogroup')
\r
34 try { element.selectedItem = element.childNodes[gPref.getIntPref(elementID)]; }
\r
35 catch(e) { element.selectedItem = element.childNodes[0]; }
\r
37 else if (element.localName == 'textbox')
\r
39 if (element.getAttribute('preftype') == 'int')
\r
41 try { element.value = gPref.getIntPref(elementID); }
\r
42 catch(e) { element.value = 180; }
\r
46 try { element.value = gPref.getCharPref(elementID); }
\r
47 catch(e) { element.value = ''; }
\r
50 else if (element.id == 'beagle.security.filters')
53 var val = gPref.getCharPref("beagle.security.filters");
54 var items = val.split(';');
55 var listbox = document.getElementById('beagle.security.filters');
57 for (var j = 0; j < items.length; j++){
59 var item = listbox.appendItem(items[j], items[j]);
63 // We don't seem to care about this.
70 function beaglePrefsSave()
\r
72 for( var i = 0; i < _elementIDs.length; i++ )
\r
74 var elementID = _elementIDs[i];
\r
75 var element = document.getElementById(elementID);
\r
81 else if (element.localName == 'checkbox')
\r
83 gPref.setBoolPref(elementID, element.checked);
\r
85 else if (element.localName == 'radiogroup')
\r
87 gPref.setIntPref(elementID, parseInt(element.value));
\r
89 else if (element.localName == 'textbox')
\r
91 if (element.getAttribute('preftype') == 'int')
\r
95 var sPref = element.value.replace(/^[0]*/);
\r
96 var sWork = "0123456789";
\r
98 for (var j = 0; j < sPref.length; j++)
\r
100 if (sWork.indexOf(sPref.charAt(j)) == -1) bOkay = false;
\r
101 else cPref = cPref + sPref.charAt(j);
\r
104 if (cPref.length == 0 ) cPref = '0';
\r
105 var iPref = parseInt(cPref);
\r
106 if (iPref < 180) iPref = 180;
\r
107 gPref.setIntPref(elementID, iPref);
\r
111 gPref.setCharPref(elementID, element.value);
\r
114 else if (element.id == 'beagle.security.filters')
117 for (var j = 0; j < element.getRowCount(); j++){
118 var listitem = element.getItemAtIndex(j);
119 val += listitem.value + ";";
121 gPref.setCharPref(element.id, val);
126 function beaglePrefsAddFilter() {
127 window.openDialog('chrome://beagle/content/beagleAddDomainDialog.xul', 'Add Domain', 'chrome, modal');
130 function beaglePrefsRemoveFilter() {
131 var listbox = document.getElementById('beagle.security.filters');
132 listbox.removeItemAt(listbox.selectedIndex);
135 function updateFilterAddButton() {
136 var button = document.getElementById('beagle.filter.add');
137 var filter = document.getElementById('beagle.filter');
139 if (filter.value != ''){
140 button.disabled = false;
142 button.disabled = true;
146 function updateFilterRemoveButton() {
147 var button = document.getElementById('beagle.filter.remove');
148 var listbox = document.getElementById('beagle.security.filters');
150 if (listbox.selectedCount > 0){
151 button.disabled = false;
153 button.disabled = true;