
|
Home |
Mailing List |
Installation |
Uninstallation |
Extending |
Source Code |
Screenshots
|
Extending
Hints.
- For most lookups, you'll want the menu item enabled when there's a selection, disabled when there's none. When you add the menu item in the XUL file (found at <mozilla install dir>/chrome/qlookup/content/qlookup.xul), you should give the new item a unique id (e.g. qlookup-thes for a Thesaurus lookup), then add that id to the elementTags array in the javascript file (<mozilla install dir>/chrome/qlookup/content/qlookup.js).
- Mozilla uses ampersands in XUL files to indicate string resources (which are used for internationalization). If you have a ampersand in your URL, you must replace it with the HTML character code for an ampersand: & becomes &
A simple lookup.
Re-uses existing functionality, demonstrates html character code for ampersand.This code goes in qlookup.xul, found in <mozilla install dir>/chrome/qlookup/content/
<menuitem id="qlookup-thes" label="Lookup at thesaurus.com" oncommand="doLookup('http://www.thesaurus.com/cgi-bin/search?config=roget&words=')"/>
The 'qlookup-thes' id must be added to qlookup.js, found in <mozilla install dir>/chrome/qlookup/content/
var elementTags = new Array('qlookup-dict',
'qlookup-goog',
'qlookup-url',
'qlookup-thes');
An advanced lookup, inserting term in the middle of a URL.
Also features a popup dialog box if no-thing is selected. You would not want to disable this sort of item when no-thing is selected, since it has valid functionality in such a case.This code goes in qlookup.js, found in <mozilla install dir>/chrome/qlookup/content/
// ==============
function doGoogleAdvanced() {
var selection = getSelection();
if (selection.length < 1)
selection = prompt('Keywords...','');
if (selection.length < 1)
return;
urlPrefix = 'http://www.google.com/search?as_q=';
urlPostfix = '&num=100&hl=en&ie=ISO-8859-1&btnG=Google+Search&as_epq=&as_oq=&as_eq=&lr=&as_ft=i&as_filetype=&as_qdr=all&as_occt=any&as_dt=i&as_sitesearch=&safe=images';
doUrl(urlPrefix + selection + urlPostfix);
}
// ==============
This code goes in qlookup.xul, found in <mozilla install dir>/chrome/qlookup/content/
<menuitem id="qlookup-adv" label="Google Advanced" oncommand="doGoogleAdvanced()"/>