134 lines
5.3 KiB
JavaScript

var Bible = (function () {
function Bible() {
}
Bible.DisplayPassage = function (result, ref) {
try {
var r = "";
for (var 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 />";
}
var vss = result.cs[j].vss;
for (var m = 0; m < vss.length; m++) {
var v = vss[m];
r += "<b>" + v.v + ".</b> ";
for (var w = 0; w < v.w.length; w++) {
if (v.w[w].s != undefined) {
var strongs_pre = "";
if (result.testament == "old") {
strongs_pre = "H";
}
if (result.testament == "new") {
strongs_pre = "G";
}
var sp = "";
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 />";
}
}
}
var 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'>&nbsp;</a><div class='tags panel left'></div><span class='resultbody'>" + "<h2><a class ='result-heading' href='?r=" + ref.toString() + "'>" + ref.toString() + "</a></h2>" + r + "</span><br clear='all' /></div>");
Bible.AttachEvents(t, ref);
$("#result").prepend(t);
}
catch (err) {
Util.HandleError(err);
}
};
Bible.GetPassage = function (section) {
try {
var chapters_1 = []; // the verses from the chapter.
var r = {
cs: [],
testament: ""
};
for (var i = Number(section.start.chapter); i <= Number(section.end.chapter); i++) {
var url = "data/bibles/kjv_strongs/" + section.start.book + "-" + i + ".json";
$.ajax({
async: false,
type: "GET",
url: url,
dataType: "json",
success: function (d, t, x) {
chapters_1.push(d);
},
error: function (request, status, error) {
Util.HandleError(error);
}
});
}
for (var j = 0; j < chapters_1.length; j++) {
var vss = [];
var start_1 = void 0;
var end = void 0;
// figure out the start verse.
if (j == 0) {
start_1 = section.start.verse;
}
else {
start_1 = 1;
}
// figure out the end verse
if ((j + 1) == chapters_1.length) {
end = section.end.verse;
}
else {
end = "*";
}
// get the verses requested.
var tvs = chapters_1[j].vss.length;
if (end == "*" || end > tvs) {
end = tvs;
}
for (var i = start_1; i <= end; i++) {
// we're using c based indexes here, so the index is 1 less than the verse #.
vss.push(chapters_1[j].vss[i - 1]);
}
r.cs.push({
"ch": chapters_1[j].ch,
"vss": vss
});
}
if (section.start.book >= 40) {
r.testament = "new";
}
else {
r.testament = "old";
}
return r;
}
catch (err) {
Util.HandleError(err);
}
return null;
};
Bible.AttachEvents = function (t, ref) {
t.find(".hiddenlink").click(function (e) {
Util.HandleHiddenLink(e);
});
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;'
});
};
return Bible;
}());
;
//# sourceMappingURL=Bible.js.map