Skip to content

Instantly share code, notes, and snippets.

@ftherese
Created January 31, 2009 14:42
Show Gist options
  • Save ftherese/55564 to your computer and use it in GitHub Desktop.
Save ftherese/55564 to your computer and use it in GitHub Desktop.
makeSearchCommand({
name: "etymology",
synonyms: ["root","search","dictionary","origin"],
url: "http://www.etymonline.com/index.php?term={QUERY}",
icon: "http://www.etymonline.com/graphics/header.jpg",
description: "Searches <a href=\"http://www.etymology.org\">The Online Etymology Dictonary</a> for the etymology of your words.",
preview: function( pblock, thing ) {
if (thing.text < 1) {pblock.innerHTML = "Search <b>Etymonline.com</b>";return;}
jQuery.get(this.url.replace("{QUERY}", thing.text),
function (doc)
{var tempElement = CmdUtils.getHiddenWindow().document.createElementNS("http://www.w3.org/1999/xhtml", "dl");
tempElement.innerHTML = doc;
// I know there must be a better way of accomplishing the following, but I am an absolute newbie when it comes to jQuery. Help would be appreciated.
pblock.innerHTML = "Found on <b>Etymonline.com</b>";
pblock.innerHTML += "<div style='clear: both;'><b><a href='http://www.etymonline.com" + jQuery("dl dt a",tempElement).attr("href") + "' >" + jQuery("dl dt a",tempElement).html() + "</a></b><br/><div style='margin-left: 20px; font-size: 80%;'>" + jQuery("dl dd",tempElement).html() + "</div></div>";
})
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment