Created
January 20, 2010 20:07
-
-
Save ba3r/282191 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
noun_version_name = new CmdUtils.NounType("version", ["nkjv", "kjv", "niv"]); | |
CmdUtils.CreateCommand( | |
{ | |
names: ["bible passage"], | |
icon: "http://www.biblegateway.com/favicon.ico", | |
homepage: "http://www.biblegateway.com", | |
author: { name: "Jon Zenor", email: "[email protected]" }, | |
contributor: { name: "Michael Baer", homepage: "http://twitter.com/synapsos"}, | |
license: "GPL", | |
description: "Search for a Bible Passage", | |
help: "Give a bible passage to look up the text. Optionally you can give a version.", | |
arguments: { object_passage: noun_arb_text, modifier_ver: noun_version_name }, | |
preview: function(pblock, args) | |
{ | |
var versions = { | |
"niv" : "31", | |
"nkjv" : "50", | |
"kjv" : "9" | |
}; | |
var version = versions[args["ver"].text]; | |
if(version == "" || version == null) | |
{ | |
version = versions.nkjv; | |
} | |
var passageUrl = "http://www.biblegateway.com/passage/?search=" + input.text + ";&version=" + version; | |
CmdUtils.previewAjax(pblock, | |
{ | |
url: passageUrl, | |
dataType: "html", | |
success: function(data) | |
{ | |
var passageRegex = new RegExp('<div class=\\"result-text-style-normal\\">\\n.+[\\n|</div>]', 'mgi'); | |
var match = passageRegex.exec(data); | |
if(match != null) | |
{ | |
var msg = '${passage}'; | |
pblock.innerHTML = CmdUtils.renderTemplate(msg, { passage: match[0]}); | |
} | |
else | |
{ | |
pblock.innerHTML = "No match found for passage: " + input.text ; | |
} | |
} | |
}); | |
}, | |
execute: function(input, args) | |
{ | |
var versions = { | |
"niv" : "31", | |
"nkjv" : "50", | |
"kjv" : "9" | |
}; | |
var version = versions[args["ver"].text]; | |
if(version == "" || version == null) | |
{ | |
version = versions.nkjv; | |
} | |
Utils.openUrlInBrowser("http://www.biblegateway.com/passage/?search=" + input.text + ";&version=" + version); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
__