2 * Beagle Extension: Index webpages you visit using the Beagle Indexing Engine.
3 * An Extension for the Firefox (and Mozilla?) Browser.
6 // Initiate a new preference instance.
7 var gPref
= Components
.classes
['@mozilla.org/preferences-service;1'].getService(Components
.interfaces
.nsIPrefBranch
);
9 // Declare form variables.
11 'beagle.context.active',
12 'beagle.security.active',
13 'beagle.security.filters'
16 function beaglePrefsInit()
18 for( var i
= 0; i
< _elementIDs
.length
; i
++ )
20 var elementID
= _elementIDs
[i
];
21 var element
= document
.getElementById(elementID
);
27 else if (element
.localName
== 'checkbox')
29 try { element
.checked
= gPref
.getBoolPref(elementID
); }
30 catch(e
) { element
.checked
= false; }
32 else if (element
.localName
== 'radiogroup')
34 try { element
.selectedItem
= element
.childNodes
[gPref
.getIntPref(elementID
)]; }
35 catch(e
) { element
.selectedItem
= element
.childNodes
[0]; }
37 else if (element
.localName
== 'textbox')
39 if (element
.getAttribute('preftype') == 'int')
41 try { element
.value
= gPref
.getIntPref(elementID
); }
42 catch(e
) { element
.value
= 180; }
46 try { element
.value
= gPref
.getCharPref(elementID
); }
47 catch(e
) { element
.value
= ''; }
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()
72 for( var i
= 0; i
< _elementIDs
.length
; i
++ )
74 var elementID
= _elementIDs
[i
];
75 var element
= document
.getElementById(elementID
);
81 else if (element
.localName
== 'checkbox')
83 gPref
.setBoolPref(elementID
, element
.checked
);
85 else if (element
.localName
== 'radiogroup')
87 gPref
.setIntPref(elementID
, parseInt(element
.value
));
89 else if (element
.localName
== 'textbox')
91 if (element
.getAttribute('preftype') == 'int')
95 var sPref
= element
.value
.replace(/^[0]*/);
96 var sWork
= "0123456789";
98 for (var j
= 0; j
< sPref
.length
; j
++)
100 if (sWork
.indexOf(sPref
.charAt(j
)) == -1) bOkay
= false;
101 else cPref
= cPref
+ sPref
.charAt(j
);
104 if (cPref
.length
== 0 ) cPref
= '0';
105 var iPref
= parseInt(cPref
);
106 if (iPref
< 180) iPref
= 180;
107 gPref
.setIntPref(elementID
, iPref
);
111 gPref
.setCharPref(elementID
, element
.value
);
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;