added improved reference parsing, can now find passages across chapters.

This commit is contained in:
jwall@VAPPRCSN015.vap.local 2011-11-04 19:19:29 -04:00
parent 99dec3f4a6
commit 7fd974741a
5 changed files with 796 additions and 551 deletions

78
biblerefparsingtests.html Normal file
View File

@ -0,0 +1,78 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="Jason Wall" />
<meta name="PBO.auth" content="8bff0c5d7a8f61d1e5dfa6c58da67c2b" />
<meta name="geo.country" content="US" />
<meta name="dc.language" content="en" />
<meta name="dc.title" content="walljm.com || AJAX Bible || King James Version with Strong's Dictionary and Cross References" />
<meta name="description" content="An AJAX implimentation of The King James Version Bible with Strong's Dictionary integrated." />
<meta name="keywords" content="AJAX, KJV, King James Version, Strong's Dictionary, Strongs" />
<meta name="blogchalk" content="United States, Missouri, Saint Louis, English, Jason, Male, 21-25, photography, poetry" />
<meta name="copyright" content="All content copyrighted to Jason Wall, and available by permission of the owner." />
<title>The Bible with Strong's Numbers and Cross References</title>
<script type="text/javascript" src="js/jquery.min.js"></script>
<!--<script type="text/javascript" src="js/bible_ref_parsing.js"></script>-->
<script type="text/javascript" src="js/bible_ref_parsing.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
var tests = [
["john 1:4 - john 2", "John 1:4 - 2:*"],
["john 1 : 4 - john 2", "John 1:4 - 2:*"],
["1 john 1:4 - 1 john 2", "1 John 1:4 - 2:*"],
["1 john 1 : 4 - john 2", "1 John 1:4 - 2:*"],
["1 john 3 - 1 john 5", "1 John 3:1 - 5:*"],
["1 John 1", "1 John 1:1 - 1:*"],
["John 1", "John 1:1 - 1:*"],
["1 John 1:1", "1 John 1:1 - 1:1"],
[" 1 John 1 : 1 ", "1 John 1:1 - 1:1"],
["John 1:1", "John 1:1 - 1:1"],
[" John 1 : 1 ", "John 1:1 - 1:1"],
[" 1 John 1 : 1 - 2 ", "1 John 1:1 - 1:2"],
["1 John 1:1-2", "1 John 1:1 - 1:2"],
["John 1:1-2", "John 1:1 - 1:2"],
["John 1 : 1 - 2", "John 1:1 - 1:2"],
["1 John 1 : 1 - 1 John 2 : 3 ", "1 John 1:1 - 2:3"],
["1 John 1:1-1 John 2:3", "1 John 1:1 - 2:3"],
["John 1:1-John 2:3", "John 1:1 - 2:3"],
["John 1 : 1 - John 2 : 3 ", "John 1:1 - 2:3"],
["John 1-2", "John 1:1 - 2:*"],
["John 1 - 2", "John 1:1 - 2:*"],
["1 John 1-2", "1 John 1:1 - 2:*"],
["1 John 1 - 2 ", "1 John 1:1 - 2:*"]
];
var b = $("body");
var passed = 0;
var failed = 0;
for (var i = 0; i < tests.length; i++)
{
var t = tests[i];
var ref = new Reference(t[0]);
var r = "<b>Test " + i + ":</b> " + t[0] + "<br />";
var parsed = ref.bookname + " " + ref.startchapter + ":" + ref.startverse + " - " + ref.endchapter + ":" + ref.endverse;
r += "<b>Value:</b> " + parsed + "<br />";
if (parsed == t[1])
{
r += "<span style='color:green'>Passed</span><br /><br />";
passed++;
}
else
{
r += "<span style='color:red'>Failed</span><br /><br />";
failed++;
}
b.append(r);
}
b.prepend(passed + " Passed, " + failed + " Failed<br /><br />");
});
</script>
</head>
<body>
</body>
</html>

View File

