diff --git a/DynamicBibleUtility/DynamicBibleUtility.suo b/DynamicBibleUtility/DynamicBibleUtility.suo index 23f0459f..ec1bde4c 100644 Binary files a/DynamicBibleUtility/DynamicBibleUtility.suo and b/DynamicBibleUtility/DynamicBibleUtility.suo differ diff --git a/DynamicBibleUtility/DynamicBibleUtility/Text.cs b/DynamicBibleUtility/DynamicBibleUtility/Text.cs index 71580dcb..b8e61443 100644 --- a/DynamicBibleUtility/DynamicBibleUtility/Text.cs +++ b/DynamicBibleUtility/DynamicBibleUtility/Text.cs @@ -7,23 +7,22 @@ namespace DynamicBibleUtility { public class Book { - public string bk = ""; + public int bk = -1; public List chs = new List(); } public class Chapter { - public string ch = ""; + public int ch = -1; public List vss = new List(); } public class Verse { - public string vs = ""; - public List words = new List(); + public int v = -1; + public List w = new List(); } public class Text { - public string txt = ""; - public string str = ""; - public int i = -1; + public string t = ""; + public string s = ""; } } diff --git a/DynamicBibleUtility/DynamicBibleUtility/frmMain.cs b/DynamicBibleUtility/DynamicBibleUtility/frmMain.cs index 125ed6b1..ef0efde8 100644 --- a/DynamicBibleUtility/DynamicBibleUtility/frmMain.cs +++ b/DynamicBibleUtility/DynamicBibleUtility/frmMain.cs @@ -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); diff --git a/js/common.js b/js/common.js index b8c07aa9..33fbbaf6 100644 --- a/js/common.js +++ b/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 += "Chapter: " + cs[j].ch + "
"; } - 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 += "" + $(v).attr("n") + ". "; + r += "" + v.v + ". "; - 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 += "" + v.w[w].t.trim() + ""+sp; + } + else + { + r += v.w[w].t; + } } - - r += "
"; } } @@ -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 = $("
").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)