Re: mozilla extension suggestion
- From: Tom von Schwerdtner <tomvons gmail com>
- To: Joe Shaw <joeshaw novell com>
- Cc: dashboard-hackers gnome org
- Subject: Re: mozilla extension suggestion
- Date: Wed, 26 Jan 2005 23:15:43 -0500
Patch attached:
* Adds preferences and functionality to filter based on host (eg,
'www.google.com' or 'localhost'). This checks page.location.host
only, so it can not distinguish between ports.
* Removed what looked like old and obsolete preferences (placement of
menu separator stuff that was commented out anyways).
* Changed the UI to what seems like more appropriate XUL.
It could be improved, but it seems to accomplish what I was looking for.
Criticisms are welcome. I've never played with XUL before so be gentle.
Regards,
Tom
On Wed, 26 Jan 2005 15:24:47 -0500, Joe Shaw <joeshaw novell com> wrote:
> On Wed, 2005-01-26 at 13:23 -0500, Tom von Schwerdtner wrote:
> > I've been looking for an excuse to play with mozilla extensions
> > though, if I can wedge up some time I'll have a poke and see if I can
> > add this option (unless someone is vehemently opposed).
>
> Please feel free! The mozilla extension at this point hasn't seen any
> development in a while. (Although it should still work fine)
>
> Joe
>
>
--
Tom von Schwerdtner
Etria, LLP :: http://etria.com/
Baltimore, MD
? mozilla-extension.patch
? content/.beaglePrefs.xul.swp
Index: install.rdf
===================================================================
RCS file: /cvs/gnome/beagle/mozilla-extension/install.rdf,v
retrieving revision 1.3
diff -u -b -r1.3 install.rdf
--- install.rdf 17 Sep 2004 16:34:06 -0000 1.3
+++ install.rdf 27 Jan 2005 04:06:57 -0000
@@ -7,7 +7,7 @@
<em:id>{fda00e13-8c62-4f63-9d19-d168115b11ca}</em:id>
<em:name>Beagle Indexer</em:name>
- <em:version>0.1</em:version>
+ <em:version>0.2</em:version>
<em:description>
Index webpages you visit using Beagle.
</em:description>
Index: content/beagleOverlay.js
===================================================================
RCS file: /cvs/gnome/beagle/mozilla-extension/content/beagleOverlay.js,v
retrieving revision 1.3
diff -u -b -r1.3 beagleOverlay.js
--- content/beagleOverlay.js 7 Oct 2004 23:52:48 -0000 1.3
+++ content/beagleOverlay.js 27 Jan 2005 04:06:57 -0000
@@ -120,6 +120,21 @@
return false;
}
+ try {
+ fPref = gPref.getCharPref('beagle.security.filters');
+ var filtered = fPref.split(';');
+ for (j = 0; j < filtered.length; j++){
+ if (filtered[j] == page.location.host){
+ dump("beagleShouldIndex: filtered host: " + page.location.host + '\n');
+ gBeagleRunStatus = -2;
+ beagleUpdateStatus ();
+ return false;
+ }
+ }
+ } catch (e) {
+ // Do nothing..
+ }
+
if (page.location.protocol == "https:") {
var bPref;
Index: content/beaglePrefs.js
===================================================================
RCS file: /cvs/gnome/beagle/mozilla-extension/content/beaglePrefs.js,v
retrieving revision 1.2
diff -u -b -r1.2 beaglePrefs.js
--- content/beaglePrefs.js 28 Jul 2004 10:25:33 -0000 1.2
+++ content/beaglePrefs.js 27 Jan 2005 04:06:57 -0000
@@ -9,21 +9,10 @@
// Declare form variables.
var _elementIDs = [
'beagle.context.active',
- 'beagle.context.sep.a',
- 'beagle.context.sep.b',
'beagle.security.active',
+ 'beagle.security.filters'
];
-function beaglePrefsFlip()
-{
- // Handle enabling/disabling prefs based on settings
- /*
- var bPref = document.getElementById('beagle.context.active').checked;
- document.getElementById('beagle.context.sep.a').disabled = !(bPref);
- document.getElementById('beagle.context.sep.b').disabled = !(bPref);
- */
-}
-
function beaglePrefsInit()
{
for( var i = 0; i < _elementIDs.length; i++ )
@@ -58,9 +47,22 @@
catch(e) { element.value = ''; }
}
}
+ else if (element.id == 'beagle.security.filters')
+ {
+ try {
+ var val = gPref.getCharPref("beagle.security.filters");
+ var items = val.split(';');
+ var listbox = document.getElementById('beagle.security.filters');
+
+ for (i = 0; i < items.length; i++){
+ if(items[i] != ''){
+ listbox.appendItem(items[i], items[i]);
+ }
+ }
+ } catch(e) { }
+ }
}
- beaglePrefsFlip();
}
function beaglePrefsSave()
@@ -107,7 +109,26 @@
gPref.setCharPref(elementID, element.value);
}
}
+ else if (element.id == 'beagle.security.filters')
+ {
+ var val = "";
+ for (j = 0; j < element.getRowCount(); j++){
+ var listitem = element.getItemAtIndex(j);
+ val += listitem.value + ";";
+ }
+ gPref.setCharPref(element.id, val);
+ }
}
+}
+
+function beaglePrefsAddFilter() {
+ var filter = document.getElementById('beagle.filter');
+ var listbox = document.getElementById('beagle.security.filters');
+ listbox.appendItem(filter.value, filter.value);
+ filter.value = '';
+}
- beaglePrefsFlip();
+function beaglePrefsRemoveFilter() {
+ var listbox = document.getElementById('beagle.security.filters');
+ listbox.removeItemAt(listbox.selectedIndex);
}
Index: content/beaglePrefs.xul
===================================================================
RCS file: /cvs/gnome/beagle/mozilla-extension/content/beaglePrefs.xul,v
retrieving revision 1.2
diff -u -b -r1.2 beaglePrefs.xul
--- content/beaglePrefs.xul 28 Jul 2004 10:25:33 -0000 1.2
+++ content/beaglePrefs.xul 27 Jan 2005 04:06:57 -0000
@@ -13,11 +13,13 @@
title="&beagle.pref.label;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
- <script type="application/x-javascript" src="chrome://beagle/content/beaglePrefs.js" />
+ <script type="application/x-javascript"
+ src="chrome://beagle/content/beaglePrefs.js" />
- <groupbox>
- <caption label="&beagle.pref.label;" />
+ <dialogheader title="&beagle.pref.label;"/>
+ <groupbox>
+ <caption label="General" />
<checkbox
id="beagle.context.active"
label="&beagle.pref.context.active.label;"
@@ -27,24 +29,6 @@
type="checkbox"
/>
-<!-- showing options for separators is hella lame -->
-<!--
- <checkbox id="beagle.context.sep.a"
- class="indent"
- label="&beagle.pref.context.sep.a.label;"
- prefattribute="checked"
- preftype="bool"
- type="checkbox"
- />
- <checkbox id="beagle.context.sep.b"
- class="indent"
- label="&beagle.pref.context.sep.b.label;"
- prefattribute="checked"
- preftype="bool"
- type="checkbox"
- />
--->
-
<checkbox
id="beagle.security.active"
label="&beagle.pref.security.active.label;"
@@ -52,7 +36,23 @@
preftype="bool"
type="checkbox"
/>
+ </groupbox>
+
+ <groupbox>
+ <caption label="&beagle.pref.filter.label;" />
+ <label control="host-filter" value="&beagle.pref.filter.host.label;"/>
+ <textbox id="beagle.filter"/>
+ <button id="beagle.filter.add"
+ label="&beagle.pref.filter.host.add.label;"
+ oncommand="beaglePrefsAddFilter();"/>
+
+ <listbox id="beagle.security.filters">
+ </listbox>
+
+ <button id="beagle.filter.remove"
+ label="&beagle.pref.filter.host.remove.label;"
+ oncommand="beaglePrefsRemoveFilter();"/>
</groupbox>
</dialog>
Index: locale/en-US/beagle.dtd
===================================================================
RCS file: /cvs/gnome/beagle/mozilla-extension/locale/en-US/beagle.dtd,v
retrieving revision 1.2
diff -u -b -r1.2 beagle.dtd
--- locale/en-US/beagle.dtd 28 Jul 2004 10:25:34 -0000 1.2
+++ locale/en-US/beagle.dtd 27 Jan 2005 04:06:58 -0000
@@ -6,6 +6,8 @@
<!ENTITY beagle.pref.label "Beagle Preferences">
<!ENTITY beagle.pref.context.label "Context Menu Options">
<!ENTITY beagle.pref.context.active.label "Add Beagle options to context menu">
-<!ENTITY beagle.pref.context.sep.a.label "Insert a Separator Before Context Items">
-<!ENTITY beagle.pref.context.sep.b.label "Insert a Separator After Context Items">
<!ENTITY beagle.pref.security.active.label "Index pages with secure content">
+<!ENTITY beagle.pref.filter.label "Filtering">
+<!ENTITY beagle.pref.filter.host.label "Hostname">
+<!ENTITY beagle.pref.filter.host.add.label "Add Host">
+<!ENTITY beagle.pref.filter.host.remove.label "Remove Host">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]