Back to Jargon File Resources Up to Site Map $Date: 2003/10/27 05:33:06 $

Search Jargoogle

Loading
The logo points to an Advanced search set up for Jargon search and is a good bookmark candidate, as well as this page itself. If you have Netscape or MSIE with JavaScript the following are probably better:

Browser buttons

Just drag the appropriate links onto your personal toolbar:

Google Search I'm feeling lucky
Netscape Jargoogle Lucky Jargoogle
MSIE Jargoogle Lucky Jargoogle

Some bugs in the javascript have been fixed (both browsers).

I'm told that these won't work on MSIE 6; I also think they won't work before Netscape 4 and MSIE 4. Try them and please report any failures (see email at bottom).

Can somebody explain to me why the same search (try `foo bar' (two words)) gives different results on Netscape and MSIE?


How does it work?

There is no magic to it; no search engine called Jargoogle was setup by me; it's just a convenient interface to Google hiding an additional restriction added to your request.

Google's feature used

Note: All my knowledge of Google's features is all acquired by expirement/guessing and might be inaccurate/incomplete/intrustable/incorrect.

Google claims:

The word "site" followed by a colon enables you to restrict your search to a specific site. To do this, use the "site:sampledomain.com" syntax in the Google search box.
I tried it and although it actually accepts only domain names, it gets accurate results when searching for a jargon term within jargon.meulie.net (that's the domain where the Jargon File resources page resides). For example searching for:
foobar site:jargon.meulie.net
results in:
http://jargon.meulie.net/jargoogle.html

as the first match, which is the Right Page.

Google CGI Interface for it

Note: I don't know CGI well; the terminology might differ from the accepted one.

Google has two CGI interfaces that provide same input for the search engine from different form inputs. The first is the simple search at `http://www.google.com/search?' and the second is the advanced search at `http://www.google.com/advanced_search?'.

Both searches accept two submit inputs: `btnG' for normal search and `btnI' for "I'm feeling lucky" searches. Only their presence matters; the values are ignored, which allows freedom in the button names (the value is taken from the button name which is not a great design decision IMHO). Hint: if nothing is found (press random keys for search text :), you will be able see the search string and URL actually with "I'm feeling lucky".

The simple search accepts the search request in one string as the `q' input. This is good enough for the JavaScript in the toolbar buttons, but not for the HTML from. The advanced search builds the search request from parts given in separate inputs. `as_q' acts as `q' in the simple search but it's combined with values from other input fields. In paticular if `as_sitesearch' is specified, it's value is prepended with ` site:' and concatenated onto the search string.

The Jargoogle search form is a cut-down version of Google Advanced search form. It includes only the main `as_q' field and a hidden `as_sitesearch' field set to `www.catb.org'

In the absence of either submit inputs the simple search defualt to regular (unlucky :-) Google search and the advanced search presents the adnvaced search page with the value of `as_q' parsed into the various boxes. That's used tby Google to switch from simple search to advanced search when you have already typed part of the search. I used it to make the Google logo point to the advance search page initialized with the domain restriction.

The toolbar buttons provided by Google also provide a `client' input with `googlet' value which seems to do nothing (I tried both ways). I left it in, guessing that they might be collecting statistics of toolbar button usage, and the Jargon version probably should be included.

The JavaScript buttons dissected

These are simple extensions of the buttons provided by Google, at the sofistication level of a script kiddie (select the previous 2 words and press the Lucky Jargoogle button, see meaning 2 :-). The description provides my understanding of the code, as I [want to] know nothing about JavaScript. You might be better off just reading the code in the page source - the same holds for the above explanations about CGI.

The buttons are links whose URL begins with `javascript:'. It is followed by the javascript code, on one line, URL encoded and without spaces. I have removed URL encoding, added spacing and indentation here so that you can read it. Ignore the indentation style if you dislike it.

The first thing that is done is to try to get the selection to simplify search of a jargon term appearing on some web site. This is (of course) not portable accross browsers, especially contsidering that we have to check for the selection in every frame:

Netscape:
q = document.getSelection();
for(i = 0; i < frames.length; i++) {
   q = frames[i].document.getSelection();
   if(q)
      break;
}
MSIE:
q = (document.frames.length ? '' : document.selection.createRange().text);
for(i = 0; i < document.frames.length; i++)
{
   q = document.frames[i].document.selection.createRange().text;
   if(q != '')
      break;
}

The second thing to do is to prompt for the search string if no selection was found. This code could be portable if the check was - I haven't tried to make it the same on both browsers (lazyness...) but if it's a real difference it might result from the above Netscape code giving 0 or null vs. the MSIE code giving an empty string if no selection is found. The string split for readability by me:

Netscape:
if(!q)
   void(q = prompt('Enter text to search using Google. You can also highlight ' +
                   'a word on this web page before clicking Google Search.', ''));
MSIE:
if(q == '')
   void(q = prompt('Enter text to search using Google. You can also highlight ' +
                   'a word on this web page before clicking Google Search.', ''));

The last thing left to do is to create the URL unless "Cancel" was pressed. (Loading seems to be automagically triggered by the change of the current location). At least this is portable. Even the check is, probably because prompt() returns 0 or null if "Cancel" is pressed in both browsers.

if(q)
   location.href = 'http://www.google.com/search?client=googlet&q=' +
                   escape(q) +
                   '+site:jargon.meulie.net'

Of course no closing semicolon is needed as this is the last statement. It's known that all C-inspired languages use Pascal syntax ;-).

If you want to have an "I'm feeling lucky" search, just add the `btnI' input:

if(q)
   location.href = 'http://www.google.com/search?client=googlet&btnI=Im+Feeling+Lucky&q=' +
                   escape(q) +
                   '+site:jargon.meulie.net'

Now you just have to combine these together.


Back to Jargon File Resources Up to Site Map $Date: 2003/10/27 05:33:06 $

The "research" was performed and documented in this page by Beni Cherniavsky. Please email with any corrections/improvements you have.