jason.wall 1f2383d2f8 FIX: Final tweaks to typescript refactor.
* added type checking
 * fixed display of multi chapter passages
 * limited display to 900 pxof width for easier reading
 * converted vars to lets
 * removed unused traverse function
 * simplified whats gets passed around with passages and results
2016-04-26 10:24:12 -04:00

68 lines
2.3 KiB
TypeScript

/// <reference path="d.ts/jquery.d.ts"/>
/// <reference path="d.ts/jquerymobile.d.ts"/>
/// <reference path="d.ts/jqueryui.d.ts"/>
var CurrentReferences = {};
function SortNumeric(x, y) {
return x - y;
}
function Search(sv) {
try {
let qs = sv.split(";");
for (let x in qs) {
let q = qs[x].trim();
if (q != "") {
// its a search term.
if (q.search(/[0-9]/i) == -1) {
// get new results.
Words.FindReferences(q);
$("#searchpanel").panel("open");
} else if (q.search(/(H|G)[0-9]/i) != -1) {
let original_q = q;
// its a strongs lookup
let dict = q.substring(0, 1);
let store = true;
if (dict.search(/h/i) != -1) {
dict = "heb";
if (parseInt(q.substring(1)) > 8674) store = false;
} else {
dict = "grk";
if (parseInt(q.substring(1)) > 5624) store = false;
}
q = q.substring(1, q.length);
let Ss = q.split(' ');
let results = [];
for (let s in Ss) {
results.push(Strongs.GetStrongs(Ss[s], dict));
}
for (let result in results) {
Strongs.DisplayStrongs(results[result]);
}
if (store) CurrentReferences[original_q.toString().toLowerCase()] = true;
} else {
// its a verse reference.
if (q.trim() != "") {
let myref = new Reference(q.trim());
let r = Bible.GetPassage(myref.Section);
Bible.DisplayPassage(r, myref);
CurrentReferences[myref.toString().toLowerCase()] = true;
}
}
}
}
$("#result").sortable({
axis: "x",
handle: ".handle"
});
Settings.SaveResults();
}
catch (err) {
Util.HandleError(err);
}
};