@ -3,434 +3,563 @@
// Jason@walljm.com // www.walljm.com
//
String.prototype.trim = function()
{
return this.replace(/^\s+|\s+$/g, "");
}
String.prototype.ltrim = function()
{
return this.replace(/^\s+/, "");
}
String.prototype.rtrim = function()
{
return this.replace(/\s+$/, "");
}
function Reference(bibleRef) {
bibleRef = bibleRef.toLowerCase();
function Reference(ref)
{
ref = ref.toLowerCase().trim();
var bibleNames = new Object;
var book = bibleRef.substring(0, bibleRef.search(/\s\d/i));
var book = ref.substring(0, ref.search(/\s\d/i));
if (book.search(/\b(genesis|gen|ge|gn)\b/i) != -1) {
if (book.search(/\b(genesis|gen|ge|gn)\b/i) != -1)
{
this.book = 1;
this.bookname = "Genesis";
this.longbookname = "Genesis";
this.lastchapter = 50;
}
if (book.search(/\b(exodus|ex|exo|exod|exd)\b/i) != -1) {
if (book.search(/\b(exodus|ex|exo|exod|exd)\b/i) != -1)
{
this.book = 2;
this.bookname = "Exodus";
this.longbookname = "Exodus";
this.lastchapter = 40;
}
if (book.search(/\b(leviticus|lev|le|levi|lv)\b/i) != -1) {
if (book.search(/\b(leviticus|lev|le|levi|lv)\b/i) != -1)
{
this.book = 3;
this.bookname = "Leviticus";
this.longbookname = "Leviticus";
this.lastchapter = 27;
}
if (book.search(/\b(numbers|num|nu|numb|number)\b/i) != -1) {
if (book.search(/\b(numbers|num|nu|numb|number)\b/i) != -1)
{
this.book = 4;
this.bookname = "Numbers";
this.longbookname = "Book_of_Numbers";
this.lastchapter = 36;
}
if (book.search(/\b(deuteronomy|deut|de|dt|deu)\b/i) != -1) {
if (book.search(/\b(deuteronomy|deut|de|dt|deu)\b/i) != -1)
{
this.book = 5;
this.bookname = "Deuteronomy";
this.longbookname = "Deuteronomy";
this.lastchapter = 34;
}
if (book.search(/\b(joshua|josh|jos)\b/i) != -1) {
if (book.search(/\b(joshua|josh|jos)\b/i) != -1)
{
this.book = 6;
this.bookname = "Joshua";
this.longbookname = "Book_of_Joshua";
this.lastchapter = 24;
}
if (book.search(/\b(judges|jud|ju|jdg|judg)\b/i) != -1) {
if (book.search(/\b(judges|jud|ju|jdg|judg)\b/i) != -1)
{
this.book = 7;
this.bookname = "Judges";
this.longbookname = "Book_of_Judges";
this.lastchapter = 21;
}
if (book.search(/\b(ruth|ru)\b/i) != -1) {
if (book.search(/\b(ruth|ru)\b/i) != -1)
{
this.book = 8;
this.bookname = "Ruth";
this.longbookname = "Book_of_Ruth";
this.lastchapter = 4;
}
if (book.search(/\b(1|i|1st|first)\s*(samuel|sa|sam|sml)\b/i) != -1) {
if (book.search(/\b(1|i|1st|first)\s*(samuel|sa|sam|sml)\b/i) != -1)
{
this.book = 9;
this.bookname = "1 Samuel";
this.longbookname = "First_Samuel";
this.lastchapter = 31;
}
if (book.search(/\b(2|ii|2nd|second|sec)\s*(samuel|sa|sam|sml)\b/i) != -1) {
if (book.search(/\b(2|ii|2nd|second|sec)\s*(samuel|sa|sam|sml)\b/i) != -1)
{
this.book = 10;
this.bookname = "2 Samuel";
this.longbookname = "Second_Samuel";
this.lastchapter = 24;
}
if (book.search(/\b(1|i|1st|first)\s*(kings|king|kgs|kn|k|ki)\b/i) != -1) {
if (book.search(/\b(1|i|1st|first)\s*(kings|king|kgs|kn|k|ki)\b/i) != -1)
{
this.book = 11;
this.bookname = "1 Kings";
this.longbookname = "First_Kings";
this.lastchapter = 22;
}
if (book.search(/\b(2|ii|2nd|second|sec)\s*(kings|king|kgs|kn|k|ki)\b/i) != -1) {
if (book.search(/\b(2|ii|2nd|second|sec)\s*(kings|king|kgs|kn|k|ki)\b/i) != -1)
{
this.book = 12;
this.bookname = "2 Kings";
this.longbookname = "Second_Kings";
this.lastchapter = 25;
}
if (book.search(/\b(1|i|1st|first)\s*(chronicles|chron|ch|chr)\b/i) != -1) {
if (book.search(/\b(1|i|1st|first)\s*(chronicles|chron|ch|chr)\b/i) != -1)
{
this.book = 13;
this.bookname = "1 Chronicles";
this.longbookname = "First_Chronicles";
this.lastchapter = 29;
}
if (book.search(/\b(2|ii|2nd|second|sec)\s*(chronicles|chron|ch|chr)\b/i) != -1) {
if (book.search(/\b(2|ii|2nd|second|sec)\s*(chronicles|chron|ch|chr)\b/i) != -1)
{
this.book = 14;
this.bookname = "2 Chronicles";
this.longbookname = "Second_Chronicles";
this.lastchapter = 36;
}
if (book.search(/\b(ezra|ez|ezr)\b/i) != -1) {
if (book.search(/\b(ezra|ez|ezr)\b/i) != -1)
{
this.book = 15;
this.bookname = "Ezra";
this.longbookname = "Book_of_Ezra";
this.lastchapter = 10;
}
if (book.search(/\b(nehemiah|neh|ne|nehamiah)\b/i) != -1) {
if (book.search(/\b(nehemiah|neh|ne|nehamiah)\b/i) != -1)
{
this.book = 16;
this.bookname = "Nehemiah";
this.longbookname = "Book_of_Nehemiah";
this.lastchapter = 13;
}
if (book.search(/\b(esther|est|es|esth)\b/i) != -1) {
if (book.search(/\b(esther|est|es|esth)\b/i) != -1)
{
this.book = 17;
this.bookname = "Esther";
this.longbookname = "Book_of_Esther";
this.lastchapter = 10;
}
if (book.search(/\b(job|jo|jb)\b/i) != -1) {
if (book.search(/\b(job|jo|jb)\b/i) != -1)
{
this.book = 18;
this.bookname = "Job";
this.longbookname = "Book_of_Job";
this.lastchapter = 42;
}
if (book.search(/\b(psalms|ps|psa|psalm|psm)\b/i) != -1) {
if (book.search(/\b(psalms|ps|psa|psalm|psm)\b/i) != -1)
{
this.book = 19;
this.bookname = "Psalm";
this.longbookname = "Psalm";
this.lastchapter = 150;
}
if (book.search(/\b(proverbs|prov|pr|pro|proverb|prv|prvbs)\b/i) != -1) {
if (book.search(/\b(proverbs|prov|pr|pro|proverb|prv|prvbs)\b/i) != -1)
{
this.book = 20;
this.bookname = "Proverbs";
this.longbookname = "Book_of_Proverbs";
this.lastchapter = 31;
}
if (book.search(/\b(ecclesiastes|eccl|ecc|eccles|ec|ecl|ecclesiaste)\b/i) != -1) {
if (book.search(/\b(ecclesiastes|eccl|ecc|eccles|ec|ecl|ecclesiaste)\b/i) != -1)
{
this.book = 21;
this.bookname = "Ecclesiastes";
this.longbookname = "Ecclesiastes";
this.lastchapter = 12;
}
if (book.search(/\b(song\sof\ssolomon|song\sof\ssongs|sos|ss|son|so|song|songs)\b/i) != -1) {
if (book.search(/\b(song\sof\ssolomon|song\sof\ssongs|sos|ss|son|so|song|songs)\b/i) != -1)
{
this.book = 22;
this.bookname = "Song of Solomon";
this.longbookname = "Song_of_Solomon";
this.lastchapter = 8;
}
if (book.search(/\b(isaiah|is|is|isah|isai|ia)\b/i) != -1) {
if (book.search(/\b(isaiah|is|is|isah|isai|ia)\b/i) != -1)
{
this.book = 23;
this.bookname = "Isaiah";
this.longbookname = "Book_of_Isaiah";
this.lastchapter = 66;
}
if (book.search(/\b(jerimiah|jeremiah|jer|je|jere)\b/i) != -1) {
if (book.search(/\b(jerimiah|jeremiah|jer|je|jere)\b/i) != -1)
{
this.book = 24;
this.bookname = "Jeremiah";
this.longbookname = "Book_of_Jeremiah";
this.lastchapter = 52;
}
if (book.search(/\b(lamentations|lam|la|lamentation)\b/i) != -1) {
if (book.search(/\b(lamentations|lam|la|lamentation)\b/i) != -1)
{
this.book = 25;
this.bookname = "Lamentations";
this.longbookname = "Book_of_Lamentations";
this.lastchapter = 5;
}
if (book.search(/\b(ezekiel|eze|ez|ezk|ezek)\b/i) != -1) {
if (book.search(/\b(ezekiel|eze|ez|ezk|ezek)\b/i) != -1)
{
this.book = 26;
this.bookname = "Ezekiel";
this.longbookname = "Book_of_Ezekiel";
this.lastchapter = 48;
}
if (book.search(/\b(daniel|dan|dn|dl|da)\b/i) != -1) {
if (book.search(/\b(daniel|dan|dn|dl|da)\b/i) != -1)
{
this.book = 27;
this.bookname = "Daniel";
this.longbookname = "Book_of_Daniel";
this.lastchapter = 12;
}
if (book.search(/\b(hosea|hos|ho)\b/i) != -1) {
if (book.search(/\b(hosea|hos|ho)\b/i) != -1)
{
this.book = 28;
this.bookname = "Hosea";
this.longbookname = "Book_of_Hosea";
this.lastchapter = 14;
}
if (book.search(/\b(joel|joe|jl)\b/i) != -1) {
if (book.search(/\b(joel|joe|jl)\b/i) != -1)
{
this.book = 29;
this.bookname = "Joel";
this.longbookname = "Book_of_Joel";
this.lastchapter = 3;
}
if (book.search(/\b(amos|am|amo)\b/i) != -1) {
if (book.search(/\b(amos|am|amo)\b/i) != -1)
{
this.book = 30;
this.bookname = "Amos";
this.longbookname = "Book_of_Amos";
this.lastchapter = 9;
}
if (book.search(/\b(obadiah|oba|ob|obad)\b/i) != -1) {
if (book.search(/\b(obadiah|oba|ob|obad)\b/i) != -1)
{
this.book = 31;
this.bookname = "Obadiah";
this.longbookname = "Book_of_Obadiah";
this.lastchapter = 1;
}
if (book.search(/\b(jonah|jnh|jon)\b/i) != -1) {
if (book.search(/\b(jonah|jnh|jon)\b/i) != -1)
{
this.book = 32;
this.bookname = "Jonah";
this.longbookname = "Book_of_Jonah";
this.lastchapter = 4;
}
if (book.search(/\b(micah|mic|mi)\b/i) != -1) {
if (book.search(/\b(micah|mic|mi)\b/i) != -1)
{
this.book = 33;
this.bookname = "Micah";
this.longbookname = "Book_of_Micah";
this.lastchapter = 7;
}
if (book.search(/\b(nahum|nah|na)\b/i) != -1) {
if (book.search(/\b(nahum|nah|na)\b/i) != -1)
{
this.book = 34;
this.bookname = "Nahum";
this.longbookname = "Book_of_Nahum";
this.lastchapter = 3;
}
if (book.search(/\b(habakkuk|hab|ha|habakuk)\b/i) != -1) {
if (book.search(/\b(habakkuk|hab|ha|habakuk)\b/i) != -1)
{
this.book = 35;
this.bookname = "Habakkuk";
this.longbookname = "Book_of_Habakkuk";
this.lastchapter = 3;
}
if (book.search(/\b(zephaniah|zeph|zep)\b/i) != -1) {
if (book.search(/\b(zephaniah|zeph|zep)\b/i) != -1)
{
this.book = 36;
this.bookname = "Zephaniah";
this.longbookname = "Book_of_Zephaniah";
this.lastchapter = 3;
}
if (book.search(/\b(haggia|hag|hg|haggai)\b/i) != -1) {
if (book.search(/\b(haggia|hag|hg|haggai)\b/i) != -1)
{
this.book = 37;
this.bookname = "Haggai";
this.longbookname = "Book_of_Haggai";
this.lastchapter = 2;
}
if (book.search(/\b(zechariah|zech|zch|zec)\b/i) != -1) {
if (book.search(/\b(zechariah|zech|zch|zec)\b/i) != -1)
{
this.book = 38;
this.bookname = "Zechariah";
this.longbookname = "Book_of_Zechariah";
this.lastchapter = 14;
}
if (book.search(/\b(malachi|mal)\b/i) != -1) {
if (book.search(/\b(malachi|mal)\b/i) != -1)
{
this.book = 39;
this.bookname = "Malachi";
this.longbookname = "Book_of_Malachi";
this.lastchapter = 4;
}
if (book.search(/\b(matthew|mt|matt|mat)\b/i) != -1) {
if (book.search(/\b(matthew|mt|matt|mat)\b/i) != -1)
{
this.book = 40;
this.bookname = "Matthew";
this.longbookname = "Gospel_of_Matthew";
this.lastchapter = 28;
}
if (book.search(/\b(mark|mrk|mk|mr)\b/i) != -1) {
if (book.search(/\b(mark|mrk|mk|mr)\b/i) != -1)
{
this.book = 41;
this.bookname = "Mark";
this.longbookname = "Gospel_of_Mark";
this.lastchapter = 16;
}
if (book.search(/\b(luke|lu|lke|luk|lk)\b/i) != -1) {
if (book.search(/\b(luke|lu|lke|luk|lk)\b/i) != -1)
{
this.book = 42;
this.bookname = "Luke";
this.longbookname = "Gospel_of_Luke";
this.lastchapter = 24;
}
if (book.search(/\b(john|jn|jhn)\b/i) != -1) {
if (book.search(/\b(john|jn|jhn)\b/i) != -1)
{
this.book = 43;
this.bookname = "John";
this.longbookname = "Gospel_of_John";
this.lastchapter = 21;
}
if (book.search(/\b(acts|ac|act)\b/i) != -1) {
if (book.search(/\b(acts|ac|act)\b/i) != -1)
{
this.book = 44;
this.bookname = "Acts";
this.longbookname = "Acts_of_the_Apostles";
this.lastchapter = 28;
}
if (book.search(/\b(romans|rom|ro|rm|roman)\b/i) != -1) {
if (book.search(/\b(romans|rom|ro|rm|roman)\b/i) != -1)
{
this.book = 45;
this.bookname = "Romans";
this.longbookname = "Epistle_to_the_Romans";
this.lastchapter = 16;
}
if (book.search(/\b(1|i|1st|first)\s*(corinthian|cor|corinthians|corinth|corin|corth|corint)\b/i) != -1) {
if (book.search(/\b(1|i|1st|first)\s*(corinthian|cor|corinthians|corinth|corin|corth|corint)\b/i) != -1)
{
this.book = 46;
this.bookname = "1 Corinthians";
this.longbookname = "First_Epistle_to_the_Corinthians";
this.lastchapter = 16;
}
if (book.search(/\b(2|ii|2nd|second|sec)\s*(corinthian|cor|corinthians|corinth|corin|corth|corint)\b/i) != -1) {
if (book.search(/\b(2|ii|2nd|second|sec)\s*(corinthian|cor|corinthians|corinth|corin|corth|corint)\b/i) != -1)
{
this.book = 47;
this.bookname = "2 Corinthians";
this.longbookname = "Second_Epistle_to_the_Corinthians";
this.lastchapter = 13;
}
if (book.search(/\b(galatians|galatian|galations|gal|ga|gala|galation|galat)\b/i) != -1) {
if (book.search(/\b(galatians|galatian|galations|gal|ga|gala|galation|galat)\b/i) != -1)
{
this.book = 48;
this.bookname = "Galatians";
this.longbookname = "Epistle_to_the_Galatians";
this.lastchapter = 6;
}
if (book.search(/\b(ephesians|eph|ep|ephes|ephe|ephs)\b/i) != -1) {
if (book.search(/\b(ephesians|eph|ep|ephes|ephe|ephs)\b/i) != -1)
{
this.book = 49;
this.bookname = "Ephesians";
this.longbookname = "Epistle_to_the_Ephesians";
this.lastchapter = 6;
}
if (book.search(/\b(philippians|phi|phil|ph|philip)\b/i) != -1) {
if (book.search(/\b(philippians|phi|phil|ph|philip)\b/i) != -1)
{
this.book = 50;
this.bookname = "Philippians";
this.longbookname = "Epistle_to_the_Philippians";
this.lastchapter = 4;
}
if (book.search(/\b(colossians|col|co|colossian|colos|coloss)\b/i) != -1) {
if (book.search(/\b(colossians|col|co|colossian|colos|coloss)\b/i) != -1)
{
this.book = 51;
this.bookname = "Colossians";
this.longbookname = "Epistle_to_the_Colossians";
this.lastchapter = 4;
}
if (book.search(/\b(1|i|1st|first)\s*(thessalonians|the|thessa|thessalonian|thes|thess|th)\b/i) != -1) {
if (book.search(/\b(1|i|1st|first)\s*(thessalonians|the|thessa|thessalonian|thes|thess|th)\b/i) != -1)
{
this.book = 52;
this.bookname = "1 Thessalonians";
this.longbookname = "First_Epistle_to_the_Thessalonians";
this.lastchapter = 5;
}
if (book.search(/\b(2|ii|2nd|second|sec)\s*(thessalonians|the|thessa|thessalonian|thes|thess|th)\b/i) != -1) {
if (book.search(/\b(2|ii|2nd|second|sec)\s*(thessalonians|the|thessa|thessalonian|thes|thess|th)\b/i) != -1)
{
this.book = 53;
this.bookname = "2 Thessalonians";
this.longbookname = "Second_Epistle_to_the_Thessalonians";
this.lastchapter = 3;
}
if (book.search(/\b(1|i|1st|first)\s*(timothy|tim|ti|timoth|tm)\b/i) != -1) {
if (book.search(/\b(1|i|1st|first)\s*(timothy|tim|ti|timoth|tm)\b/i) != -1)
{
this.book = 54;
this.bookname = "1 Timothy";
this.longbookname = "First_Epistle_to_Timothy";
this.lastchapter = 6;
}
if (book.search(/\b(2|ii|2nd|second|sec)\s*(timothy|tim|timoth|tm)\b/i) != -1) {
if (book.search(/\b(2|ii|2nd|second|sec)\s*(timothy|tim|timoth|tm)\b/i) != -1)
{
this.book = 55;
this.bookname = "2 Timothy";
this.longbookname = "Second_Epistle_to_Timothy";
this.lastchapter = 4;
}
if (book.search(/\b(titus|tit)\b/i) != -1) {
if (book.search(/\b(titus|tit)\b/i) != -1)
{
this.book = 56;
this.bookname = "Titus";
this.longbookname = "Epistle_to_Titus";
this.lastchapter = 3;
}
if (book.search(/\b(philemon|phlmn|phl|phm|phile|philem)\b/i) != -1) {
if (book.search(/\b(philemon|phlmn|phl|phm|phile|philem)\b/i) != -1)
{
this.book = 57;
this.bookname = "Philemon";
this.longbookname = "Epistle_to_Philemon";
this.lastchapter = 1;
}
if (book.search(/\b(hebrews|heb|he|hebrew)\b/i) != -1) {
if (book.search(/\b(hebrews|heb|he|hebrew)\b/i) != -1)
{
this.book = 58;
this.bookname = "Hebrews";
this.longbookname = "Epistle_to_the_Hebrews";
this.lastchapter = 13;
}
if (book.search(/\b(james|jam|ja|jas|jms|jame|jm)\b/i) != -1) {
if (book.search(/\b(james|jam|ja|jas|jms|jame|jm)\b/i) != -1)
{
this.book = 59;
this.bookname = "James";
this.longbookname = "Epistle_of_James";
this.lastchapter = 5;
}
if (book.search(/\b(1|i|1st|first)\s*(peter|pe|pet|pete|pt|p)\b/i) != -1) {
if (book.search(/\b(1|i|1st|first)\s*(peter|pe|pet|pete|pt|p)\b/i) != -1)
{
this.book = 60;
this.bookname = "1 Peter";
this.longbookname = "First_Epistle_of_Peter";
this.lastchapter = 5;
}
if (book.search(/\b(2|ii|2nd|second|sec)\s*(peter|pe|pet|pete|pt|p)\b/i) != -1) {
if (book.search(/\b(2|ii|2nd|second|sec)\s*(peter|pe|pet|pete|pt|p)\b/i) != -1)
{
this.book = 61;
this.bookname = "2 Peter";
this.longbookname = "Second_Epistle_of_Peter";
this.lastchapter = 3;
}
if (book.search(/\b(1|i|1st|first)\s*(john|jn|jo)\b/i) != -1) {
if (book.search(/\b(1|i|1st|first)\s*(john|jn|jo)\b/i) != -1)
{
this.book = 62;
this.bookname = "1 John";
this.longbookname = "First_Epistle_of_John";
this.lastchapter = 5;
}
if (book.search(/\b(2|ii|2nd|second|sec)\s*(john|jn|jo)\b/i) != -1) {
if (book.search(/\b(2|ii|2nd|second|sec)\s*(john|jn|jo)\b/i) != -1)
{
this.book = 63;
this.bookname = "2 John";
this.longbookname = "Second_Epistle_of_John";
this.lastchapter = 1;
}
if (book.search(/\b(3|iii|3rd|third)\s*(john|jn|jo)\b/i) != -1) {
if (book.search(/\b(3|iii|3rd|third)\s*(john|jn|jo)\b/i) != -1)
{
this.book = 64;
this.bookname = "3 John";
this.longbookname = "Third_Epistle_of_John";
this.lastchapter = 1;
}
if (book.search(/\b(jude|jud|ju)\b/i) != -1) {
if (book.search(/\b(jude|jud|ju)\b/i) != -1)
{
this.book = 65;
this.bookname = "Jude";
this.longbookname = "Epistle_of_Jude";
this.lastchapter = 1;
}
if (book.search(/\b(revelation|rev|re|revelations|rv)\b/i) != -1) {
if (book.search(/\b(revelation|rev|re|revelations|rv)\b/i) != -1)
{
this.book = 66;
this.bookname = "Revelation";
this.longbookname = "Book_of_Revelations";
this.lastchapter = 22;
}
var chvs = bibleRef.substring(bibleRef.search(/\s\d/)+1, bibleRef.length);
if (chvs.search(":") == -1) {
this.chapter = parseInt(chvs.substring(chvs.search(/\s\d\s/) +1,chvs.length));
// ok. we're going to deal with any of the following types of refernces:
/*
book 1-2
book 1 - book 2
book 1:1-2
book 1:1
*/
// book 1-2 or book 1 - book 2
var reg1 = /^\d*\s*(\w+) (\d+)\s*\-\s*\d*\s*\w*\s*(\d+)$/i;
var reg2 = /^\d*\s*(\w+) (\d+)\s*\:\s*(\d+)\s*\-\s*\d*\s*\w+ (\d+)\s*\:\s*(\d+)\s*$/i;
var reg3 = /^\d*\s*(\w+) (\d+)\s*\:\s*(\d+)\s*\-\s*(\d+)\s*$/i;
var reg4 = /^\d*\s*(\w+) (\d+)\s*\:\s*(\d+)\s*$/i;
var reg5 = /^\d*\s*(\w+) (\d+)\s*$/i;
var reg6 = /^\d*\s*(\w+) (\d+)\s*\:\s*(\d+)\s*\-\s*\d*\s*\w+ (\d+)\s*$/i;
if (ref.match(reg1) != null)
{
this.startchapter = RegExp.$2;
this.endchapter = RegExp.$3;
this.startverse = 1;
this.endverse = "*";
} else {
this.chapter = parseInt(chvs.substring(chvs.search(/\s\d\:/) +1, chvs.search(":")));
var vss = chvs.substring(chvs.search(":") + 1, chvs.length);
}
else if (ref.match(reg2) != null)
{
this.startchapter = RegExp.$2;
this.startverse = RegExp.$3;
this.endchapter = RegExp.$4;
this.endverse = RegExp.$5;
}
else if (ref.match(reg3) != null)
{
this.startchapter = RegExp.$2;
this.endchapter = RegExp.$2;
this.startverse = RegExp.$3;
this.endverse = RegExp.$4;
}
else if (ref.match(reg4) != null)
{
this.startchapter = RegExp.$2;
this.endchapter = RegExp.$2;
this.startverse = RegExp.$3;
this.endverse = RegExp.$3;
}
else if (ref.match(reg5) != null)
{
this.startchapter = RegExp.$2;
this.endchapter = RegExp.$2;
this.startverse = 1;
this.endverse = "*";
}
else if (ref.match(reg6) != null)
{
this.startchapter = RegExp.$2;
this.endchapter = RegExp.$4;
this.startverse = RegExp.$3;
this.endverse = "*";
}
if (vss.search("-") != -1) {
this.startverse = parseInt(vss.substring(0, vss.search("-")));
var ev = vss.substring(vss.search("-") + 1, vss.length);
if (ev != "*") {
this.endverse = parseInt(ev);
} else {
this.endverse = ev;
}
} else {
this.startverse = parseInt(vss);
this.endverse = parseInt(vss);
// make sure you don't return an invalid chapter.
if (this.endchapter > this.lastchapter)
{
this.endchapter = this.lastchapter;
}
if (this.startchapter > this.endchapter)
{
this.startchapter = this.endchapter;
}
}
function bookName(booknum) {
function bookName(booknum)
{
var book = new Array();
book[0] = "";
book[1] = "Genesis";

File diff suppressed because one or more lines are too long

View File

@ -107,9 +107,9 @@ function Search(sv)
if (q.trim() != "")
{
var myref = new Reference(q.trim());
var r = Bible.GetPassage(myref.book, myref.chapter, myref.startverse, myref.endverse);
var r = Bible.GetPassage(myref.book, myref.startchapter, myref.endchapter, myref.startverse, myref.endverse);
Bible.DisplayPassage(r.vs, myref.book, myref.chapter, myref.startverse, myref.endverse, r.testament);
Bible.DisplayPassage(r.cs, myref.book, myref.startchapter, myref.endchapter, myref.startverse, myref.endverse, r.testament);
}
}
}
@ -202,28 +202,43 @@ var Util = {
}
var Bible = {
DisplayPassage: function(vs, b, ch, sv, ev, testament)
DisplayPassage: function(cs, b, sch, ech, sv, ev, testament)
{
try
{
var r = "";
// make the end verse pretty.
var tvs = cs[cs.length - 1].vs.length;
for (var i = 0; i < vs.length; i++)
if (ev == "*" || ev > tvs)
{
var v = vs[i];
ev = tvs;
}
for (var j = 0; j < cs.length; j++)
{
if (sch < ech)
{
r += "<b>Chapter: " + cs[j].ch + "</b><br />";
}
var vs = cs[j].vs;
for (var m = 0; m < vs.length; m++)
{
var v = vs[m];
r += "<b>" + $(v).attr("n") + ".</b> ";
for (var j = 0; j < v.childNodes.length; j++)
for (var w = 0; w < v.childNodes.length; w++)
{
r += Traverse(v.childNodes[j], testament);
r += Traverse(v.childNodes[w], testament);
}
r += "<br />";
}
var t = $("<div class='passage result'><a href='javascript:void();' class='removeresult' style='border: 0;'><img style='border: 0px;' src='images/delete.png' width='48' height='48' /></a><span class='resultbody'>" + "<h2>" + bookName(b) + " " + ch + ":" + sv + "-" + ev + "</h2>" + r + "</span><br clear='all' /></div>");
}
var t = $("<div class='passage result'><a href='javascript:void();' class='removeresult' style='border: 0;'><img style='border: 0px;' src='images/delete.png' width='48' height='48' /></a><span class='resultbody'>" + "<h2>" + bookName(b) + " " + sch + ":" + sv + "-" + ech + ":" + ev + "</h2>" + r + "</span><br clear='all' /></div>");
t.find(".hiddenlink").click(function(e)
{
@ -240,15 +255,17 @@ var Bible = {
Util.HandleError(err);
}
},
GetPassage: function(b, ch, sv, ev)
GetPassage: function(b, sch, ech, sv, ev)
{
try
{
var xml; // the verses from the chapter.
var vs = new Array(); // the verses requested.
var xml = []; // the verses from the chapter.
var cs = []; // the verses requested.
var r = {};
var url = "xml/" + b + "-" + ch + ".xml"
for (var i = sch; i <= ech; i++)
{
var url = "xml/" + b + "-" + i + ".xml"
$.ajax({
async: false,
type: "GET",
@ -256,30 +273,51 @@ var Bible = {
dataType: "xml",
success: function(d, t, x)
{
xml = d;
xml.push({ "ch": i, "vs": d });
},
error: function(request, status, error)
{
Util.HandleError(error, request);
}
});
}
for (var j = 0; j < xml.length; j++)
{
var vs = [];
var start;
var end;
// figure out the start verse.
if (j == 0)
{ start = sv; }
else
{ start = 1; }
if ((j + 1) == xml.length)
{ end = ev; }
else
{ end = "*"; }
var tvs = $(xml[j].vs).find("v").length;
// get the verses requested.
if (ev == "*")
if (end == "*" || end > tvs)
{
vs = $(xml).find("v");
end = tvs;
}
else
{
for (var i = sv; i <= ev; i++)
{
vs.unshift($(xml).find('v[n="' + i + '"]')[0])
}
}
r.vs = vs;
r.testament = $(xml).find("b").attr("testament");
return r;
for (var i = start; i <= end; i++)
{
vs.push($(xml[j].vs).find('v[n="' + i + '"]')[0])
}
cs.push({ "ch": xml[j].ch, "vs": vs });
}
r.cs = cs;
r.testament = $(xml[0].vs).find("b").attr("testament");
return r;
}
catch (err)
{

2
js/common.min.js vendored

File diff suppressed because one or more lines are too long