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 { try { let r = ""; for (let j = 0; j < result.cs.length; j++) { if (Number(ref.Section.start.chapter) < Number(ref.Section.end.chapter)) { r += "Chapter: " + result.cs[j].ch + "
"; } let vss = result.cs[j].vss; for (let m = 0; m < vss.length; m++) { let v = vss[m]; r += "" + v.v + ". "; for (let w = 0; w < v.w.length; w++) { if (v.w[w].s != undefined) { let strongs_pre = ""; if (result.testament == "old") { strongs_pre = "H"; } if (result.testament == "new") { strongs_pre = "G"; } let sp = ""; if (v.w[w].t.substr(v.w[w].t.length - 1) == " ") { sp = " "; } r += "" + v.w[w].t.trim() + "" + sp; } else { r += v.w[w].t; } } if ($("#break-on-verses").is(":checked")) { r += "
"; } } } let t = $("
 
" + "

" + ref.toString() + "

" + r + "

"); Bible.AttachEvents(t, ref); $("#result").prepend(t); } catch (err) { Util.HandleError(err); } } public static GetPassage(section: Section): BiblePassageResult { try { let chapters: BiblePassage[] = []; // the verses from the chapter. let r: BiblePassageResult = { cs: [], testament: "" }; for (let i = Number(section.start.chapter); i <= Number(section.end.chapter); i++) { let url = "data/bibles/kjv_strongs/" + section.start.book + "-" + i + ".json"; $.ajax({ async: false, type: "GET", url: url, dataType: "json", success: function (d: BiblePassage, t, x) { chapters.push(d); }, error: function (request, status, error) { Util.HandleError(error); } }); } for (let j = 0; j < chapters.length; j++) { let vss: BibleVerse[] = []; let start; let end; // figure out the start verse. if (j == 0) { start = section.start.verse; } else { start = 1; } // figure out the end verse if ((j + 1) == chapters.length) { end = section.end.verse; } else { end = "*"; } // get the verses requested. let tvs = chapters[j].vss.length; if (end == "*" || end > tvs) { end = tvs; } for (let i = start; i <= end; i++) { // 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 }); } if (section.start.book >= 40) { r.testament = "new"; } else { r.testament = "old"; } return r; } catch (err) { Util.HandleError(err); } return null; } public static AttachEvents(t, ref) { t.find(".hiddenlink").click(function (e) { Util.HandleHiddenLink(e); }); t.find(".result-heading").click(function (e) { window.location.href = "?"+$(e.target).text(); }); 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;' }); } };