- further checks to prevent throwing null when localStorage isn't defined.

This commit is contained in:
walljm 2013-04-18 13:28:18 -04:00
parent 25d11136b9
commit 7332d1bdaa
10 changed files with 68 additions and 117 deletions

View File

@ -3,3 +3,4 @@ DynamicBibleUtility/DynamicBibleUtility/bin
DynamicBibleUtility/DynamicBibleUtility/obj DynamicBibleUtility/DynamicBibleUtility/obj
*.suo *.suo
*.orig *.orig
Android/DynamicBible/bin

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="walljm.dynamicbible" package="walljm.dynamicbible"
android:versionCode="8" android:versionCode="9"
android:versionName="1.3.5" > android:versionName="1.3.6" >
<supports-screens <supports-screens
android:smallScreens="false" android:smallScreens="false"
android:normalScreens="true" android:normalScreens="true"

View File

@ -2,17 +2,17 @@ function SortNumeric(x, y) {
return x - y; return x - y;
} }
String.prototype.trim = function() { String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, ""); return this.replace(/^\s+|\s+$/g, "");
}; };
String.prototype.ltrim = function() { String.prototype.ltrim = function() {
return this.replace(/^\s+/, ""); return this.replace(/^\s+/, "");
}; };
String.prototype.rtrim = function() { String.prototype.rtrim = function() {
return this.replace(/\s+$/, ""); return this.replace(/\s+$/, "");
}; };
function Traverse(node, testament) { function Traverse(node, testament) {
try { try {
@ -93,7 +93,6 @@ function Search(sv) {
} else { } else {
// its a verse reference. // its a verse reference.
var passage = "";
if (q.trim() != "") { if (q.trim() != "") {
var myref = new Reference(q.trim()); var myref = new Reference(q.trim());
var r = Bible.GetPassage(myref.book, myref.startchapter, myref.endchapter, myref.startverse, myref.endverse); var r = Bible.GetPassage(myref.book, myref.startchapter, myref.endchapter, myref.startverse, myref.endverse);
@ -119,8 +118,22 @@ function Search(sv) {
var Settings = { var Settings = {
Load: function() { Load: function() {
if(typeof(Storage)!=="undefined") if(localStorage != null && typeof(Storage)!=="undefined")
{ {
if (localStorage.Results !== "undefined" && localStorage.SearchResults !== "undefined") {
$("#resultwrap").html(localStorage.Results);
$("#searchresultswrap").html(localStorage.SearchResults);
$("#resultwrap").find(".hiddenlink").click(function(e) {
Util.HandleHiddenLink(e);
});
$("#resultwrap").find(".removeresult").click(function(e) {
Util.RemoveResult(e);
});
$("#searchresultswrap").find(".link").click(function(e) {
Util.HandleLink(e);
});
}
if (localStorage.Panes !== "undefined") { if (localStorage.Panes !== "undefined") {
$("#resultwrap").css("float", localStorage.Panes); $("#resultwrap").css("float", localStorage.Panes);
$("#searchresultswrap").css("float", localStorage.Panes); $("#searchresultswrap").css("float", localStorage.Panes);
@ -149,24 +162,10 @@ var Settings = {
} else { } else {
$("#display-strongs-as-dialog")[0].checked = true; $("#display-strongs-as-dialog")[0].checked = true;
} }
if (localStorage.Results !== "undefined" && localStorage.SearchResults !== "undefined") {
$("#resultwrap").html(localStorage.Results);
$("#searchresultswrap").html(localStorage.SearchResults);
$("#resultwrap").find(".hiddenlink").click(function(e) {
Util.HandleHiddenLink(e);
});
$("#resultwrap").find(".removeresult").click(function(e) {
Util.RemoveResult(e);
});
$("#searchresultswrap").find(".link").click(function(e) {
Util.HandleLink(e);
});
}
} }
}, },
Save: function() { Save: function() {
if(typeof(Storage)!=="undefined") if(typeof(Storage)!=="undefined" && localStorage != null)
{ {
localStorage.Panes = $("#resultwrap").css("float"); localStorage.Panes = $("#resultwrap").css("float");
localStorage.Search = $("#searchresultswrap").css("display"); localStorage.Search = $("#searchresultswrap").css("display");
@ -219,17 +218,17 @@ var Settings = {
$("#result").css("font-family", fontfamily); $("#result").css("font-family", fontfamily);
this.Save(); this.Save();
}, },
ChangeDisplayStrongsInDialog: function(fontfamily) { ChangeDisplayStrongsInDialog: function() {
this.Save(); this.Save();
}, },
SaveResults: function() SaveResults: function()
{ {
if(typeof(Storage)!=="undefined") if(localStorage != null && typeof(Storage)!=="undefined")
{ {
localStorage.Results = $("#resultwrap").html(); localStorage.Results = $("#resultwrap").html();
localStorage.SearchResults = $("#searchresultswrap").html(); localStorage.SearchResults = $("#searchresultswrap").html();
} }
} }
}; };
var Util = { var Util = {

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="walljm.dynamicbible"
android:versionCode="8"
android:versionName="1.3.5" >
<supports-screens
android:smallScreens="false"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
/>
<uses-sdk android:minSdkVersion="12" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".DynamicBibleActivity"
android:configChanges="keyboardHidden|orientation" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Binary file not shown.

View File

@ -24,16 +24,14 @@ public class DynamicBibleActivity extends Activity
setContentView(R.layout.main); setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.webview); mWebView = (WebView) findViewById(R.id.webview);
CookieManager.getInstance().setAcceptCookie(true);
CookieSyncManager.createInstance(this);
CookieSyncManager.getInstance().startSync();
WebSettings webSettings = mWebView.getSettings(); WebSettings webSettings = mWebView.getSettings();
webSettings.setSavePassword(false); webSettings.setSavePassword(false);
webSettings.setSaveFormData(true); webSettings.setSaveFormData(true);
webSettings.setJavaScriptEnabled(true); webSettings.setJavaScriptEnabled(true);
webSettings.setSupportZoom(true); webSettings.setSupportZoom(true);
webSettings.setDomStorageEnabled(true);
webSettings.setDatabasePath("/data/data/" + mWebView.getContext().getPackageName() + "/databases/");
mWebView.setWebViewClient(new WebViewClient() mWebView.setWebViewClient(new WebViewClient()
{ {
@ -51,20 +49,4 @@ public class DynamicBibleActivity extends Activity
{ {
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
} }
@Override
public void onResume()
{
super.onResume();
CookieSyncManager.getInstance().startSync();
}
@Override
public void onPause()
{
super.onPause();
CookieSyncManager.getInstance().sync();
CookieSyncManager.getInstance().stopSync();
}
} }

View File

@ -2,17 +2,17 @@ function SortNumeric(x, y) {
return x - y; return x - y;
} }
String.prototype.trim = function() { String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, ""); return this.replace(/^\s+|\s+$/g, "");
}; };
String.prototype.ltrim = function() { String.prototype.ltrim = function() {
return this.replace(/^\s+/, ""); return this.replace(/^\s+/, "");
}; };
String.prototype.rtrim = function() { String.prototype.rtrim = function() {
return this.replace(/\s+$/, ""); return this.replace(/\s+$/, "");
}; };
function Traverse(node, testament) { function Traverse(node, testament) {
try { try {
@ -93,7 +93,6 @@ function Search(sv) {
} else { } else {
// its a verse reference. // its a verse reference.
var passage = "";
if (q.trim() != "") { if (q.trim() != "") {
var myref = new Reference(q.trim()); var myref = new Reference(q.trim());
var r = Bible.GetPassage(myref.book, myref.startchapter, myref.endchapter, myref.startverse, myref.endverse); var r = Bible.GetPassage(myref.book, myref.startchapter, myref.endchapter, myref.startverse, myref.endverse);
@ -119,8 +118,22 @@ function Search(sv) {
var Settings = { var Settings = {
Load: function() { Load: function() {
if(typeof(Storage)!=="undefined") if(localStorage != null && typeof(Storage)!=="undefined")
{ {
if (localStorage.Results !== "undefined" && localStorage.SearchResults !== "undefined") {
$("#resultwrap").html(localStorage.Results);
$("#searchresultswrap").html(localStorage.SearchResults);
$("#resultwrap").find(".hiddenlink").click(function(e) {
Util.HandleHiddenLink(e);
});
$("#resultwrap").find(".removeresult").click(function(e) {
Util.RemoveResult(e);
});
$("#searchresultswrap").find(".link").click(function(e) {
Util.HandleLink(e);
});
}
if (localStorage.Panes !== "undefined") { if (localStorage.Panes !== "undefined") {
$("#resultwrap").css("float", localStorage.Panes); $("#resultwrap").css("float", localStorage.Panes);
$("#searchresultswrap").css("float", localStorage.Panes); $("#searchresultswrap").css("float", localStorage.Panes);
@ -149,24 +162,10 @@ var Settings = {
} else { } else {
$("#display-strongs-as-dialog")[0].checked = true; $("#display-strongs-as-dialog")[0].checked = true;
} }
if (localStorage.Results !== "undefined" && localStorage.SearchResults !== "undefined") {
$("#resultwrap").html(localStorage.Results);
$("#searchresultswrap").html(localStorage.SearchResults);
$("#resultwrap").find(".hiddenlink").click(function(e) {
Util.HandleHiddenLink(e);
});
$("#resultwrap").find(".removeresult").click(function(e) {
Util.RemoveResult(e);
});
$("#searchresultswrap").find(".link").click(function(e) {
Util.HandleLink(e);
});
}
} }
}, },
Save: function() { Save: function() {
if(typeof(Storage)!=="undefined") if(typeof(Storage)!=="undefined" && localStorage != null)
{ {
localStorage.Panes = $("#resultwrap").css("float"); localStorage.Panes = $("#resultwrap").css("float");
localStorage.Search = $("#searchresultswrap").css("display"); localStorage.Search = $("#searchresultswrap").css("display");
@ -219,17 +218,17 @@ var Settings = {
$("#result").css("font-family", fontfamily); $("#result").css("font-family", fontfamily);
this.Save(); this.Save();
}, },
ChangeDisplayStrongsInDialog: function(fontfamily) { ChangeDisplayStrongsInDialog: function() {
this.Save(); this.Save();
}, },
SaveResults: function() SaveResults: function()
{ {
if(typeof(Storage)!=="undefined") if(localStorage != null && typeof(Storage)!=="undefined")
{ {
localStorage.Results = $("#resultwrap").html(); localStorage.Results = $("#resultwrap").html();
localStorage.SearchResults = $("#searchresultswrap").html(); localStorage.SearchResults = $("#searchresultswrap").html();
} }
} }
}; };
var Util = { var Util = {