Skip to content

Instantly share code, notes, and snippets.

@codejoust
Created September 21, 2009 18:17
Show Gist options
  • Save codejoust/190420 to your computer and use it in GitHub Desktop.
Save codejoust/190420 to your computer and use it in GitHub Desktop.
/* command "Bible" */
CmdUtils.CreateCommand({
name: "bible",
icon: "http://www.biblegateway.com/favicon.ico",
homepage: "http://www.biblegateway.com/",
author: { name: "CodeJoust", email: "http://codejoust.com/contact"},
license: "GPL",
description: "Search BibleGateway",
help: "BibleGateway: General Search",
takes: {"input": noun_arb_text},
baseurl: "http://www.biblegateway.com/quicksearch/?quicksearch=",
execute: function(direct_obj){
var input = Utils.trim(direct_obj.text);
var url = this.baseurl + encodeURIComponent(input);
Utils.openUrlInBrowser(url);
},
preview: function( pblock, direct_obj) {
var input = direct_obj.text;
var url = this.baseurl + encodeURIComponent(input);
var apiUrl = "http://www.biblegateway.com/quicksearch/?quicksearch=";
Utils.parseRemoteDocument(
url, // URL
null, // post data
function(doc) { // success callback
var data = jQuery('.keyword-result-list li', doc);
var result = "<ul>";
jQuery.each(data , function(i, val) {
if (val.innerHTML != "" )
result += "<li>" + val.innerHTML + "</li>";
});
//result = result.replace(/define.asp/g, apiUrl);
pblock.innerHTML = result + "</ul>";//data;
},
function() { // error callback
pblock.innerHTML = "Error!";
}
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment