- 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
*.suo
*.orig
Android/DynamicBible/bin

View File

@ -1,8 +1,8 @@
<?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" >
android:versionCode="9"
android:versionName="1.3.6" >
<supports-screens
android:smallScreens="false"
android:normalScreens="true"

View File

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

@ -23,17 +23,15 @@ public class DynamicBibleActivity extends Activity
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.webview);
CookieManager.getInstance().setAcceptCookie(true);
CookieSyncManager.createInstance(this);
CookieSyncManager.getInstance().startSync();
WebSettings webSettings = mWebView.getSettings();
webSettings.setSavePassword(false);
webSettings.setSaveFormData(true);
webSettings.setJavaScriptEnabled(true);
webSettings.setSupportZoom(true);
webSettings.setDomStorageEnabled(true);
webSettings.setDatabasePath("/data/data/" + mWebView.getContext().getPackageName() + "/databases/");
mWebView.setWebViewClient(new WebViewClient()
{
@ -51,20 +49,4 @@ public class DynamicBibleActivity extends Activity
{
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;
}
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, "");
};
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, "");
};
String.prototype.ltrim = function() {
return this.replace(/^\s+/, "");
};
String.prototype.ltrim = function() {
return this.replace(/^\s+/, "");
};
String.prototype.rtrim = function() {
return this.replace(/\s+$/, "");
};
String.prototype.rtrim = function() {
return this.replace(/\s+$/, "");
};
function Traverse(node, testament) {
try {
@ -93,7 +93,6 @@ function Search(sv) {
} else {
// its a verse reference.
var passage = "";
if (q.trim() != "") {
var myref = new Reference(q.trim());
var r = Bible.GetPassage(myref.book, myref.startchapter, myref.endchapter, myref.startverse, myref.endverse);
@ -119,8 +118,22 @@ function Search(sv) {
var Settings = {
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") {
$("#resultwrap").css("float", localStorage.Panes);
$("#searchresultswrap").css("float", localStorage.Panes);
@ -149,24 +162,10 @@ var Settings = {
} else {
$("#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() {
if(typeof(Storage)!=="undefined")
if(typeof(Storage)!=="undefined" && localStorage != null)
{
localStorage.Panes = $("#resultwrap").css("float");
localStorage.Search = $("#searchresultswrap").css("display");
@ -219,17 +218,17 @@ var Settings = {
$("#result").css("font-family", fontfamily);
this.Save();
},
ChangeDisplayStrongsInDialog: function(fontfamily) {
ChangeDisplayStrongsInDialog: function() {
this.Save();
},
SaveResults: function()
{
if(typeof(Storage)!=="undefined")
if(localStorage != null && typeof(Storage)!=="undefined")
{
localStorage.Results = $("#resultwrap").html();
localStorage.SearchResults = $("#searchresultswrap").html();
}
}
localStorage.Results = $("#resultwrap").html();
localStorage.SearchResults = $("#searchresultswrap").html();
}
}
};
var Util = {