My favorite feature of dqsd is the mwd popup feature when mapped to the
postfix operator :.  It's small, handy and unobtrusive.  It's important to
me that a simple definition lookup doesn't switch context from what I want
to be doing, that it not bring up a browser window.  I've mentioned it
before here:

That feature is broken yet again, and not worth fixing anymore.  MWD's
changed the format of their page so much I've given up trying to make mwd
work anymore.  They'll just break it again.  So here's a replacement
search.  It's called "df", short for definition.  Here's how I use it.  I


to localaliases.txt, and now when I need the definition of a word, I type
the word with a colon, and the definition pops up in a little window in the

Please note:  I don't know any JavaScript, XML, CSS, HTML or web servicey
stuff.  I only did this because it was too useful a feature not to have.
Nothing would delight me more than somebody who knows what they're doing
taking it over and cleaning it up.


PS.  If anybody does look at the code, you'll see that I only look for
definitions in at most two dictionaries.  My selection was based on
experimentation and is quite arbitrary.  I wrote the search for me, after
all.  But it'd be great to make that customizable, or when a word is
misspelled, to attempt a Match from
with a strategy from
That'd be nice.

PPS.  There are probably glaring problems with the submitted file.  I
apologize in advance.  It was only tested on my Windows Vista machine with
launchmode=1, and my default browser is Firefox.  Please, go ahead and fix
it so it works for you, too.
<search function="df">
  <name>DictService from Aonaware</name>
    Search for word definitions.  Recommended it is used with ":|df" in localaliases.txt, so that "word:" brings up its definition.
    <div class="helpboxDescLabels">Switches:</div>
    <div class="helpboxDescLabels">Examples:</div>
    <table class="helpboxDescTable">
      <tr><td>df idempotent</td></tr>
  <form name="dff"
    <input type="hidden" name="book" value="Dictionary"/>
    <input type="hidden" name="va"/>
    function df(q)
      var dicts = ["foldoc","gcide"];
      var definitions;
        var xmlHttp = new ActiveXObject("Microsoft.XmlHttp");
        for( var d in dicts ) {
"GET", ""; + dicts[d] + "&word=" + q, false);
          var xmlDoc = xmlHttp.responseXML.documentElement;
          definitions = xmlDoc.getElementsByTagName("WordDefinition")          
          if( definitions.length > 0 )
      catch ( e )
        alert( "Exception thrown: " + e.description );
      var windowW = 500;

      if ( definitions.length > 0 ) {
          var html = '<p><b>' + q + '</b></p>';
          for( var i=0; i < definitions.length; i++ ) {
            html += '<p>' + definitions[i].text + '</p>';
          var html = '<center><b>' + q + '</b> not found</center><br/>';
          alert( html );

      if ( typeof dictPopup == 'undefined' )
        dictPopup = window.createPopup();
      var dictPopupBody = dictPopup.document.body;

      // Let's concat on a local variable first for easier debugging - let's also copy over a couple of styles from linked "entry.css"
      var dictPopupBodyInnerHTML = '<table id=dfTable style="font-size: 70%; border: inset 2px" height="100%" width="100%"><style type="text/css">img { border-width: 0 } .variant { font-weight: bold; } .verb_class { display: block; } .unicode{font-family:"Lucida Sans Unicode";}</style><tr><td style="padding: 5px 20px 5px 5px">' + html + "</td></tr></table>";

      // This assignment will reformat the HTML extensively
      dictPopupBody.innerHTML = dictPopupBodyInnerHTML;"outset 2px";"1px 1px; background: navy";'menu';'auto';'Verdana';

      // Temporarily show the popup to determine the proper final height for the popup., 0, windowW, 0);
      var windowH = dictPopupBody.scrollHeight + 6;
      dictPopup.hide(); = windowW - 5;
      windowH = windowH > window.screen.height/2 ? window.screen.height/2 : windowH;
      dictPopup_x = (buttonalign == "left" ? 0 : document.body.clientWidth - windowW);
      dictPopup_y = -windowH;
      dictPopup_width = windowW;
      dictPopup_height = windowH;
      if ( typeof dictPopup_ring == 'undefined' )
        dictPopup_ring = new Array();
      dictPopup_ring.push( { x:dictPopup_x, y:dictPopup_y, width:dictPopup_width, height:dictPopup_height, html:dictPopupBody.innerHTML } );
      dictPopup_sp = dictPopup_ring.length - 1;, dictPopup_y, dictPopup_width, dictPopup_height, document.body);
    function dfCopySelection()
      dictPopup.document.execCommand( "Copy" );
    function dfGoToWord(w)
      if ( dictPopup.document.selection.type == "Text" )
  Copyright (c) 2009 David Blume
  Distributed under the terms of the
  GNU Public License, Version 2 (
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3.
To unsubscribe visit:

Reply via email to