2016-04-26 10:24:12 -04:00
|
|
|
|
type BiblePassage = {
|
|
|
|
|
ch: number,
|
|
|
|
|
vss: BibleVerse[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type BibleVerse = {
|
|
|
|
|
v: number,
|
|
|
|
|
w: [
|
|
|
|
|
{
|
|
|
|
|
t: string, s: string
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type BiblePassageResult = {
|
|
|
|
|
cs: BiblePassage[],
|
|
|
|
|
testament: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Bible {
|
|
|
|
|
public static DisplayPassage(result: BiblePassageResult, ref: Reference): void {
|
2016-04-20 17:15:14 -04:00
|
|
|
|
try {
|
2016-04-26 10:30:37 -04:00
|
|
|
|
let r = "";
|
2016-04-26 10:24:12 -04:00
|
|
|
|
for (let j = 0; j < result.cs.length; j++) {
|
|
|
|
|
if (Number(ref.Section.start.chapter) < Number(ref.Section.end.chapter)) {
|
|
|
|
|
r += "<b>Chapter: " + result.cs[j].ch + "</b><br />";
|
2016-04-20 17:15:14 -04:00
|
|
|
|
}
|
2016-04-26 10:24:12 -04:00
|
|
|
|
let vss = result.cs[j].vss;
|
2016-04-20 17:15:14 -04:00
|
|
|
|
|
2016-04-26 10:24:12 -04:00
|
|
|
|
for (let m = 0; m < vss.length; m++) {
|
|
|
|
|
let v = vss[m];
|
2016-04-20 17:15:14 -04:00
|
|
|
|
|
|
|
|
|
r += "<b>" + v.v + ".</b> ";
|
|
|
|
|
|
2016-04-26 10:24:12 -04:00
|
|
|
|
for (let w = 0; w < v.w.length; w++) {
|
2016-04-20 17:15:14 -04:00
|
|
|
|
if (v.w[w].s != undefined) {
|
2016-04-26 10:24:12 -04:00
|
|
|
|
let strongs_pre = "";
|
|
|
|
|
if (result.testament == "old") {
|
2016-04-20 17:15:14 -04:00
|
|
|
|
strongs_pre = "H";
|
|
|
|
|
}
|
2016-04-26 10:24:12 -04:00
|
|
|
|
if (result.testament == "new") {
|
2016-04-20 17:15:14 -04:00
|
|
|
|
strongs_pre = "G";
|
|
|
|
|
}
|
2016-04-26 10:24:12 -04:00
|
|
|
|
let sp = "";
|
2016-04-20 17:15:14 -04:00
|
|
|
|
if (v.w[w].t.substr(v.w[w].t.length - 1) == " ") {
|
|
|
|
|
sp = " ";
|
|
|
|
|
}
|
|
|
|
|
r += "<a href='javascript:void(0)' class='hiddenlink' title='Strongs #: " + v.w[w].s + "'><span class='searchvalue' style='display:none'>" + strongs_pre + v.w[w].s + "</span>" + v.w[w].t.trim() + "</a>" + sp;
|
|
|
|
|
} else {
|
|
|
|
|
r += v.w[w].t;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($("#break-on-verses").is(":checked")) {
|
|
|
|
|
r += "<br />";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-09-12 10:45:00 -04:00
|
|
|
|
let t = $("<div class='passage result'><a href='javascript:void(0)' class='removeresult' style='border: 0;'><img style='border: 0px;' src='images/delete.png' width='48' height='48' /></a><a href='#' class='trigger left'> </a><div class='tags panel left'></div><span class='resultbody'>" + "<h2><a class ='result-heading' href='javascript:void()'>" + ref.toString() + "</a></h2>" + r + "</span><br clear='all' /></div>");
|
2016-04-20 17:15:14 -04:00
|
|
|
|
Bible.AttachEvents(t, ref);
|
|
|
|
|
$("#result").prepend(t);
|
|
|
|
|
}
|
|
|
|
|
catch (err) {
|
|
|
|
|
Util.HandleError(err);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-26 10:24:12 -04:00
|
|
|
|
public static GetPassage(section: Section): BiblePassageResult {
|
2016-04-20 17:15:14 -04:00
|
|
|
|
try {
|
2016-04-26 10:24:12 -04:00
|
|
|
|
let chapters: BiblePassage[] = []; // the verses from the chapter.
|
|
|
|
|
let r: BiblePassageResult = {
|
2016-04-20 17:15:14 -04:00
|
|
|
|
cs: [],
|
|
|
|
|
testament: ""
|
|
|
|
|
};
|
|
|
|
|
|
2016-04-26 10:24:12 -04:00
|
|
|
|
for (let i = Number(section.start.chapter); i <= Number(section.end.chapter); i++) {
|
|
|
|
|
let url = "data/bibles/kjv_strongs/" + section.start.book + "-" + i + ".json";
|
2016-04-20 17:15:14 -04:00
|
|
|
|
$.ajax({
|
|
|
|
|
async: false,
|
|
|
|
|
type: "GET",
|
|
|
|
|
url: url,
|
|
|
|
|
dataType: "json",
|
2016-04-26 10:24:12 -04:00
|
|
|
|
success: function (d: BiblePassage, t, x) {
|
2016-04-20 17:15:14 -04:00
|
|
|
|
chapters.push(d);
|
|
|
|
|
},
|
|
|
|
|
error: function (request, status, error) {
|
|
|
|
|
Util.HandleError(error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-26 10:24:12 -04:00
|
|
|
|
for (let j = 0; j < chapters.length; j++) {
|
|
|
|
|
let vss: BibleVerse[] = [];
|
|
|
|
|
let start;
|
|
|
|
|
let end;
|
2016-04-20 17:15:14 -04:00
|
|
|
|
|
|
|
|
|
// figure out the start verse.
|
|
|
|
|
if (j == 0) {
|
2016-04-26 10:24:12 -04:00
|
|
|
|
start = section.start.verse;
|
2016-04-20 17:15:14 -04:00
|
|
|
|
} else {
|
|
|
|
|
start = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// figure out the end verse
|
|
|
|
|
if ((j + 1) == chapters.length) {
|
2016-04-26 10:24:12 -04:00
|
|
|
|
end = section.end.verse;
|
2016-04-20 17:15:14 -04:00
|
|
|
|
} else {
|
|
|
|
|
end = "*";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// get the verses requested.
|
2016-04-26 10:24:12 -04:00
|
|
|
|
let tvs = chapters[j].vss.length;
|
2016-04-20 17:15:14 -04:00
|
|
|
|
if (end == "*" || end > tvs) {
|
|
|
|
|
end = tvs;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-26 10:24:12 -04:00
|
|
|
|
for (let i = start; i <= end; i++) {
|
2016-04-20 17:15:14 -04:00
|
|
|
|
// we're using c based indexes here, so the index is 1 less than the verse #.
|
|
|
|
|
vss.push(chapters[j].vss[i - 1]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
r.cs.push({
|
|
|
|
|
"ch": chapters[j].ch,
|
|
|
|
|
"vss": vss
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-26 10:24:12 -04:00
|
|
|
|
if (section.start.book >= 40) {
|
2016-04-20 17:15:14 -04:00
|
|
|
|
r.testament = "new";
|
|
|
|
|
} else {
|
|
|
|
|
r.testament = "old";
|
|
|
|
|
}
|
|
|
|
|
return r;
|
|
|
|
|
} catch (err) {
|
|
|
|
|
Util.HandleError(err);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-25 14:47:08 -04:00
|
|
|
|
public static AttachEvents(t, ref) {
|
2016-04-20 17:15:14 -04:00
|
|
|
|
t.find(".hiddenlink").click(function (e) {
|
|
|
|
|
Util.HandleHiddenLink(e);
|
|
|
|
|
});
|
2016-09-12 10:45:00 -04:00
|
|
|
|
t.find(".result-heading").click(function (e)
|
|
|
|
|
{
|
|
|
|
|
window.location.href = "?"+$(e.target).text();
|
|
|
|
|
});
|
2016-04-20 17:15:14 -04:00
|
|
|
|
t.find(".removeresult").click(function (e) {
|
|
|
|
|
Util.RemoveResult(e);
|
|
|
|
|
});
|
|
|
|
|
t.find(".resultbody h2").tooltip({
|
|
|
|
|
items: ".resultbody h2",
|
|
|
|
|
content: function (tt) {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
t.find('.trigger').slidePanel({
|
|
|
|
|
triggerCss: 'margin-top: 60px; display: block; width: 48px; height: 48px;',
|
|
|
|
|
panelCss: 'margin-top: 55px; border: 2px solid #666;'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|