From 0741b50b4cba38d93713ee77019def95930a11f3 Mon Sep 17 00:00:00 2001 From: "Jeremy Wall (zaphar)" Date: Wed, 10 Apr 2013 19:39:10 -0500 Subject: [PATCH] Cleanup. * Use the same brace style everywhere. * Use semicolons everywhere. * Add myself to the authorship for bible ref parsing. * Don't use try catch blocks when exceptions are impossible. * Add some returns for completeness sake when the functions return values elsewhere. --- js/bible_ref_parsing.js | 6 +- js/common.js | 1050 +++++++++++++++++---------------------- 2 files changed, 446 insertions(+), 610 deletions(-) diff --git a/js/bible_ref_parsing.js b/js/bible_ref_parsing.js index 086a34b3..fcbfdce3 100644 --- a/js/bible_ref_parsing.js +++ b/js/bible_ref_parsing.js @@ -1,7 +1,7 @@ -// -// This code was written by Jason Wall. Feel free to use, and if you can, include a link back to www.walljm.com +// This code was written by Jeremy and Jason Wall. +// Feel free to use, and if you can, include a link back to www.walljm.com // Jason@walljm.com // www.walljm.com -// +// Jeremy@marzhillstudios.com // jeremy.marzhillstudios.com String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); diff --git a/js/common.js b/js/common.js index 8cb212c0..05951d60 100644 --- a/js/common.js +++ b/js/common.js @@ -1,60 +1,46 @@ -function SortNumeric(x, y) -{ - return x - y +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+$/, ""); - } -function Traverse(node, testament) -{ - try - { +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 { var treeText = ""; - if (node != null) - { - if (node.hasChildNodes()) - { - if (node.nodeName == "s") - { + if (node != null) { + if (node.hasChildNodes()) { + if (node.nodeName == "s") { // you need to test if this is the OT or NT and set the attribute accordingly. var t = ""; - if (testament == "old") - { + if (testament == "old") { t = "H"; } - if (testament == "new") - { + if (testament == "new") { t = "G"; } treeText += "" + Traverse(node.childNodes.item(0), testament) + ""; - } else -{ + } else { treeText += '<' + node.nodeName + '>'; - for (var i = 0; i < node.childNodes.length; i++) - { + for (var i = 0; i < node.childNodes.length; i++) { treeText += Traverse(node.childNodes.item(i), testament); } treeText += ''; } - } else -{ - if (node.nodeValue != null) - { - if (node.nodeValue.search(/^(\,|\.|\:|\?|\;|\!)/) != -1) - { + } else { + if (node.nodeValue != null) { + if (node.nodeValue.search(/^(\,|\.|\:|\?|\;|\!)/) != -1) { treeText += node.nodeValue; - } else -{ + } else { treeText += " " + node.nodeValue; } } @@ -62,33 +48,25 @@ function Traverse(node, testament) } return treeText; } - catch (err) - { + catch (err) { Util.HandleError(err); } + return null; } -function Search(sv) -{ - try - { +function Search(sv) { + try { var qs = sv.split(";"); - for (var x in qs) - { + for (var x in qs) { var q = qs[x].trim(); - if (q != "") - { + if (q != "") { // its a search term. - if (q.search(/[0-9]/i) == -1) - { + if (q.search(/[0-9]/i) == -1) { // get new results. Words.FindReferences(q); - } - - // its a strongs lookup - else if (q.search(/(H|G)[0-9]/i) != -1) - { + } else if (q.search(/(H|G)[0-9]/i) != -1) { + // its a strongs lookup var dict = q.substring(0, 1); if (dict.search(/h/i) != -1) { dict = "heb"; @@ -97,34 +75,26 @@ function Search(sv) } q = q.substring(1, q.length); var Ss = q.split(' '); - + var results = []; - for (var s in Ss) - { + for (var s in Ss) { results.push(Strongs.GetStrongs(Ss[s], dict)); } - - for (var result in results) - { + + for (var result in results) { // display results. - if ($("#display-strongs-as-dialog")[0].checked) - { + if ($("#display-strongs-as-dialog")[0].checked) { Strongs.DisplayStrongsDialog(results[result]); - } - else - { + } else { Strongs.DisplayStrongs(results[result]); } } - } - // its a verse reference. - else - { + } else { + // its a verse reference. var passage = ""; - if (q.trim() != "") - { + if (q.trim() != "") { var myref = new Reference(q.trim()); var r = Bible.GetPassage(myref.book, myref.startchapter, myref.endchapter, myref.startverse, myref.endverse); @@ -132,15 +102,13 @@ function Search(sv) } } } - } $( "#result" ).sortable({ axis: "x", handle: ".handle" }); } - catch (err) - { + catch (err) { Util.HandleError(err); } @@ -149,25 +117,20 @@ function Search(sv) var Settings = { - Load: function() - { + Load: function() { var str = $.cookie('settings'); - if (str != null) - { + if (str != null) { var s = str.split(","); $("#resultwrap").css("float", s[0]); $("#searchresultswrap").css("float", s[0]); - if (s[1] == "none") - { + if (s[1] == "none") { $("#searchresultswrap").css("display", "none"); $("#showhidesearch").html("Show Search"); $("#resultwrap").css("width", "100%"); - } - else - { + } else { $("#searchresultswrap").css("display", "block"); $("#showhidesearch").html("Hide Search"); $("#resultwrap").css("width", "70%"); @@ -177,8 +140,7 @@ var Settings = { $("#result").css("font-family", s[3]); } }, - Save: function() - { + Save: function() { var s = {}; s.Panes = $("#resultwrap").css("float"); s.Search = $("#searchresultswrap").css("display"); @@ -191,126 +153,101 @@ var Settings = { expires: 365 }); }, - ShowHideSearch: function() - { + ShowHideSearch: function() { var o = $("#showhidesearch"); var s = $("#searchresultswrap"); var r = $("#resultwrap"); - if (s.css("display") != "none") - { + if (s.css("display") != "none") { s.css("display", "none"); o.html("Show Search"); r.css("width", "100%"); - } - else - { + } else { s.css("display", "block"); o.html("Hide Search"); r.css("width", "70%"); } this.Save(); }, - SwitchPanes: function() - { + SwitchPanes: function() { var s = $("#searchresultswrap"); var r = $("#resultwrap"); var v = s.css("float"); - if (v == "right") - { + if (v == "right") { s.css("float", "left"); r.css("float", "left"); - } - else - { + } else { s.css("float", "right"); r.css("float", "right"); } this.Save(); }, - IncreaseResultFontSize: function() - { + IncreaseResultFontSize: function() { var s = $("#result").css("font-size"); $("#result").css("font-size", parseInt(s) + 1); this.Save(); }, - DecreaseResultFontSize: function() - { + DecreaseResultFontSize: function() { var s = $("#result").css("font-size"); $("#result").css("font-size", parseInt(s) - 1); this.Save(); }, - ChangeResultFont: function(fontfamily) - { + ChangeResultFont: function(fontfamily) { $("#result").css("font-family", fontfamily); this.Save(); } -} +}; var Util = { - HandleLink: function(e) - { + HandleLink: function(e) { Search($(e.target).text()); }, - HandleHiddenLink: function(e) - { + HandleHiddenLink: function(e) { Search($(e.target).find(".searchvalue").text()); }, - RemoveResult: function(e) - { + RemoveResult: function(e) { $(e.target).parent().parent().remove(); }, - HandleError: function(e) - { + HandleError: function(e) { // for now we're going to put the error in the main result div. var t = $("
" + e + "
"); return false; } -} +}; var Bible = { - DisplayPassage: function(cs, b, sch, ech, sv, ev, testament) - { - try - { + DisplayPassage: function(cs, b, sch, ech, sv, ev, testament) { + try { var r = ""; // make the end verse pretty. var tvs = cs[cs.length - 1].vss.length; - if (ev == "*" || ev > tvs) - { + if (ev == "*" || ev > tvs) { ev = tvs; } - for (var j = 0; j < cs.length; j++) - { - if (sch < ech) - { + for (var j = 0; j < cs.length; j++) { + if (sch < ech) { r += "Chapter: " + cs[j].ch + "
"; } var vss = cs[j].vss; - for (var m = 0; m < vss.length; m++) - { + for (var m = 0; m < vss.length; m++) { var v = vss[m]; r += "" + v.v + ". "; - for (var w = 0; w < v.w.length; w++) - { - if (v.w[w].s != undefined) - { + for (var w = 0; w < v.w.length; w++) { + 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 - { + } else { r += v.w[w].t; } } @@ -319,119 +256,96 @@ var Bible = { } var t = $("
" + "

" + bookName(b) + " " + sch + ":" + sv + "-" + ech + ":" + ev + "

" + r + "

"); - t.find(".hiddenlink").click(function(e) - { + t.find(".hiddenlink").click(function(e) { Util.HandleHiddenLink(e); }); - t.find(".removeresult").click(function(e) - { + t.find(".removeresult").click(function(e) { Util.RemoveResult(e); }); $("#result").prepend(t); } - catch (err) - { + catch (err) { Util.HandleError(err); } }, - GetPassage: function(b, sch, ech, sv, ev) - { - try - { + GetPassage: function(b, sch, ech, sv, ev) { + try { var chapters = []; // the verses from the chapter. var cs = []; // the verses requested. var r = {}; - for (var i = sch; i <= ech; i++) - { - var url = "bibles/kjv_strongs/" + b + "-" + i + ".json" + for (var i = sch; i <= ech; i++) { + var url = "bibles/kjv_strongs/" + b + "-" + i + ".json"; $.ajax({ async: false, type: "GET", url: url, dataType: "json", - success: function(d, t, x) - { + success: function(d, t, x) { chapters.push(d); }, - error: function(request, status, error) - { + error: function(request, status, error) { Util.HandleError(error, request); } }); } - for (var j = 0; j < chapters.length; j++) - { + for (var j = 0; j < chapters.length; j++) { var vss = []; var start; var end; // figure out the start verse. - if (j == 0) - { + if (j == 0) { start = sv; - } - else - { + } else { start = 1; } - + // figure out the end verse - if ((j + 1) == chapters.length) - { + if ((j + 1) == chapters.length) { end = ev; - } - else - { + } else { end = "*"; } // get the verses requested. var tvs = chapters[j].vss.length; - if (end == "*" || end > tvs) - { + if (end == "*" || end > tvs) { end = tvs; } - for (i = start; i <= end; i++) - { + for (i = start; i <= end; i++) { // 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": chapters[j].ch, + "ch": chapters[j].ch, "vss": vss }); } r.cs = cs; - if (b >= 40) - { + if (b >= 40) { r.testament = "new"; - } - else - { + } else { r.testament = "old"; } return r; - } - catch (err) - { + } catch (err) { Util.HandleError(err); } + return null; } -} +}; var Strongs = { - GetStrongs: function(sn, dict) - { - try - { + GetStrongs: function(sn, dict) { + try { var self = this; var results = {}; - var url = dict + parseInt((sn - 1) / 100) + ".xml" + var url = dict + parseInt((sn - 1) / 100) + ".xml"; if (dict == "grk") { results.prefix = "G"; } else { @@ -444,12 +358,10 @@ var Strongs = { type: "GET", url: "xml/" + url, dataType: "xml", - success: function(d, t, x) - { + success: function(d, t, x) { results.strongs = d; }, - error: function(request, status, error) - { + error: function(request, status, error) { Util.HandleError(error, request); } }); @@ -459,18 +371,15 @@ var Strongs = { type: "GET", url: "xml/cr" + url, dataType: "xml", - success: function(d, t, x) - { + success: function(d, t, x) { results.crossrefs = d; }, - error: function(request, status, error) - { + error: function(request, status, error) { Util.HandleError(error, request); } }); - if (dict == "grk") - { + if (dict == "grk") { url = "xml/rs" + parseInt((sn - 1) / 1000) + ".xml"; // rmac is a two get process. $.ajax({ @@ -478,12 +387,10 @@ var Strongs = { type: "GET", url: url, dataType: "xml", - success: function(d, t, x) - { + success: function(d, t, x) { results.rmac = d; }, - error: function(request, status, error) - { + error: function(request, status, error) { Util.HandleError(error, request); } }); @@ -496,27 +403,22 @@ var Strongs = { type: "GET", url: url, dataType: "xml", - success: function(d, t, x) - { + success: function(d, t, x) { results.rmac = d; }, - error: function(request, status, error) - { + error: function(request, status, error) { Util.HandleError(error, request); } }); } return results; - } - catch (err) - { + } catch (err) { Util.HandleError(err); } + return null; }, - BuildStrongs: function(r) - { - try - { + BuildStrongs: function(r) { + try { // first deal with strongs data. var entry = $(r.strongs).find("i#" + r.prefix + r.sn); var title = $(entry).find("t").text(); @@ -533,12 +435,10 @@ var Strongs = { var crtxt = "
Cross References: Show
"; - cr.each(function(i) - { + cr.each(function(i) { crtxt += "" + $(this).find("t").text() + ": "; - $(this).find("r").each(function(j) - { + $(this).find("r").each(function(j) { var ref = $(this).attr("r").split(";"); crtxt += "" + bookName(ref[0]) + " " + ref[1] + ":" + ref[2] + ", "; }); @@ -549,12 +449,10 @@ var Strongs = { // ...processing statements go here... var rtxt = ""; - if (r.prefix == "G") - { + if (r.prefix == "G") { rtxt += "
Robinsons Morphological Analysis Code: " + r.rmaccode + " Show
"; ; - $(r.rmac).find('i[id="' + r.rmaccode.toUpperCase() + '"]').find("d").each(function() - { + $(r.rmac).find('i[id="' + r.rmaccode.toUpperCase() + '"]').find("d").each(function() { rtxt += $(this).text() + "
"; }); rtxt += "
"; @@ -564,53 +462,44 @@ var Strongs = { // ok. we have to do this because click events seem to be cumulative with jquery. var t = $("
" + trans + " (" + r.sn + ") - " + pron + " - " + title + " - " + desc + "
" + rtxt + crtxt + "

"); - t.find(".link").click(function(e) - { + t.find(".link").click(function(e) { Util.HandleLink(e); }); - t.find(".removeresult").click(function(e) - { + t.find(".removeresult").click(function(e) { Util.RemoveResult(e); }); - t.find(".showhide").click(function(e) - { + t.find(".showhide").click(function(e) { Strongs.ShowHide(e); }); return t; - } - catch (err) - { + } catch (err) { Util.HandleError(err); } + return null; }, - DisplayStrongs: function(r) - { - try - { + DisplayStrongs: function(r) { + try { var t = Strongs.BuildStrongs(r); $("#result").prepend(t); return false; - } - catch (err) - { + } catch (err) { Util.HandleError(err); } + return null; }, - DisplayStrongsDialog: function(r) - { - try - { + DisplayStrongsDialog: function(r) { + try { var t = Strongs.BuildStrongs(r); var d = $("
").append(t); - + d.dialog({ - draggable:true, - width: 600, - height: 500, - resizable: true, + draggable:true, + width: 600, + height: 500, + resizable: true, title: "Strongs Definition", buttons: { "Close": function() { @@ -619,24 +508,19 @@ var Strongs = { } }); return false; - } - catch (err) - { + } catch (err) { Util.HandleError(err); } + return null; }, - ShowHide: function(e) - { + ShowHide: function(e) { var o = $(e.target); var c = o.parent().find(".contents"); - if (c.css("display") != "none") - { + if (c.css("display") != "none") { c.css("display", "none"); o.html("Show"); - } - else - { + } else { c.css("display", "inline"); o.html("Hide"); } @@ -644,29 +528,22 @@ var Strongs = { } var Words = { - ConvertResultsToArray: function(r) - { - try - { + ConvertResultsToArray: function(r) { + try { var results = new Array(); - $(r).each(function() - { + $(r).each(function() { results.push([$(this).attr("b"), $(this).attr("ch"), $(this).attr("v")]); }); return results; - } - catch (err) - { + } catch (err) { Util.HandleError(err); } + return null; }, - DisplayResults: function(results, q) - { - try - { + DisplayResults: function(results, q) { + try { var txt = "

Query: " + q + "

    "; - for (var i = 0; i < results.length; i++) - { + for (var i = 0; i < results.length; i++) { var r = results[i].split(":"); txt += "
  • " + bookName(r[0]) + " " + r[1] + ":" + r[2] + ""; } @@ -674,50 +551,40 @@ var Words = { var t = $(txt); - t.find(".link").click(function(e) - { + t.find(".link").click(function(e) { Util.HandleLink(e); }); $("#searchresults").html(t); $("#searchTotal").html(results.length); return false; - } - catch (err) - { + } catch (err) { Util.HandleError(err); } + return null; }, - FindReferences: function(qry) - { - try - { + FindReferences: function(qry) { + try { qry = qry.toLowerCase(); var qs = qry.split(" "); var words = this.BuildIndexArray().sort(); var results = new Array(); // Loop through each query term. - for (i = 0; i < qs.length; i++) - { + for (i = 0; i < qs.length; i++) { var q = qs[i].replace("'", ""); // we don't included ticks in our words. - - // For each query term, figure out which xml file it is in, and get it. - // getSearchRefs returns an array of references. - for (var w = 0; w < words.length; w++) - { + + // For each query term, figure out which xml file it is in, and get it. + // getSearchRefs returns an array of references. + for (var w = 0; w < words.length; w++) { // If we are at the end of the array, we want to use a different test. - if (w == 0) - { - if (q <= words[w]) - { + if (w == 0) { + if (q <= words[w]) { results.unshift(this.GetSearchReferences("index/" + words[w] + "idx.json", q)); break; } - } else -{ - if (q <= words[w] && q > words[w - 1]) - { + } else { + if (q <= words[w] && q > words[w - 1]) { results.unshift(this.GetSearchReferences("index/" + words[w] + "idx.json", q)); break; } @@ -725,28 +592,23 @@ var Words = { } } // End of loop through query terms - // Now we need to test results. If there is more than one item in the array, we need to find the set + // Now we need to test results. If there is more than one item in the array, we need to find the set // that is shared by all of them. IF not, we can just return those refs. - if (results.length == 1) - { + if (results.length == 1) { this.DisplayResults(results[0], qry); - } else -{ + } else { this.DisplayResults(this.FindSharedSet(results), qry); } return false; - } - catch (err) - { + } catch (err) { Util.HandleError(err); } + return null; }, - GetSearchReferences: function(url, query) - { - try - { + GetSearchReferences: function(url, query) { + try { // getSearchRefs takes a url and uses ajax to retrieve the references and returns an array of references. var r; @@ -755,301 +617,285 @@ var Words = { type: "GET", url: url, dataType: "json", - success: function(d, t, x) - { + success: function(d, t, x) { r = d; }, - error: function(request, status, error) - { + error: function(request, status, error) { Util.HandleError(error, request); } }); // find the right word - var refs = $.grep(r, function(o,i) - { + var refs = $.grep(r, function(o,i) { return o.word == query; }); return refs[0].refs; - } - catch (err) - { + } catch (err) { Util.HandleError(err); } + return null; }, - BuildIndexArray: function() - { - try - { - var words = new Array(); - words.unshift('abiram'); - words.unshift('accepteth'); - words.unshift('acquit'); - words.unshift('adna'); - words.unshift('affecteth'); - words.unshift('aharhel'); - words.unshift('aijeleth'); - words.unshift('almug'); - words.unshift('amiable'); - words.unshift('ancients'); - words.unshift('anything'); - words.unshift('appointeth'); - words.unshift('areopagus'); - words.unshift('art'); - words.unshift('ashteroth'); - words.unshift('astaroth'); - words.unshift('availeth'); - words.unshift('azotus'); - words.unshift('badness'); - words.unshift('baptizing'); - words.unshift('bat'); - words.unshift('bechorath'); - words.unshift('beguile'); - words.unshift('bemoaning'); - words.unshift('beside'); - words.unshift('bezek'); - words.unshift('bitterly'); - words.unshift('bloodthirsty'); - words.unshift('bolted'); - words.unshift('bountifulness'); - words.unshift('breastplates'); - words.unshift('broth'); - words.unshift('bunni'); - words.unshift('cain'); - words.unshift('cankered'); - words.unshift('carry'); - words.unshift('celebrate'); - words.unshift('chapel'); - words.unshift('cheese'); - words.unshift('chilmad'); - words.unshift('circumcision'); - words.unshift('closer'); - words.unshift('come'); - words.unshift('communication'); - words.unshift('concerning'); - words.unshift('confusion'); - words.unshift('consummation'); - words.unshift('convince'); - words.unshift('couch'); - words.unshift('covers'); - words.unshift('crisping'); - words.unshift('curse'); - words.unshift('damnable'); - words.unshift('deacons'); - words.unshift('decision'); - words.unshift('defileth'); - words.unshift('depart'); - words.unshift('despisest'); - words.unshift('diblathaim'); - words.unshift('directly'); - words.unshift('dishonesty'); - words.unshift('distracted'); - words.unshift('dominion'); - words.unshift('dreamer'); - words.unshift('dulcimer'); - words.unshift('eastward'); - words.unshift('eighteenth'); - words.unshift('elihoreph'); - words.unshift('embrace'); - words.unshift('endeavored'); - words.unshift('ensign'); - words.unshift('ephraim'); - words.unshift('eshtemoa'); - words.unshift('evening'); - words.unshift('excellest'); - words.unshift('extended'); - words.unshift('fairer'); - words.unshift('fastings'); - words.unshift('feign'); - words.unshift('fight'); - words.unshift('fishermen'); - words.unshift('flint'); - words.unshift('foolishness'); - words.unshift('forever'); - words.unshift('forts'); - words.unshift('fresh'); - words.unshift('furnish'); - words.unshift('gallio'); - words.unshift('gebal'); - words.unshift('gezrites'); - words.unshift('girt'); - words.unshift('goath'); - words.unshift('government'); - words.unshift('greeteth'); - words.unshift('guiltless'); - words.unshift('haggai'); - words.unshift('hamstrung'); - words.unshift('happy'); - words.unshift('harum'); - words.unshift('hattush'); - words.unshift('heard'); - words.unshift('heir'); - words.unshift('herbs'); - words.unshift('hezronites'); - words.unshift('hivite'); - words.unshift('honored'); - words.unshift('hostages'); - words.unshift('huntest'); - words.unshift('idalah'); - words.unshift('impenitent'); - words.unshift('inferior'); - words.unshift('insomuch'); - words.unshift('ira'); - words.unshift('isuah'); - words.unshift('jabneh'); - words.unshift('japhia'); - words.unshift('jeduthun'); - words.unshift('jerahmeelites'); - words.unshift('jew'); - words.unshift('joined'); - words.unshift('joy'); - words.unshift('kadmonites'); - words.unshift('kid'); - words.unshift('kneaded'); - words.unshift('lack'); - words.unshift('languish'); - words.unshift('lazarus'); - words.unshift('legions'); - words.unshift('libnath'); - words.unshift('likhi'); - words.unshift('lock'); - words.unshift('louder'); - words.unshift('lysias'); - words.unshift('magpiash'); - words.unshift('malchus'); - words.unshift('marble'); - words.unshift('mastery'); - words.unshift('meddle'); - words.unshift('members'); - words.unshift('mesech'); - words.unshift('midian'); - words.unshift('ministered'); - words.unshift('mithnite'); - words.unshift('morasthite'); - words.unshift('mower'); - words.unshift('myrtle'); - words.unshift('naphish'); - words.unshift('necks'); - words.unshift('net'); - words.unshift('noadiah'); - words.unshift('nursed'); - words.unshift('occurrent'); - words.unshift('omnipotent'); - words.unshift('orchard'); - words.unshift('outside'); - words.unshift('owed'); - words.unshift('palti'); - words.unshift('partition'); - words.unshift('paulus'); - words.unshift('peoples'); - words.unshift('persecute'); - words.unshift('phares'); - words.unshift('pilate'); - words.unshift('plagues'); - words.unshift('plentiful'); - words.unshift('poorer'); - words.unshift('powerful'); - words.unshift('presented'); - words.unshift('prison'); - words.unshift('promoted'); - words.unshift('provision'); - words.unshift('purely'); - words.unshift('quarter'); - words.unshift('rahab'); - words.unshift('ravening'); - words.unshift('rebuking'); - words.unshift('refined'); - words.unshift('release'); - words.unshift('rent'); - words.unshift('requirest'); - words.unshift('return'); - words.unshift('rezon'); - words.unshift('riseth'); - words.unshift('roof'); - words.unshift('rump'); - words.unshift('sail'); - words.unshift('sanctuaries'); - words.unshift('savors'); - words.unshift('scorpions'); - words.unshift('second'); - words.unshift('sellers'); - words.unshift('served'); - words.unshift('shaft'); - words.unshift('sharaim'); - words.unshift('shedder'); - words.unshift('shepho'); - words.unshift('shimshai'); - words.unshift('shophan'); - words.unshift('shuppim'); - words.unshift('sihor'); - words.unshift('sippai'); - words.unshift('slandereth'); - words.unshift('smelling'); - words.unshift('softer'); - words.unshift('sores'); - words.unshift('sparrows'); - words.unshift('spoil'); - words.unshift('staff'); - words.unshift('steel'); - words.unshift('stool'); - words.unshift('stretched'); - words.unshift('stumblingblocks'); - words.unshift('suffice'); - words.unshift('surnamed'); - words.unshift('swore'); - words.unshift('take'); - words.unshift('task'); - words.unshift('temani'); - words.unshift('testator'); - words.unshift('thessalonica'); - words.unshift('threatening'); - words.unshift('tie'); - words.unshift('titus'); - words.unshift('torments'); - words.unshift('translation'); - words.unshift('tributaries'); - words.unshift('tubal'); - words.unshift('unchangeable'); - words.unshift('unlawful'); - words.unshift('upbraideth'); - words.unshift('uzza'); - words.unshift('verily'); - words.unshift('visage'); - words.unshift('walk'); - words.unshift('washing'); - words.unshift('wayside'); - words.unshift('wellspring'); - words.unshift('whisperer'); - words.unshift('win'); - words.unshift('withereth'); - words.unshift('work'); - words.unshift('wrest'); - words.unshift('yours'); - words.unshift('zealously'); - words.unshift('zetham'); - words.unshift('zophim'); - words.unshift('zuzims'); - return words; - } - catch (err) - { - Util.HandleError(err); - } + BuildIndexArray: function() { + var words = new Array(); + words.unshift('abiram'); + words.unshift('accepteth'); + words.unshift('acquit'); + words.unshift('adna'); + words.unshift('affecteth'); + words.unshift('aharhel'); + words.unshift('aijeleth'); + words.unshift('almug'); + words.unshift('amiable'); + words.unshift('ancients'); + words.unshift('anything'); + words.unshift('appointeth'); + words.unshift('areopagus'); + words.unshift('art'); + words.unshift('ashteroth'); + words.unshift('astaroth'); + words.unshift('availeth'); + words.unshift('azotus'); + words.unshift('badness'); + words.unshift('baptizing'); + words.unshift('bat'); + words.unshift('bechorath'); + words.unshift('beguile'); + words.unshift('bemoaning'); + words.unshift('beside'); + words.unshift('bezek'); + words.unshift('bitterly'); + words.unshift('bloodthirsty'); + words.unshift('bolted'); + words.unshift('bountifulness'); + words.unshift('breastplates'); + words.unshift('broth'); + words.unshift('bunni'); + words.unshift('cain'); + words.unshift('cankered'); + words.unshift('carry'); + words.unshift('celebrate'); + words.unshift('chapel'); + words.unshift('cheese'); + words.unshift('chilmad'); + words.unshift('circumcision'); + words.unshift('closer'); + words.unshift('come'); + words.unshift('communication'); + words.unshift('concerning'); + words.unshift('confusion'); + words.unshift('consummation'); + words.unshift('convince'); + words.unshift('couch'); + words.unshift('covers'); + words.unshift('crisping'); + words.unshift('curse'); + words.unshift('damnable'); + words.unshift('deacons'); + words.unshift('decision'); + words.unshift('defileth'); + words.unshift('depart'); + words.unshift('despisest'); + words.unshift('diblathaim'); + words.unshift('directly'); + words.unshift('dishonesty'); + words.unshift('distracted'); + words.unshift('dominion'); + words.unshift('dreamer'); + words.unshift('dulcimer'); + words.unshift('eastward'); + words.unshift('eighteenth'); + words.unshift('elihoreph'); + words.unshift('embrace'); + words.unshift('endeavored'); + words.unshift('ensign'); + words.unshift('ephraim'); + words.unshift('eshtemoa'); + words.unshift('evening'); + words.unshift('excellest'); + words.unshift('extended'); + words.unshift('fairer'); + words.unshift('fastings'); + words.unshift('feign'); + words.unshift('fight'); + words.unshift('fishermen'); + words.unshift('flint'); + words.unshift('foolishness'); + words.unshift('forever'); + words.unshift('forts'); + words.unshift('fresh'); + words.unshift('furnish'); + words.unshift('gallio'); + words.unshift('gebal'); + words.unshift('gezrites'); + words.unshift('girt'); + words.unshift('goath'); + words.unshift('government'); + words.unshift('greeteth'); + words.unshift('guiltless'); + words.unshift('haggai'); + words.unshift('hamstrung'); + words.unshift('happy'); + words.unshift('harum'); + words.unshift('hattush'); + words.unshift('heard'); + words.unshift('heir'); + words.unshift('herbs'); + words.unshift('hezronites'); + words.unshift('hivite'); + words.unshift('honored'); + words.unshift('hostages'); + words.unshift('huntest'); + words.unshift('idalah'); + words.unshift('impenitent'); + words.unshift('inferior'); + words.unshift('insomuch'); + words.unshift('ira'); + words.unshift('isuah'); + words.unshift('jabneh'); + words.unshift('japhia'); + words.unshift('jeduthun'); + words.unshift('jerahmeelites'); + words.unshift('jew'); + words.unshift('joined'); + words.unshift('joy'); + words.unshift('kadmonites'); + words.unshift('kid'); + words.unshift('kneaded'); + words.unshift('lack'); + words.unshift('languish'); + words.unshift('lazarus'); + words.unshift('legions'); + words.unshift('libnath'); + words.unshift('likhi'); + words.unshift('lock'); + words.unshift('louder'); + words.unshift('lysias'); + words.unshift('magpiash'); + words.unshift('malchus'); + words.unshift('marble'); + words.unshift('mastery'); + words.unshift('meddle'); + words.unshift('members'); + words.unshift('mesech'); + words.unshift('midian'); + words.unshift('ministered'); + words.unshift('mithnite'); + words.unshift('morasthite'); + words.unshift('mower'); + words.unshift('myrtle'); + words.unshift('naphish'); + words.unshift('necks'); + words.unshift('net'); + words.unshift('noadiah'); + words.unshift('nursed'); + words.unshift('occurrent'); + words.unshift('omnipotent'); + words.unshift('orchard'); + words.unshift('outside'); + words.unshift('owed'); + words.unshift('palti'); + words.unshift('partition'); + words.unshift('paulus'); + words.unshift('peoples'); + words.unshift('persecute'); + words.unshift('phares'); + words.unshift('pilate'); + words.unshift('plagues'); + words.unshift('plentiful'); + words.unshift('poorer'); + words.unshift('powerful'); + words.unshift('presented'); + words.unshift('prison'); + words.unshift('promoted'); + words.unshift('provision'); + words.unshift('purely'); + words.unshift('quarter'); + words.unshift('rahab'); + words.unshift('ravening'); + words.unshift('rebuking'); + words.unshift('refined'); + words.unshift('release'); + words.unshift('rent'); + words.unshift('requirest'); + words.unshift('return'); + words.unshift('rezon'); + words.unshift('riseth'); + words.unshift('roof'); + words.unshift('rump'); + words.unshift('sail'); + words.unshift('sanctuaries'); + words.unshift('savors'); + words.unshift('scorpions'); + words.unshift('second'); + words.unshift('sellers'); + words.unshift('served'); + words.unshift('shaft'); + words.unshift('sharaim'); + words.unshift('shedder'); + words.unshift('shepho'); + words.unshift('shimshai'); + words.unshift('shophan'); + words.unshift('shuppim'); + words.unshift('sihor'); + words.unshift('sippai'); + words.unshift('slandereth'); + words.unshift('smelling'); + words.unshift('softer'); + words.unshift('sores'); + words.unshift('sparrows'); + words.unshift('spoil'); + words.unshift('staff'); + words.unshift('steel'); + words.unshift('stool'); + words.unshift('stretched'); + words.unshift('stumblingblocks'); + words.unshift('suffice'); + words.unshift('surnamed'); + words.unshift('swore'); + words.unshift('take'); + words.unshift('task'); + words.unshift('temani'); + words.unshift('testator'); + words.unshift('thessalonica'); + words.unshift('threatening'); + words.unshift('tie'); + words.unshift('titus'); + words.unshift('torments'); + words.unshift('translation'); + words.unshift('tributaries'); + words.unshift('tubal'); + words.unshift('unchangeable'); + words.unshift('unlawful'); + words.unshift('upbraideth'); + words.unshift('uzza'); + words.unshift('verily'); + words.unshift('visage'); + words.unshift('walk'); + words.unshift('washing'); + words.unshift('wayside'); + words.unshift('wellspring'); + words.unshift('whisperer'); + words.unshift('win'); + words.unshift('withereth'); + words.unshift('work'); + words.unshift('wrest'); + words.unshift('yours'); + words.unshift('zealously'); + words.unshift('zetham'); + words.unshift('zophim'); + words.unshift('zuzims'); + return words; }, - FindSharedSet: function(results) - { - try - { - // FindSharedSet takes an array of reference arrays, and figures out which references are shared + FindSharedSet: function(results) { + try { + // FindSharedSet takes an array of reference arrays, and figures out which references are shared // by all arrays/sets, then returns a single array of references. - for (var j in results) - { + for (var j in results) { var refs = results[j]; - for (var i = 0; i < refs.length; i++) - { + for (var i = 0; i < refs.length; i++) { var r = refs[i].split(":"); // convert references to single integers. // Book * 100000, Chapter * 1000, Verse remains same, add all together. @@ -1064,29 +910,24 @@ var Words = { var result = results[0]; // for each additional result, get the shared set - for (i = 1; i < results.length; i++) - { + for (i = 1; i < results.length; i++) { result = this.ReturnSharedSet(results[i], result); } // convert the references back into book, chapter and verse. - for (i = 0; i < result.length; i++) - { + for (i = 0; i < result.length; i++) { ref = result[i]; result[i] = parseInt(ref / 100000000)+":"+parseInt((ref % 100000000) / 10000)+":"+((ref % 100000000) % 10000); } return result; - } - catch (err) - { + } catch (err) { Util.HandleError(err); } + return null; }, - ReturnSharedSet: function(x, y) - { - try - { + ReturnSharedSet: function(x, y) { + try { /// /// Takes two javascript arrays and returns an array /// containing a set of values shared by arrays. @@ -1096,7 +937,7 @@ var Words = { var i = 0; // declare terminator - var t = (x.length < y.length) ? x.length : y.length + var t = (x.length < y.length) ? x.length : y.length; // sort the arrays x.sort(SortNumeric); @@ -1104,24 +945,20 @@ var Words = { // in this loop, we remove from the arrays, the // values that aren't shared between them. - while (i < t) - { - if (x[i] == y[i]) - { + while (i < t) { + if (x[i] == y[i]) { i++; } - if (x[i] < y[i]) - { + if (x[i] < y[i]) { x.splice(i, 1); } - if (x[i] > y[i]) - { + if (x[i] > y[i]) { y.splice(i, 1); } t = (x.length < y.length) ? x.length : y.length; // we have to make sure to remove any extra values - // at the end of an array when we reach the end of + // at the end of an array when we reach the end of // the other. if (t == i && t < x.length) { x.splice(i, x.length - i); @@ -1133,10 +970,9 @@ var Words = { // we could return y, because at this time, both arrays // are identical. return x; - } - catch (err) - { + } catch (err) { Util.HandleError(err); } + return null; } -} \ No newline at end of file +};