- added support for html localStorage for settings (should work on tablet now)

- added support to save strong dialog option, and results.
This commit is contained in:
walljm 2013-04-16 16:41:19 -04:00
parent 185579e1df
commit be32335b40
6 changed files with 116 additions and 46 deletions

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="6" android:versionCode="7"
android:versionName="1.3.3" > android:versionName="1.3.4" >
<supports-screens <supports-screens
android:smallScreens="false" android:smallScreens="false"
android:normalScreens="true" android:normalScreens="true"

View File

@ -52,6 +52,11 @@
{ {
Settings.ChangeResultFont($("#changefont").val()); Settings.ChangeResultFont($("#changefont").val());
return false; return false;
});
$("#display-strongs-as-dialog").change(function()
{
Settings.ChangeDisplayStrongsInDialog($("#display-strongs-as-dialog")[0].checked);
return false;
}); });
$(window).bind("resize", function() $(window).bind("resize", function()
{ {

View File

@ -106,7 +106,8 @@ function Search(sv) {
$( "#result" ).sortable({ $( "#result" ).sortable({
axis: "x", axis: "x",
handle: ".handle" handle: ".handle"
}); });
Settings.SaveResults();
} }
catch (err) { catch (err) {
Util.HandleError(err); Util.HandleError(err);
@ -118,14 +119,12 @@ function Search(sv) {
var Settings = { var Settings = {
Load: function() { Load: function() {
var str = $.cookie('settings'); if(typeof(Storage)!=="undefined")
if (str != null) { {
var s = str.split(","); $("#resultwrap").css("float", localStorage.Panes);
$("#searchresultswrap").css("float", localStorage.Panes);
$("#resultwrap").css("float", s[0]); if (localStorage.Search == "none") {
$("#searchresultswrap").css("float", s[0]);
if (s[1] == "none") {
$("#searchresultswrap").css("display", "none"); $("#searchresultswrap").css("display", "none");
$("#showhidesearch").html("Show Search"); $("#showhidesearch").html("Show Search");
$("#resultwrap").css("width", "100%"); $("#resultwrap").css("width", "100%");
@ -136,22 +135,39 @@ var Settings = {
$("#resultwrap").css("width", "70%"); $("#resultwrap").css("width", "70%");
} }
$("#result").css("font-size", s[2]); $("#result").css("font-size", localStorage.FontSize);
$("#result").css("font-family", s[3]); $("#result").css("font-family", localStorage.Font);
$("#changefont").val(localStorage.Font);
if (localStorage.StrongsAsDialog == "false") {
$("#display-strongs-as-dialog")[0].checked = false;
} else {
$("#display-strongs-as-dialog")[0].checked = true;
}
$("#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() {
var s = {}; if(typeof(Storage)!=="undefined")
s.Panes = $("#resultwrap").css("float"); {
s.Search = $("#searchresultswrap").css("display"); localStorage.Panes = $("#resultwrap").css("float");
s.FontSize = $("#result").css("font-size"); localStorage.Search = $("#searchresultswrap").css("display");
s.Font = $("#result").css("font-family"); localStorage.FontSize = $("#result").css("font-size");
localStorage.Font = $("#result").css("font-family");
var str = s.Panes + "," + s.Search + "," + s.FontSize + "," + s.Font; localStorage.StrongsAsDialog = $("#display-strongs-as-dialog")[0].checked;
localStorage.Results = $("#result").html();
$.cookie('settings', str, { }
expires: 365
});
}, },
ShowHideSearch: function() { ShowHideSearch: function() {
var o = $("#showhidesearch"); var o = $("#showhidesearch");
@ -196,23 +212,37 @@ var Settings = {
ChangeResultFont: function(fontfamily) { ChangeResultFont: function(fontfamily) {
$("#result").css("font-family", fontfamily); $("#result").css("font-family", fontfamily);
this.Save(); this.Save();
},
ChangeDisplayStrongsInDialog: function(fontfamily) {
this.Save();
},
SaveResults: function()
{
localStorage.Results = $("#resultwrap").html();
localStorage.SearchResults = $("#searchresultswrap").html();
} }
}; };
var Util = { var Util = {
HandleLink: function(e) { HandleLink: function(e) {
Search($(e.target).text()); Search($(e.target).text());
Settings.SaveResults();
}, },
HandleHiddenLink: function(e) { HandleHiddenLink: function(e) {
Search($(e.target).find(".searchvalue").text()); Search($(e.target).find(".searchvalue").text());
Settings.SaveResults();
}, },
RemoveResult: function(e) { RemoveResult: function(e) {
$(e.target).parent().parent().remove(); $(e.target).parent().parent().remove();
Settings.SaveResults();
}, },
HandleError: function(e) { HandleError: function(e) {
// for now we're going to put the error in the main result div. // for now we're going to put the error in the main result div.
var t = $("<div class='strongsdef result'><a href='javascript:void();' class='removeresult' style='border: 0;'><img style='border: 0px;' src='images/delete.png' width='48' height='48' /></a><span class='resultbody'>" + e + "</span><br clear='all' /></div>"); var t = $("<div class='strongsdef result'><a href='javascript:void();' class='removeresult' style='border: 0;'><img style='border: 0px;' src='images/delete.png' width='48' height='48' /></a><span class='resultbody'>" + e + "</span><br clear='all' /></div>");
$("#result").prepend(t); $("#result").prepend(t);
t.find(".removeresult").click(function(e) {
Util.RemoveResult(e);
});
return false; return false;
} }
}; };

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="6" android:versionCode="7"
android:versionName="1.3.3" > android:versionName="1.3.4" >
<supports-screens <supports-screens
android:smallScreens="false" android:smallScreens="false"
android:normalScreens="true" android:normalScreens="true"

View File

@ -52,6 +52,11 @@
{ {
Settings.ChangeResultFont($("#changefont").val()); Settings.ChangeResultFont($("#changefont").val());
return false; return false;
});
$("#display-strongs-as-dialog").change(function()
{
Settings.ChangeDisplayStrongsInDialog($("#display-strongs-as-dialog")[0].checked);
return false;
}); });
$(window).bind("resize", function() $(window).bind("resize", function()
{ {

View File

@ -106,7 +106,8 @@ function Search(sv) {
$( "#result" ).sortable({ $( "#result" ).sortable({
axis: "x", axis: "x",
handle: ".handle" handle: ".handle"
}); });
Settings.SaveResults();
} }
catch (err) { catch (err) {
Util.HandleError(err); Util.HandleError(err);
@ -118,14 +119,12 @@ function Search(sv) {
var Settings = { var Settings = {
Load: function() { Load: function() {
var str = $.cookie('settings'); if(typeof(Storage)!=="undefined")
if (str != null) { {
var s = str.split(","); $("#resultwrap").css("float", localStorage.Panes);
$("#searchresultswrap").css("float", localStorage.Panes);
$("#resultwrap").css("float", s[0]); if (localStorage.Search == "none") {
$("#searchresultswrap").css("float", s[0]);
if (s[1] == "none") {
$("#searchresultswrap").css("display", "none"); $("#searchresultswrap").css("display", "none");
$("#showhidesearch").html("Show Search"); $("#showhidesearch").html("Show Search");
$("#resultwrap").css("width", "100%"); $("#resultwrap").css("width", "100%");
@ -136,22 +135,39 @@ var Settings = {
$("#resultwrap").css("width", "70%"); $("#resultwrap").css("width", "70%");
} }
$("#result").css("font-size", s[2]); $("#result").css("font-size", localStorage.FontSize);
$("#result").css("font-family", s[3]); $("#result").css("font-family", localStorage.Font);
$("#changefont").val(localStorage.Font);
if (localStorage.StrongsAsDialog == "false") {
$("#display-strongs-as-dialog")[0].checked = false;
} else {
$("#display-strongs-as-dialog")[0].checked = true;
}
$("#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() {
var s = {}; if(typeof(Storage)!=="undefined")
s.Panes = $("#resultwrap").css("float"); {
s.Search = $("#searchresultswrap").css("display"); localStorage.Panes = $("#resultwrap").css("float");
s.FontSize = $("#result").css("font-size"); localStorage.Search = $("#searchresultswrap").css("display");
s.Font = $("#result").css("font-family"); localStorage.FontSize = $("#result").css("font-size");
localStorage.Font = $("#result").css("font-family");
var str = s.Panes + "," + s.Search + "," + s.FontSize + "," + s.Font; localStorage.StrongsAsDialog = $("#display-strongs-as-dialog")[0].checked;
localStorage.Results = $("#result").html();
$.cookie('settings', str, { }
expires: 365
});
}, },
ShowHideSearch: function() { ShowHideSearch: function() {
var o = $("#showhidesearch"); var o = $("#showhidesearch");
@ -196,23 +212,37 @@ var Settings = {
ChangeResultFont: function(fontfamily) { ChangeResultFont: function(fontfamily) {
$("#result").css("font-family", fontfamily); $("#result").css("font-family", fontfamily);
this.Save(); this.Save();
},
ChangeDisplayStrongsInDialog: function(fontfamily) {
this.Save();
},
SaveResults: function()
{
localStorage.Results = $("#resultwrap").html();
localStorage.SearchResults = $("#searchresultswrap").html();
} }
}; };
var Util = { var Util = {
HandleLink: function(e) { HandleLink: function(e) {
Search($(e.target).text()); Search($(e.target).text());
Settings.SaveResults();
}, },
HandleHiddenLink: function(e) { HandleHiddenLink: function(e) {
Search($(e.target).find(".searchvalue").text()); Search($(e.target).find(".searchvalue").text());
Settings.SaveResults();
}, },
RemoveResult: function(e) { RemoveResult: function(e) {
$(e.target).parent().parent().remove(); $(e.target).parent().parent().remove();
Settings.SaveResults();
}, },
HandleError: function(e) { HandleError: function(e) {
// for now we're going to put the error in the main result div. // for now we're going to put the error in the main result div.
var t = $("<div class='strongsdef result'><a href='javascript:void();' class='removeresult' style='border: 0;'><img style='border: 0px;' src='images/delete.png' width='48' height='48' /></a><span class='resultbody'>" + e + "</span><br clear='all' /></div>"); var t = $("<div class='strongsdef result'><a href='javascript:void();' class='removeresult' style='border: 0;'><img style='border: 0px;' src='images/delete.png' width='48' height='48' /></a><span class='resultbody'>" + e + "</span><br clear='all' /></div>");
$("#result").prepend(t); $("#result").prepend(t);
t.find(".removeresult").click(function(e) {
Util.RemoveResult(e);
});
return false; return false;
} }
}; };