Re: [DQSD-Users] df for word definitions (take 2)

2009-05-02 Thread David Blume
Thanks, Kim,

For anybody who's interested, there's a screenshot of the new search in
action here:

http://dblume.livejournal.com/126591.html

I won't take offense if anybody takes ownership of it and improves it.  :)

--David

On Sat, May 2, 2009 at 1:02 PM, Kim Gräsman kim.gras...@gmail.com wrote:

 Thanks David!

 Committed, and will be part of the next release.

 - Kim

 On Sat, May 2, 2009 at 06:58, David Blume david.bl...@gmail.com wrote:
  Sorry, all.  I'd left an alert() in there, had the dictionaries in the
 wrong
  order, and didn't know that there was formatting whitespace hidden in the
  XML response.  Here's a second cut of the file that takes those points
 into
  account.
 
  --David
 
 
 --
  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. http://p.sf.net/sfu/velocityconf
  ___
  To unsubscribe visit:
  https://lists.sourceforge.net/lists/listinfo/dqsd-users
  DQSD-Users@lists.sourceforge.net
  http://sourceforge.net/mailarchive/forum.php?forum_id=8601
 
 


 --
 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. http://p.sf.net/sfu/velocityconf
 ___
 To unsubscribe visit:
 https://lists.sourceforge.net/lists/listinfo/dqsd-users
 DQSD-Users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/dqsd-users%0adqsd-us...@lists.sourceforge.net
 http://sourceforge.net/mailarchive/forum.php?forum_id=8601

--
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. http://p.sf.net/sfu/velocityconf___
To unsubscribe visit:
https://lists.sourceforge.net/lists/listinfo/dqsd-users
DQSD-Users@lists.sourceforge.net
http://sourceforge.net/mailarchive/forum.php?forum_id=8601


[DQSD-Users] df for word definitions (take 2)

2009-05-01 Thread David Blume
Sorry, all.  I'd left an alert() in there, had the dictionaries in the wrong
order, and didn't know that there was formatting whitespace hidden in the
XML response.  Here's a second cut of the file that takes those points into
account.

--David
search function=df
  nameDictService from Aonaware/name
  description
Search for word definitions.  Recommended it is used with :|df in localaliases.txt, so that word: brings up its definition.
div class=helpboxDescLabelsSwitches:/div
div class=helpboxDescLabelsExamples:/div
table class=helpboxDescTable
  trtddf idempotent/td/tr
  trtdidempotent:/td/tr
/table
  /description
  categoryReferencecategoryLanguage/category/category
  linkhttp://www.aonaware.com/services.htm/link
  
  form name=dff
action=http://services.aonaware.com;
method=post
input type=hidden name=book value=Dictionary/
input type=hidden name=va/
  /form
  
  script
   ![CDATA[
  
function df(q)
{
  var dicts = [gcide,foldoc];
  var definitions;
  try
  {
var xmlHttp = new ActiveXObject(Microsoft.XmlHttp);
for( var d in dicts ) {
  xmlHttp.open(GET, http://services.aonaware.com/DictService/DictService.asmx/DefineInDict?dictId=; + dicts[d] + word= + q, false);
  xmlHttp.send();  
  var xmlDoc = xmlHttp.responseXML.documentElement;
  definitions = xmlDoc.getElementsByTagName(WordDefinition)  
  if( definitions.length  0 )
break;
}
  }
  catch ( e )
  {
alert( Exception thrown:  + e.description );
return;
  }
  
  var windowW = 440;

  if ( definitions.length  0 ) {
  var html = ;
  for( var i=0; i  definitions.length; i++ ) {
html += 'pb' + q + '/b/p';
var body = definitions[i].text.replace( /[\r\n]/gi, br / );
body = body.replace( /  /gi,  nbsp; );
html += 'p' + body + '/p';
  }
  }
  else
  {
  var html = 'centerb' + q + '/b not found/centerbr/';
  }

  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/cssimg { border-width: 0 } .variant { font-weight: bold; } .verb_class { display: block; } .unicode{font-family:Lucida Sans Unicode;}/styletrtd style=padding: 5px 20px 5px 5px' + html + /td/tr/table;

  // This assignment will reformat the HTML extensively
  dictPopupBody.innerHTML = dictPopupBodyInnerHTML;

  dictPopup.document.body.style.border=outset 2px;
  dictPopup.document.body.style.padding=1px 1px; background: navy;
  dictPopup.document.body.style.background='menu';
  dictPopup.document.body.style.overflowY='auto';
  dictPopup.document.body.style.fontFamily='Verdana';
  dictPopup.document.body.attachEvent('onmouseup',dfCopySelection);

  // Temporarily show the popup to determine the proper final height for the popup.
  dictPopup.show(0, 0, windowW, 0);
  var windowH = dictPopupBody.scrollHeight + 6;
  dictPopup.hide();
  dictPopup.document.all.dfTable.style.width = 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.show(dictPopup_x, dictPopup_y, dictPopup_width, dictPopup_height, document.body);
}

function dfCopySelection()
{
  dictPopup.document.execCommand( Copy );
  dictPopup.document.selection.empty();
}

function dfGoToWord(w)
{
  if ( dictPopup.document.selection.type == Text )
  {
dfCopySelection();
  }
  else
  {
df(w);
  }
}
  ]]/script
  copyright
  Copyright (c) 2009 David Blume
  Distributed under the terms of the
  GNU Public License, Version 2 (http://www.gnu.org/copyleft/gpl.txt)
  /copyright
/search
--
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.