Skip to content

Instantly share code, notes, and snippets.

@ftherese
Created January 31, 2009 16:04
Show Gist options
  • Save ftherese/55575 to your computer and use it in GitHub Desktop.
Save ftherese/55575 to your computer and use it in GitHub Desktop.
makeSearchCommand({
name: "philosophy-encyclopedia",
synonyms: ["philosophy","search","encyclopedia"],
url: "http://www.google.com/search?hl=en&as_q={QUERY}&as_sitesearch=iep.utm.edu",
description: "Searches <a href=\"http://www.iep.utm.edu\">The Internet Encyclopedia of Philosophy</a> for articles matching your words.",
preview: function( pblock, thing ) {
if (thing.text < 1) {pblock.innerHTML = "Search <b>The Internet Encyclopedia of Philosophy</b>";return;}
jQuery.get(this.url.replace("{QUERY}", thing.text),
function (doc)
{var tempElement = CmdUtils.getHiddenWindow().document.createElementNS("http://www.w3.org/1999/xhtml", "ol");
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 in <b>The Encyclopedia of Philosophy</b>";
for (i=0; i<=7; i++ ) {
pblock.innerHTML += "<div style='clear: both;'><b><a href='" + jQuery("ol h3 a",tempElement).eq(i).attr("href") + "' >" + jQuery("ol h3 a",tempElement).eq(i).html() + "</a></b><br/><div style='margin-left: 20px; font-size: 80%;'>" + jQuery("ol div.s",tempElement).eq(i).html() + "</div></div>";
}
})
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment