-
-
Save ftherese/54249 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "newadvent gnostics in cathen" to get results from the Catholic Encyclopedia. Works with "cathen," "fathers," "bible," "summa," and "library."", | |
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