mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-27 09:29:59 -04:00
tweaked json text conversion to make smaller. switched out text parsing from xml to json.
This commit is contained in:
parent
1af5989ac1
commit
7d0482cbb1
Binary file not shown.
@ -7,23 +7,22 @@ namespace DynamicBibleUtility
|
||||
{
|
||||
public class Book
|
||||
{
|
||||
public string bk = "";
|
||||
public int bk = -1;
|
||||
public List<Chapter> chs = new List<Chapter>();
|
||||
}
|
||||
public class Chapter
|
||||
{
|
||||
public string ch = "";
|
||||
public int ch = -1;
|
||||
public List<Verse> vss = new List<Verse>();
|
||||
}
|
||||
public class Verse
|
||||
{
|
||||
public string vs = "";
|
||||
public List<object> words = new List<object>();
|
||||
public int v = -1;
|
||||
public List<object> w = new List<object>();
|
||||
}
|
||||
public class Text
|
||||
{
|
||||
public string txt = "";
|
||||
public string str = "";
|
||||
public int i = -1;
|
||||
public string t = "";
|
||||
public string s = "";
|
||||
}
|
||||
}
|
||||
|
@ -273,32 +273,25 @@ namespace DynamicBibleUtility
|
||||
if (el.Name == "BIBLEBOOK")
|
||||
{
|
||||
Book bk = new Book();
|
||||
bk.bk = el.FirstAttribute.Value.ToString();
|
||||
bk.bk = Convert.ToInt32(el.FirstAttribute.Value.ToString());
|
||||
foreach (XElement chn in el.Nodes())
|
||||
{
|
||||
Chapter ch = new Chapter();
|
||||
ch.ch = chn.FirstAttribute.Value;
|
||||
ch.ch = Convert.ToInt32(chn.FirstAttribute.Value);
|
||||
foreach (XElement vs in chn.Nodes())
|
||||
{
|
||||
Verse v = new Verse();
|
||||
v.vs = vs.FirstAttribute.Value;
|
||||
v.v = Convert.ToInt32(vs.FirstAttribute.Value);
|
||||
int i = 0;
|
||||
foreach (object o in vs.Nodes())
|
||||
{
|
||||
Text t = new Text();
|
||||
if (o.GetType() == typeof(XElement))
|
||||
{
|
||||
t.txt = ((XElement)o).Value;
|
||||
t.t = ((XElement)o).Value;
|
||||
if (((XElement)o).Name == "gr")
|
||||
{
|
||||
if (Convert.ToInt32(bk.bk) >= 40)
|
||||
{
|
||||
t.str = "G" + ((XElement)o).FirstAttribute.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
t.str = "H" + ((XElement)o).FirstAttribute.Value;
|
||||
}
|
||||
t.s = ((XElement)o).FirstAttribute.Value;
|
||||
}
|
||||
else if ((((XElement)o).Name.ToString().ToLower() == "style"))
|
||||
{
|
||||
@ -308,24 +301,24 @@ namespace DynamicBibleUtility
|
||||
{
|
||||
throw new Exception("Unknown Element");
|
||||
}
|
||||
t.i = i++;
|
||||
//t.i = i++;
|
||||
}
|
||||
else if (o.GetType() == typeof(XText))
|
||||
{
|
||||
t.txt = ((XText)o).Value;
|
||||
t.i = i++;
|
||||
t.t = ((XText)o).Value;
|
||||
//t.i = i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Unknown Element");
|
||||
}
|
||||
v.words.Add(t);
|
||||
v.w.Add(t);
|
||||
}
|
||||
ch.vss.Add(v);
|
||||
}
|
||||
bk.chs.Add(ch);
|
||||
|
||||
System.IO.File.WriteAllText(bk.bk.ToString() + "-"+ch.ch+".json", Serialize(ch));
|
||||
System.IO.File.WriteAllText(bk.bk.ToString() + "-" + ch.ch + ".json", Serialize(ch).Replace(",\"s\":\"\"", ""));
|
||||
}
|
||||
bbl.Add(bk);
|
||||
|
||||
|
113
js/common.js
113
js/common.js
@ -3,19 +3,18 @@ function SortNumeric(x, y)
|
||||
return x - y
|
||||
}
|
||||
|
||||
String.prototype.trim = function()
|
||||
{
|
||||
return this.replace(/^\s+|\s+$/g, "");
|
||||
}
|
||||
String.prototype.ltrim = function()
|
||||
{
|
||||
return this.replace(/^\s+/, "");
|
||||
}
|
||||
String.prototype.rtrim = function()
|
||||
{
|
||||
return this.replace(/\s+$/, "");
|
||||
}
|
||||
|
||||
String.prototype.trim = function()
|
||||
{
|
||||
return this.replace(/^\s+|\s+$/g, "");
|
||||
}
|
||||
String.prototype.ltrim = function()
|
||||
{
|
||||
return this.replace(/^\s+/, "");
|
||||
}
|
||||
String.prototype.rtrim = function()
|
||||
{
|
||||
return this.replace(/\s+$/, "");
|
||||
}
|
||||
function Traverse(node, testament)
|
||||
{
|
||||
try
|
||||
@ -127,7 +126,10 @@ function Search(sv)
|
||||
}
|
||||
|
||||
}
|
||||
$( "#result" ).sortable({ axis: "x", handle: ".handle" });
|
||||
$( "#result" ).sortable({
|
||||
axis: "x",
|
||||
handle: ".handle"
|
||||
});
|
||||
}
|
||||
catch (err)
|
||||
{
|
||||
@ -267,7 +269,7 @@ var Bible = {
|
||||
{
|
||||
var r = "";
|
||||
// make the end verse pretty.
|
||||
var tvs = cs[cs.length - 1].vs.length;
|
||||
var tvs = cs[cs.length - 1].vss.length;
|
||||
|
||||
if (ev == "*" || ev > tvs)
|
||||
{
|
||||
@ -280,20 +282,30 @@ var Bible = {
|
||||
{
|
||||
r += "<b>Chapter: " + cs[j].ch + "</b><br />";
|
||||
}
|
||||
var vs = cs[j].vs;
|
||||
var vss = cs[j].vss;
|
||||
|
||||
for (var m = 0; m < vs.length; m++)
|
||||
for (var m = 0; m < vss.length; m++)
|
||||
{
|
||||
var v = vs[m];
|
||||
var v = vss[m];
|
||||
|
||||
r += "<b>" + $(v).attr("n") + ".</b> ";
|
||||
r += "<b>" + v.v + ".</b> ";
|
||||
|
||||
for (var w = 0; w < v.childNodes.length; w++)
|
||||
for (var w = 0; w < v.w.length; w++)
|
||||
{
|
||||
r += Traverse(v.childNodes[w], testament);
|
||||
if (v.w[w].s != undefined)
|
||||
{
|
||||
var strongs_pre = "";
|
||||
if (testament == "old") { strongs_pre = "H"; }
|
||||
if (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();' 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
r += "<br />";
|
||||
}
|
||||
}
|
||||
@ -318,24 +330,21 @@ var Bible = {
|
||||
{
|
||||
try
|
||||
{
|
||||
var xml = []; // the verses from the chapter.
|
||||
var chapters = []; // the verses from the chapter.
|
||||
var cs = []; // the verses requested.
|
||||
var r = {};
|
||||
|
||||
for (var i = sch; i <= ech; i++)
|
||||
{
|
||||
var url = "xml/" + b + "-" + i + ".xml"
|
||||
var url = "bibles/kjv_strongs/" + b + "-" + i + ".json"
|
||||
$.ajax({
|
||||
async: false,
|
||||
type: "GET",
|
||||
url: url,
|
||||
dataType: "xml",
|
||||
dataType: "json",
|
||||
success: function(d, t, x)
|
||||
{
|
||||
xml.push({
|
||||
"ch": i,
|
||||
"vs": d
|
||||
});
|
||||
chapters.push(d);
|
||||
},
|
||||
error: function(request, status, error)
|
||||
{
|
||||
@ -344,9 +353,9 @@ var Bible = {
|
||||
});
|
||||
}
|
||||
|
||||
for (var j = 0; j < xml.length; j++)
|
||||
for (var j = 0; j < chapters.length; j++)
|
||||
{
|
||||
var vs = [];
|
||||
var vss = [];
|
||||
var start;
|
||||
var end;
|
||||
|
||||
@ -359,8 +368,9 @@ var Bible = {
|
||||
{
|
||||
start = 1;
|
||||
}
|
||||
|
||||
if ((j + 1) == xml.length)
|
||||
|
||||
// figure out the end verse
|
||||
if ((j + 1) == chapters.length)
|
||||
{
|
||||
end = ev;
|
||||
}
|
||||
@ -369,27 +379,34 @@ var Bible = {
|
||||
end = "*";
|
||||
}
|
||||
|
||||
var tvs = $(xml[j].vs).find("v").length;
|
||||
|
||||
// get the verses requested.
|
||||
var tvs = chapters[j].vss.length;
|
||||
if (end == "*" || end > tvs)
|
||||
{
|
||||
end = tvs;
|
||||
}
|
||||
|
||||
for (var i = start; i <= end; i++)
|
||||
for (i = start; i <= end; i++)
|
||||
{
|
||||
vs.push($(xml[j].vs).find('v[n="' + i + '"]')[0])
|
||||
// we're using c based indexes here, so the index is 1 less than the verse #.
|
||||
vss.push(chapters[j].vss[i-1]);
|
||||
}
|
||||
|
||||
cs.push({
|
||||
"ch": xml[j].ch,
|
||||
"vs": vs
|
||||
"ch": chapters[j].ch,
|
||||
"vss": vss
|
||||
});
|
||||
}
|
||||
|
||||
r.cs = cs;
|
||||
r.testament = $(xml[0].vs).find("b").attr("testament");
|
||||
if (b >= 40)
|
||||
{
|
||||
r.testament = "new";
|
||||
}
|
||||
else
|
||||
{
|
||||
r.testament = "old";
|
||||
}
|
||||
return r;
|
||||
}
|
||||
catch (err)
|
||||
@ -581,12 +598,18 @@ var Strongs = {
|
||||
var t = Strongs.BuildStrongs(r);
|
||||
var d = $("<div></div>").append(t);
|
||||
|
||||
d.dialog({draggable:true, width: 600, height: 500, resizable: true, title: "Strongs Definition",
|
||||
d.dialog({
|
||||
draggable:true,
|
||||
width: 600,
|
||||
height: 500,
|
||||
resizable: true,
|
||||
title: "Strongs Definition",
|
||||
buttons: {
|
||||
"Close": function() {
|
||||
$( this ).dialog( "close" );
|
||||
"Close": function() {
|
||||
$( this ).dialog( "close" );
|
||||
}
|
||||
}
|
||||
}});
|
||||
});
|
||||
return false;
|
||||
}
|
||||
catch (err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user