///
type StrongsDefinition = { n: number, i: string, d: string, de: string }
type StrongsCrossReference =
{
id: string, // strongs id H1|G1
t: string, // strongs testament grk|heb
d: string, // strongs word/data Aaron {ah-ar-ohn'}
ss: [
{
w: string,
rs: [
{ r: string }
]
}
]
}
type RMACDefinition = { id: string, d: string[] }
type RMACCrossReference ={i:string, r:string}
type StrongsResult =
{
prefix: string,
sn: number,
strongs:StrongsDefinition[],
rmac: RMACDefinition[],
crossrefs:StrongsCrossReference[],
rmaccode:string,
};
class Strongs
{
public static GetStrongs(sn: number, dict) : any {
try {
let self = this;
let results:StrongsResult = {
prefix: "",
sn: -1,
strongs:[],
rmac:[],
crossrefs:[],
rmaccode:'',
};
var url = dict + Math.ceil(sn / 100) + ".json";
if (dict == "grk") {
results.prefix = "G";
if (sn > 5624) return false;
} else {
results.prefix = "H";
if (sn > 8674) return false;
}
results.sn = sn;
$.ajax({
async: false,
type: "GET",
url: "data/strongs/" + url,
dataType: "json",
success: function (d:StrongsDefinition[], t, x) {
results.strongs = d;
},
error: function (request, status, error) {
Util.HandleError(error);
}
});
$.ajax({
async: false,
type: "GET",
url: "data/strongscr/cr" + url,
dataType: "json",
success: function (d:StrongsCrossReference[], t, x) {
results.crossrefs = d;
},
error: function (request, status, error) {
Util.HandleError(error);
}
});
if (dict == "grk") {
url = "data/rmac/rs" + Math.ceil(sn / 1000) + ".json";
let rmac_cross_references: RMACCrossReference[];
// rmac is a two get process.
$.ajax({
async: false,
type: "GET",
url: url,
dataType: "json",
success: function (d:RMACCrossReference[], t, x) {
rmac_cross_references = d;
},
error: function (request, status, error) {
Util.HandleError(error);
}
});
// deal with RMAC
results.rmaccode = $(results.rmac).find('s[id="' + sn + '"]').attr("r");
if (results.rmaccode != undefined) {
url = "data/rmac/r-" + results.rmaccode.substring(0, 1) + ".json";
$.ajax({
async: false,
type: "GET",
url: url,
dataType: "xml",
success: function (d: RMACDefinition[], t, x) {
results.rmac = d;
},
error: function (request, status, error) {
Util.HandleError(error);
}
});
}
}
return results;
} catch (err) {
Util.HandleError(err);
}
return null;
}
public static BuildStrongs(r:StrongsResult) {
try {
let t:JQuery;
// sometimes people search for a number that doesn't exist
if (r.strongs == undefined) {
t = $("
Doesn't exist. ");
}
else {
// first deal with strongs data.
let entry = $.grep(r.strongs, (el, i) => { if (el.i == r.prefix + r.sn) { return true } else { return false }});
let title = entry. $(entry).find("t").text();
var trans = $(entry).find("tr").text();
var pron = $(entry).find("p").text();
var desc = Traverse($(entry).find("d")[0]);
var re = /([hg][0-9]{1,4})/gi;
desc = desc.replace(re, "$1");
// now deal with cross references.
var cr = $(r.crossrefs).find("i#" + r.prefix + r.sn).find("rs");
var crtxt = "";
if (cr.length > 0) {
crtxt = "";
}
// ...processing statements go here...
var rtxt = "";
if (r.prefix == "G" && r.rmac != "none") {
rtxt += "Robinsons Morphological Analysis Code: " + r.rmaccode + " Show";
;
$(r.rmac).find('i[id="' + r.rmaccode.toUpperCase() + '"]').find("d").each(function () {
rtxt += $(this).text() + "
";
});
rtxt += " ";
}
// put together the display.
// ok. we have to do this because click events seem to be cumulative with jquery.
t = $("
" + trans + " (" + r.sn + ") - " + pron + " - " + title + " - " + desc + "
" + rtxt + crtxt + " ");
}
t.find(".link").click(function (e) {
Util.HandleLink(e);
});
t.find(".removeresult").click(function (e) {
Util.RemoveResult(e);
});
t.find(".showhide").click(function (e) {
Strongs.ShowHide(e);
});
return t;
} catch (err) {
Util.HandleError(err);
}
return null;
}
public static DisplayStrongs(r) {
try {
var t = Strongs.BuildStrongs(r);
$("#result").prepend(t);
return false;
} catch (err) {
Util.HandleError(err);
}
return null;
}
public static DisplayStrongsDialog(r) {
try {
var t = Strongs.BuildStrongs(r);
var d = $("").append(t);
d.dialog({
draggable: true,
width: 600,
height: 500,
resizable: true,
title: "Strongs Definition",
buttons: {
"Close": function () {
$(this).dialog("close");
}
}
});
return false;
} catch (err) {
Util.HandleError(err);
}
return null;
}
public static ShowHide(e) {
var o = $(e.target);
var c = o.parent().find(".contents");
if (c.css("display") != "none") {
c.css("display", "none");
o.html("Show");
} else {
c.css("display", "inline");
o.html("Hide");
}
}
};