mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-27 01:19:52 -04:00
213 lines
7.9 KiB
TypeScript
213 lines
7.9 KiB
TypeScript
class Strongs
|
|
{
|
|
public static GetStrongs(sn: number, dict) {
|
|
try {
|
|
var self = this;
|
|
var results = {
|
|
prefix: "",
|
|
sn: -1,
|
|
strongs:,
|
|
rmac:,
|
|
crossrefs:,
|
|
rmaccode:,
|
|
};
|
|
var url = dict + ((sn - 1) / 100) + ".xml";
|
|
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: "xml/" + url,
|
|
dataType: "xml",
|
|
success: function (d, t, x) {
|
|
results.strongs = d;
|
|
},
|
|
error: function (request, status, error) {
|
|
Util.HandleError(error);
|
|
}
|
|
});
|
|
|
|
$.ajax({
|
|
async: false,
|
|
type: "GET",
|
|
url: "xml/cr" + url,
|
|
dataType: "xml",
|
|
success: function (d, t, x) {
|
|
results.crossrefs = d;
|
|
},
|
|
error: function (request, status, error) {
|
|
Util.HandleError(error);
|
|
}
|
|
});
|
|
|
|
if (dict == "grk") {
|
|
url = "xml/rs" + ((sn - 1) / 1000) + ".xml";
|
|
// rmac is a two get process.
|
|
$.ajax({
|
|
async: false,
|
|
type: "GET",
|
|
url: url,
|
|
dataType: "xml",
|
|
success: function (d, t, x) {
|
|
results.rmac = 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 = "xml/r-" + results.rmaccode.substring(0, 1) + ".xml";
|
|
$.ajax({
|
|
async: false,
|
|
type: "GET",
|
|
url: url,
|
|
dataType: "xml",
|
|
success: function (d, t, x) {
|
|
results.rmac = d;
|
|
},
|
|
error: function (request, status, error) {
|
|
Util.HandleError(error);
|
|
}
|
|
});
|
|
}
|
|
else {
|
|
results.rmac = "none";
|
|
}
|
|
}
|
|
return results;
|
|
} catch (err) {
|
|
Util.HandleError(err);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static BuildStrongs(r) {
|
|
try {
|
|
var t = "";
|
|
// sometimes people search for a number that doesn't exist
|
|
if (r.strongs == undefined) {
|
|
t = $("<div class='strongsdef result'><a href='javascript:void(0)' class='removeresult' style='border: 0;'><img style='border: 0px;' src='images/delete.png' width='48' height='48' /></a><span class='resultbody'>Doesn't exist.</span><br clear='all' /></div>");
|
|
}
|
|
else {
|
|
// first deal with strongs data.
|
|
var entry = $(r.strongs).find("i#" + r.prefix + r.sn);
|
|
var title = $(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, "<a href='javascript:void(0)' class='link'>$1</a>");
|
|
|
|
// now deal with cross references.
|
|
var cr = $(r.crossrefs).find("i#" + r.prefix + r.sn).find("rs");
|
|
var crtxt = "";
|
|
if (cr.length > 0) {
|
|
crtxt = "<div class='scr'><b>Cross References:</b> <a href='javascript:void()' class='showhide'>Show</a><br /><span class='contents'>";
|
|
|
|
cr.each(function (i) {
|
|
crtxt += "<b>" + $(this).find("t").text() + ":</b> ";
|
|
|
|
$(this).find("r").each(function (j) {
|
|
var ref = $(this).attr("r").split(";");
|
|
crtxt += "<a href='javascript:void(0)' class='link'>" + Reference.bookName(ref[0]) + " " + ref[1] + ":" + ref[2] + "</a>, ";
|
|
});
|
|
crtxt = crtxt.substr(0, crtxt.length - 2);
|
|
crtxt += "<br />";
|
|
});
|
|
crtxt += "</span></div>";
|
|
}
|
|
// ...processing statements go here...
|
|
var rtxt = "";
|
|
if (r.prefix == "G" && r.rmac != "none") {
|
|
|
|
rtxt += "<div class='rmac'><b>Robinsons Morphological Analysis Code: " + r.rmaccode + "</b> <a href='javascript:void()' class='showhide'>Show</a><br /><span class='contents'>";
|
|
;
|
|
$(r.rmac).find('i[id="' + r.rmaccode.toUpperCase() + '"]').find("d").each(function () {
|
|
rtxt += $(this).text() + "<br />";
|
|
});
|
|
rtxt += "</span></div>";
|
|
}
|
|
// put together the display.
|
|
|
|
// ok. we have to do this because click events seem to be cumulative with jquery.
|
|
t = $("<div class='strongsdef result'><a href='javascript:void(0)' class='removeresult' style='border: 0;'><img style='border: 0px;' src='images/delete.png' width='48' height='48' /></a><span class='resultbody'><h2><a class ='result-heading'href='http://www.dynamicbible.com/?r=" + r.prefix + r.sn + "'>" + r.prefix + r.sn + "</a></h2><b>" + trans + " (" + r.sn + ")</b> - " + pron + " - " + title + " - " + desc + "<br />" + rtxt + crtxt + "</span><br clear='all' /></div>");
|
|
}
|
|
|
|
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 staticDisplayStrongs(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 = $("<div></div>").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");
|
|
}
|
|
}
|
|
};
|