mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-23 07:19:50 -04:00
added improved reference parsing, can now find passages across chapters.
This commit is contained in:
parent
99dec3f4a6
commit
7fd974741a
78
biblerefparsingtests.html
Normal file
78
biblerefparsingtests.html
Normal 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>
|
File diff suppressed because it is too large
Load Diff
2
js/bible_ref_parsing.min.js
vendored
2
js/bible_ref_parsing.min.js
vendored
File diff suppressed because one or more lines are too long
128
js/common.js
128
js/common.js
@ -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];
|
||||
|
||||
r += "<b>" + $(v).attr("n") + ".</b> ";
|
||||
|
||||
for (var j = 0; j < v.childNodes.length; j++)
|
||||
{
|
||||
r += Traverse(v.childNodes[j], testament);
|
||||
}
|
||||
|
||||
|
||||
r += "<br />";
|
||||
ev = tvs;
|
||||
}
|
||||
|
||||
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>");
|
||||
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 w = 0; w < v.childNodes.length; w++)
|
||||
{
|
||||
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) + " " + sch + ":" + sv + "-" + ech + ":" + ev + "</h2>" + r + "</span><br clear='all' /></div>");
|
||||
|
||||
t.find(".hiddenlink").click(function(e)
|
||||
{
|
||||
@ -240,46 +255,69 @@ 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"
|
||||
$.ajax({
|
||||
async: false,
|
||||
type: "GET",
|
||||
url: url,
|
||||
dataType: "xml",
|
||||
success: function(d, t, x)
|
||||
{
|
||||
xml = d;
|
||||
},
|
||||
error: function(request, status, error)
|
||||
{
|
||||
Util.HandleError(error, request);
|
||||
}
|
||||
});
|
||||
for (var i = sch; i <= ech; i++)
|
||||
{
|
||||
var url = "xml/" + b + "-" + i + ".xml"
|
||||
$.ajax({
|
||||
async: false,
|
||||
type: "GET",
|
||||
url: url,
|
||||
dataType: "xml",
|
||||
success: function(d, t, x)
|
||||
{
|
||||
xml.push({ "ch": i, "vs": d });
|
||||
},
|
||||
error: function(request, status, error)
|
||||
{
|
||||
Util.HandleError(error, request);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// get the verses requested.
|
||||
if (ev == "*")
|
||||
for (var j = 0; j < xml.length; j++)
|
||||
{
|
||||
vs = $(xml).find("v");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var i = sv; i <= ev; i++)
|
||||
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 (end == "*" || end > tvs)
|
||||
{
|
||||
vs.unshift($(xml).find('v[n="' + i + '"]')[0])
|
||||
end = tvs;
|
||||
}
|
||||
|
||||
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.vs = vs;
|
||||
r.testament = $(xml).find("b").attr("testament");
|
||||
|
||||
r.cs = cs;
|
||||
r.testament = $(xml[0].vs).find("b").attr("testament");
|
||||
return r;
|
||||
|
||||
}
|
||||
catch (err)
|
||||
{
|
||||
|
2
js/common.min.js
vendored
2
js/common.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user