BUGFIXES: Fixes a variety of the remaining issues

* css formatting issues
 * upgraded to latest jquery
 * removed requirejs because of incompatibility with jquery mobile
 * multiple bug fixes relating to above
 * search now opens automatically when performing a search
This commit is contained in:
jason.wall 2014-12-25 19:18:38 -05:00
parent 61753ba299
commit f9dc9e5819
10 changed files with 17224 additions and 1814 deletions

View File

@ -1,5 +1,15 @@
a
a.link
{
font-weight: normal;
color: #000;
text-decoration:none;
border-bottom: 1px dotted darkgray;
_border-bottom: 1px solid lightgray; /* IE */
}
a.hiddenlink
{
font-weight: normal;
color: #000;
text-decoration:none;
border-bottom: 1px dotted darkgray;
@ -47,7 +57,6 @@ a:hover {
{
background-color: #fff;
}
#resultwrap {
float: left;
font: 18px georgia;

3
css/jquery.mobile-1.4.5.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -8,16 +8,23 @@
<meta name="keywords" content="AJAX, KJV, King James Version, Strong's Dictionary, Strongs" />
<title>The Bible with Strong's Numbers and Cross References</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/jquery.mobile-1.3.2.min.css" />
<link rel="stylesheet" href="css/jquery.mobile-1.4.5.min.css" />
<link rel="stylesheet" href="css/themes/db.css" />
<style>@import "css/bible.css";</style>
<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/jquery.mobile-1.3.2.min.js"></script>
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/jquery.ui.js"></script>
<script src="js/jquery.slidePanel.js"></script>
<script src="js/jquery.mobile-1.4.5.js"></script>
<script src="js/reference.js"></script>
<script src="js/common.js"></script>
<script src="js/main.js"></script>
<script data-main="js/main" type="text/javascript" src="js/require-jquery.js"></script>
<style>
.panel-content { padding:3px; }
@ -27,18 +34,9 @@
.ui-submit .ui-btn-inner .ui-btn-text { font-size: 1.2em;}
.ui-submit {height:35px;}
/*
.resultbody { max-width: 600px;}
@media all and (min-width: 900px) {
.resultbody {
-webkit-columns: 2;
-moz-columns: 2;
columns: 2;
.ui-block-c div {
margin-top: 9px;
}
}
*/
</style>
</head>
<body>
@ -60,7 +58,7 @@
</div><!-- /content -->
</div>
<div data-role="panel" id="searchpanel" data-theme="a" data-position="right">
<div data-role="panel" id="searchpanel" data-theme="a" data-position="right" data-display="overlay">
<div class="panel-content">
<h3>Search Results: <span id="searchTotal"></span></h3>
<div id="searchresults"></div>

View File

@ -1,24 +1,9 @@
(function() {
var CurrentReferences = {};
define(['jquery', 'reference', 'tagging', 'jquery.ui'],
function($, reference, tagging) {
function SortNumeric(x, y) {
var CurrentReferences = {};
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+$/, "");
};
var Util = {
var Util = {
HandleLink: function(e) {
Search($(e.target).text());
Settings.SaveResults();
@ -54,8 +39,8 @@
}
return vars;
}
};
var Traverse = function(node, testament) {
};
var Traverse = function(node, testament) {
try {
var treeText = "";
if (node != null) {
@ -93,11 +78,10 @@
Util.HandleError(err);
}
return null;
};
var Search = function(sv) {
};
var Search = function(sv) {
try {
var qs = sv.split(";");
for (var x in qs) {
var q = qs[x].trim();
if (q != "") {
@ -105,9 +89,13 @@
if (q.search(/[0-9]/i) == -1) {
// get new results.
Words.FindReferences(q);
$("#searchpanel").panel("open");
} else if (q.search(/(H|G)[0-9]/i) != -1) {
var original_q = q;
// its a strongs lookup
var dict = q.substring(0, 1);
if (dict.search(/h/i) != -1) {
dict = "heb";
} else {
@ -129,12 +117,11 @@
Strongs.DisplayStrongs(results[result]);
//}
}
CurrentReferences[original_q.toString()] = true;
} else {
// its a verse reference.
var passage = "";
if (q.trim() != "") {
var myref = reference.Parse(q.trim());
var myref = new Reference(q.trim());
var r = Bible.GetPassage(myref.book, myref.startchapter, myref.endchapter, myref.startverse, myref.endverse);
Bible.DisplayPassage(r.cs, myref, r.testament);
@ -152,9 +139,12 @@
Util.HandleError(err);
}
//$("#searchpanel").removeClass("ui-panel-closed");
//$("#searchpanel").addClass("ui-panel-open");
//$("#searchpanel").trigger("updatelayout");
return false;
};
var Settings = {
};
var Settings = {
Load: function(skipresults) {
if (typeof (Storage) !== undefined) {
@ -185,10 +175,11 @@
function(i, ref) {
if (ref != undefined && ref.trim() != "")
{
var myref = reference.Parse(ref);
var r = Bible.GetPassage(myref.book, myref.startchapter, myref.endchapter, myref.startverse, myref.endverse);
Search(ref);
//var myref = new Reference(ref);
//var r = Bible.GetPassage(myref.book, myref.startchapter, myref.endchapter, myref.startverse, myref.endverse);
Bible.DisplayPassage(r.cs, myref, r.testament);
//Bible.DisplayPassage(r.cs, myref, r.testament);
}
});
}
@ -231,15 +222,15 @@
SaveResults: function() {
if (typeof localStorage != 'undefined') {
var results = "";
for (ref in CurrentReferences) {
for (var ref in CurrentReferences) {
results += ref + ';';
}
localStorage.Results = results;
localStorage.SearchResults = $("#searchresultswrap").html();
}
}
};
var Bible = {
};
var Bible = {
DisplayPassage: function(cs, ref, testament) {
try {
var r = "";
@ -276,17 +267,6 @@
}
}
var t = $("<div class='passage result'><a href='javascript:void();' class='removeresult' style='border: 0;'><img style='border: 0px;' src='images/delete.png' width='48' height='48' /></a><a href='#' class='trigger left'>&nbsp;</a><div class='tags panel left'></div><span class='resultbody'>" + "<h2><a href='http://www.dynamicbible.com/?r=" + ref.toString() + "'>" + ref.toString() + "</a></h2>" + r + "</span><br clear='all' /></div>");
var tagsform = $("<p>Tags: <br /><input type='text' class='input-addtag' /><button class='btn-addtag' type='button'>Update Tags</button></p>");
tagging.GetTags(
ref.toString(), {
success: function(data) {
var ts = data ?
(data.data ?
data.data.tagList : []) : [];
tagsform.find('.input-addtag').val(ts.join(', '));
}});
t.find(".panel").append(tagsform);
Bible.AttachEvents(t, ref);
$("#result").prepend(t);
CurrentReferences[ref.toString()] = true;
@ -391,8 +371,8 @@
panelCss: 'margin-top: 55px; border: 2px solid #666;'
});
}
};
var Strongs = {
};
var Strongs = {
GetStrongs: function(sn, dict) {
try {
var self = this;
@ -492,7 +472,7 @@
$(this).find("r").each(function(j) {
var ref = $(this).attr("r").split(";");
crtxt += "<a href='javascript:void();' class='link'>" + reference.BookName(ref[0]) + " " + ref[1] + ":" + ref[2] + "</a>, ";
crtxt += "<a href='javascript:void();' class='link'>" + BookName(ref[0]) + " " + ref[1] + ":" + ref[2] + "</a>, ";
});
crtxt = crtxt.substr(0, crtxt.length - 2);
crtxt += "<br />";
@ -576,8 +556,8 @@
o.html("Hide");
}
}
};
var Words = {
};
var Words = {
ConvertResultsToArray: function(r) {
try {
var results = new Array();
@ -595,7 +575,7 @@
var txt = "<h4>Query: <a href='javascript:void();' class='link'>" + q + "</a></h4><ul>";
for (var i = 0; i < results.length; i++) {
var r = results[i].split(":");
txt += "<li /><a href='javascript:void();' class='link' alt='" + reference.BookName(r[0]) + " " + r[1] + ":" + r[2] + "'>" + reference.BookName(r[0]) + " " + r[1] + ":" + r[2] + "</a>";
txt += "<li /><a href='javascript:void();' class='link' alt='" + BookName(r[0]) + " " + r[1] + ":" + r[2] + "'>" + BookName(r[0]) + " " + r[1] + ":" + r[2] + "</a>";
}
txt += "</ul>";
@ -1033,16 +1013,4 @@
Util.HandleLink(e);
});
}
};
return {
Traverse: Traverse,
Search: Search,
Settings: Settings,
Util: Util,
Bible: Bible,
Strongs: Strongs,
Words: Words
};
}
);
})();
};

4
js/jquery-1.11.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

15454
js/jquery.mobile-1.4.5.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +1,24 @@
require(["jquery", "db", "common", "reference", "jquery.cookie", "jquery.ui", "jquery.slidePanel"],
function($, db, common, ref) {
$(document).ready(function()
{
$(document).ready(function()
{
$("#searchvalue").keypress(function(event) {
if (event.which === 13) {
common.Search($("#searchvalue").val());
Search($("#searchvalue").val());
return false;
}
});
$("#searchbtn").click(function()
{
common.Search($("#searchvalue").val());
Search($("#searchvalue").val());
return false;
});
$("#growfont").click(function()
{
common.Settings.IncreaseResultFontSize();
Settings.IncreaseResultFontSize();
return false;
});
$("#shrinkfont").click(function()
{
common.Settings.DecreaseResultFontSize();
Settings.DecreaseResultFontSize();
return false;
});
$("#showhelp").click(function()
@ -34,43 +32,35 @@ require(["jquery", "db", "common", "reference", "jquery.cookie", "jquery.ui", "j
});
$("#changefont").change(function()
{
common.Settings.ChangeResultFont($("#changefont").val());
Settings.ChangeResultFont($("#changefont").val());
return false;
});
// load querystring
var ref = decodeURIComponent(common.Util.GetUrlVars().r);
var ref = decodeURIComponent(Util.GetUrlVars().r);
if (ref !== "undefined") {
// remember the settings, first, because if you have results, the load process would wipe out the passage you want to load.
common.Settings.Load();
// remember the settings, first, because if you have results, the load process would wipe out the passage you want to load.
Settings.Load();
// now load the passage from the querystring.
common.Search(ref);
Search(ref);
$("#searchvalue").val(ref);
} else {
common.Settings.Load();
Settings.Load();
}
// you need to do this last, otherwise the settings load resets the window height.
// you need to do this last, otherwise the settings load resets the window height.
$(window).bind("resize", function()
{
$(".my-breakpoint.ui-grid-c .ui-block-a").css("width", 55);
$(".my-breakpoint.ui-grid-c .ui-block-b").css("width", window.innerWidth - 230);
$(".my-breakpoint.ui-grid-c .ui-block-c").css("width", 100);
$(".my-breakpoint.ui-grid-c .ui-block-d").css("width", 55);
$("#searchresults").css("height", window.innerHeight-100);
$("#searchresults").css("height", window.innerHeight - 100);
return false;
});
$(".my-breakpoint.ui-grid-c .ui-block-a").css("width", 55);
$(".my-breakpoint.ui-grid-c .ui-block-b").css("width", window.innerWidth - 235);
$(".my-breakpoint.ui-grid-c .ui-block-c").css("width", 100);
$(".my-breakpoint.ui-grid-c .ui-block-d").css("width", 55);
$("#searchresults").css("height", window.innerHeight - 100);
$("#searchresults").css("height", window.innerHeight-100);
});
});
});

View File

@ -3,36 +3,145 @@
// Jason@walljm.com // www.walljm.com
// Jeremy@marzhillstudios.com // jeremy.marzhillstudios.com
define("reference",
function() {
String.prototype.trim = function() {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, "");
};
};
String.prototype.ltrim = function() {
String.prototype.ltrim = function() {
return this.replace(/^\s+/, "");
};
};
String.prototype.rtrim = function() {
String.prototype.rtrim = function() {
return this.replace(/\s+$/, "");
};
function Reference(ref)
{
var r = {
start: {
first: '',
second: ''
},
end: {
first: '',
second: ''
}
};
function parseReference(ref, r) {
var rest = ParseBook(ref, r.start, r);
rest = parseFirstNum(rest, r.start, r);
rest = maybeParseSecondNum(rest, r.start, r);
rest = maybeParseRangeSep(rest, r, r);
rest = maybeParseBook(rest, r.end, r);
rest = maybeParseFirstNumOrVerse(rest, r.end, r);
rest = maybeParseSecondNum(rest, r.end, r);
return r;
}
// First collect all our tokens so to speak
this.parseReference(ref.toLowerCase().trim(), r);
this.book = r.start.book;
this.bookname = r.start.bookname;
this.longbookname = r.start.longbookname;
this.startchapter = r.start.first;
this.endchapter = r.start.first;
this.startverse = '1';
function ParseBook(ref, data) {
// Then start our statemachine.
// Determine start verse
if (r.start.second != '') {
this.startverse = r.start.second;
this.endverse = '*';
}
// Determine possible end verse
if (r.end.second != '') {
this.endverse = r.end.second;
}
// Enforce some general data cleanliness
if (r.end.second != '*' && Number(r.end.second) < Number(r.start.second)) {
this.endverse = this.startverse;
}
// Determine end chapter and verse
if (r.end.first == '') {
if (r.start.second == '' || typeof r.end.book != 'undefined') {
this.endchapter = r.end.second || r.start.first;
this.endverse = '*';
}
} else {
this.endchapter = r.end.first;
}
}
function BookName(booknum) {
var book = new Array();
book[0] = "";
book[1] = "Genesis";
book[2] = "Exodus";
book[3] = "Leviticus";
book[4] = "Numbers";
book[5] = "Deuteronomy";
book[6] = "Joshua";
book[7] = "Judges";
book[8] = "Ruth";
book[9] = "1 Samuel";
book[10] = "2 Samuel";
book[11] = "1 Kings";
book[12] = "2 Kings";
book[13] = "1 Chronicles";
book[14] = "2 Chronicles";
book[15] = "Ezra";
book[16] = "Nehemiah";
book[17] = "Esther";
book[18] = "Job";
book[19] = "Psalm";
book[20] = "Proverbs";
book[21] = "Ecclesiastes";
book[22] = "Song of Songs";
book[23] = "Isaiah";
book[24] = "Jeremiah";
book[25] = "Lamentations";
book[26] = "Ezekiel";
book[27] = "Daniel";
book[28] = "Hosea";
book[29] = "Joel";
book[30] = "Amos";
book[31] = "Obadiah";
book[32] = "Jonah";
book[33] = "Micah";
book[34] = "Nahum";
book[35] = "Habakkuk";
book[36] = "Zephaniah";
book[37] = "Haggai";
book[38] = "Zechariah";
book[39] = "Malachi";
book[40] = "Matthew";
book[41] = "Mark";
book[42] = "Luke";
book[43] = "John";
book[44] = "Acts";
book[45] = "Romans";
book[46] = "1 Corinthians";
book[47] = "2 Corinthians";
book[48] = "Galatians";
book[49] = "Ephesians";
book[50] = "Philippians";
book[51] = "Colossians";
book[52] = "1 Thessalonians";
book[53] = "2 Thessalonians";
book[54] = "1 Timothy";
book[55] = "2 Timothy";
book[56] = "Titus";
book[57] = "Philemon";
book[58] = "Hebrews";
book[59] = "James";
book[60] = "1 Peter";
book[61] = "2 Peter";
book[62] = "1 John";
book[63] = "2 John";
book[64] = "3 John";
book[65] = "Jude";
book[66] = "Revelation";
return book[booknum];
}
Reference.prototype.parseBook = function(ref, data) {
ref = ref.toLowerCase().trim();
var fbook = ref.substring(0, ref.search(/\w\s+\d/i)+1);
if (!fbook) fbook = ref;
var rest = ref.slice(ref.search(/\w\s+\d/i)+1);
var fbook = ref.substring(0, ref.search(/\w\s+\d/i) + 1);
if (!fbook)
fbook = ref;
var rest = ref.slice(ref.search(/\w\s+\d/i) + 1);
if (fbook.search(/\b(genesis|gen|ge|gn)\b/i) != -1) {
data.book = 1;
@ -437,9 +546,9 @@ define("reference",
data.lastchapter = 22;
}
return rest;
}
};
function parseFirstNum(ref, r, errAcc) {
Reference.prototype.parseFirstNum = function(ref, r, errAcc) {
ref = ref.ltrim();
var found = false;
for (var i = 0; i <= ref.length; i++) {
@ -460,9 +569,9 @@ define("reference",
}
}
return "";
}
};
function parseSecondNum(ref, r, errAcc, skipColon) {
Reference.prototype.parseSecondNum = function(ref, r, errAcc, skipColon) {
ref = ref.toLowerCase().ltrim();
if (!skipColon) {
if (ref[0] != ":") {
@ -488,168 +597,52 @@ define("reference",
}
}
return "";
}
};
function maybeDo(ref, r, errAcc, f) {
Reference.prototype.maybeDo = function(ref, r, errAcc, f) {
ref = ref.toLowerCase().ltrim();
if (ref != "") {
return f(ref, r, errAcc);
}
return "";
}
};
function maybeParseBook(ref, r, errAcc) {
return maybeDo(ref, r, errAcc, ParseBook);
}
Reference.prototype.maybeParseBook = function(ref, r, errAcc) {
var self = this;
return self.maybeDo(ref, r, errAcc, self.parseBook);
};
function maybeParseSecondNum(ref, r, errAcc, skipColon) {
return maybeDo(ref, r, errAcc, function (ref, r, errAcc) {
return parseSecondNum(ref, r, errAcc, skipColon);
Reference.prototype.maybeParseSecondNum = function(ref, r, errAcc, skipColon) {
var self = this;
return self.maybeDo(ref, r, errAcc, function(ref, r, errAcc) {
return self.parseSecondNum(ref, r, errAcc, skipColon);
});
}
};
function maybeParseFirstNumOrVerse(ref, r, errAcc) {
return maybeDo(ref, r, errAcc, function(ref, r, errAcc) {
Reference.prototype.maybeParseFirstNumOrVerse = function(ref, r, errAcc) {
var self = this;
return self.maybeDo(ref, r, errAcc, function(ref, r, errAcc) {
if (typeof r.book != -1) {
if (ref.search(/:/) != -1) {
ref = parseFirstNum(ref, r, errAcc);
ref = self.parseFirstNum(ref, r, errAcc);
}
return parseSecondNum(ref, r, errAcc, true);
return self.parseSecondNum(ref, r, errAcc, true);
}
return "";
});
}
};
function maybeParseRangeSep(ref, r, errAcc) {
return maybeDo(ref.ltrim(), r, errAcc, function(ref, r, errAcc) {
Reference.prototype.maybeParseRangeSep = function(ref, r, errAcc) {
var self = this;
return self.maybeDo(ref.ltrim(), r, errAcc, function(ref, r, errAcc) {
if (ref[0] == "-") {
return ref.slice(1).ltrim();
}
return "";
});
}
};
function Reference(ref)
{
var r = {
start: {
first: '',
second: ''
},
end: {
first: '',
second: ''
}
};
// First collect all our tokens so to speak
parseReference(ref.toLowerCase().trim(), r);
this.book = r.start.book;
this.bookname = r.start.bookname;
this.longbookname = r.start.longbookname;
this.startchapter = r.start.first;
this.endchapter = r.start.first;
this.startverse = '1';
// Then start our statemachine.
// Determine start verse
if (r.start.second != '') {
this.startverse = r.start.second;
this.endverse = '*';
}
// Determine possible end verse
if (r.end.second != '') {
this.endverse = r.end.second;
}
// Enforce some general data cleanliness
if (r.end.second != '*' && Number(r.end.second) < Number(r.start.second)) {
this.endverse = this.startverse;
}
// Determine end chapter and verse
if (r.end.first == '') {
if (r.start.second == '' || typeof r.end.book != 'undefined') {
this.endchapter = r.end.second || r.start.first;
this.endverse = '*';
}
} else {
this.endchapter = r.end.first;
}
}
function BookName(booknum) {
var book = new Array();
book[0] = "";
book[1] = "Genesis";
book[2] = "Exodus";
book[3] = "Leviticus";
book[4] = "Numbers";
book[5] = "Deuteronomy";
book[6] = "Joshua";
book[7] = "Judges";
book[8] = "Ruth";
book[9] = "1 Samuel";
book[10] = "2 Samuel";
book[11] = "1 Kings";
book[12] = "2 Kings";
book[13] = "1 Chronicles";
book[14] = "2 Chronicles";
book[15] = "Ezra";
book[16] = "Nehemiah";
book[17] = "Esther";
book[18] = "Job";
book[19] = "Psalm";
book[20] = "Proverbs";
book[21] = "Ecclesiastes";
book[22] = "Song of Songs";
book[23] = "Isaiah";
book[24] = "Jeremiah";
book[25] = "Lamentations";
book[26] = "Ezekiel";
book[27] = "Daniel";
book[28] = "Hosea";
book[29] = "Joel";
book[30] = "Amos";
book[31] = "Obadiah";
book[32] = "Jonah";
book[33] = "Micah";
book[34] = "Nahum";
book[35] = "Habakkuk";
book[36] = "Zephaniah";
book[37] = "Haggai";
book[38] = "Zechariah";
book[39] = "Malachi";
book[40] = "Matthew";
book[41] = "Mark";
book[42] = "Luke";
book[43] = "John";
book[44] = "Acts";
book[45] = "Romans";
book[46] = "1 Corinthians";
book[47] = "2 Corinthians";
book[48] = "Galatians";
book[49] = "Ephesians";
book[50] = "Philippians";
book[51] = "Colossians";
book[52] = "1 Thessalonians";
book[53] = "2 Thessalonians";
book[54] = "1 Timothy";
book[55] = "2 Timothy";
book[56] = "Titus";
book[57] = "Philemon";
book[58] = "Hebrews";
book[59] = "James";
book[60] = "1 Peter";
book[61] = "2 Peter";
book[62] = "1 John";
book[63] = "2 John";
book[64] = "3 John";
book[65] = "Jude";
book[66] = "Revelation";
return book[booknum];
}
Reference.prototype.toString = function() {
Reference.prototype.toString = function() {
var ref = this.bookname.concat(" ").
concat(this.startchapter).concat(":").
concat(this.startverse);
@ -658,8 +651,9 @@ define("reference",
}
return ref.concat("-").concat(this.endchapter)
.concat(":").concat(this.endverse);
};
Reference.prototype.toDict = function() {
};
Reference.prototype.toDict = function() {
return {
startBook: this.bookname,
startChapter: this.startchapter,
@ -668,11 +662,15 @@ define("reference",
endChapter: this.startchapter,
endVerse: this.endverse
};
};
return {
Parse: function(ref) {return new Reference(ref);},
ParseBook: ParseBook,
BookName: BookName
};
}
);
};
Reference.prototype.parseReference = function(ref, r) {
var rest = this.parseBook(ref, r.start, r);
rest = this.parseFirstNum(rest, r.start, r);
rest = this.maybeParseSecondNum(rest, r.start, r);
rest = this.maybeParseRangeSep(rest, r, r);
rest = this.maybeParseBook(rest, r.end, r);
rest = this.maybeParseFirstNumOrVerse(rest, r.end, r);
rest = this.maybeParseSecondNum(rest, r.end, r);
return r;
};