Skip to content

Instantly share code, notes, and snippets.

@ftherese
Created January 28, 2009 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ftherese/54249 to your computer and use it in GitHub Desktop.
Save ftherese/54249 to your computer and use it in GitHub Desktop.
makeSearchCommand({
name: "newadvent",
synonyms: ["catholic","search"],
modifiers: {in: noun_arb_text},
url: "http://www.google.com/search?hl=en&as_q={QUERY}&as_sitesearch=newadvent.org",
icon: "http://www.newadvent.org/images/icon1.ico",
description: "Searches <a href=\"http://www.newadvent.org\">NewAdvent</a> for articles matching your words.",
help: "Try issuing &quot;newadvent gnostics in cathen&quot; to get results from the Catholic Encyclopedia. Works with &quot;cathen,&quot; &quot;fathers,&quot; &quot;bible,&quot; &quot;summa,&quot; and &quot;library.&quot;",
preview: function( pblock, thing, mods ) {
if (thing.text < 1) {pblock.innerHTML = "Search <b>NewAdvent.org</b>";return;}
jQuery.get(this.url.replace("{QUERY}", thing.text) + "%2F" + mods.in.text,
function (doc)
{var tempElement = CmdUtils.getHiddenWindow().document.createElementNS("http://www.w3.org/1999/xhtml", "ol");
tempElement.innerHTML = doc;
var resource = "";
if (mods.in.text){
switch (mods.in.text){
case "cathen": resource = " in the <b>Catholic Encyclopedia</b>"; break;
case "summa": resource = " in the <b>Summa Theologica</b>"; break;
case "bible": resource = " in the <b>Holy Bible</b>"; break;
case "fathers": resource = " in the <b>Fathers of the Church</b>"; break;
case "library": resource = " in the <b>Catholic Library</b>"; break;
}
}
// 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>NewAdvent</b>" + resource ;
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