Skip to content
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.

Commit

Permalink
Fix for settings.js variable overriding localStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
scooterpsu committed Mar 26, 2019
1 parent 6a17fbd commit 14681f8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion comixology2/templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h3>Settings</h3>
<option value="desc">Descending</option>
</select></label>
<label>Theme Variant: <select name="themeSelector" onchange="switchTheme(this.value);">
<option value="">Default</option>
<option value="default">Default</option>
</select></label>
</form>
</div>
Expand Down
33 changes: 17 additions & 16 deletions comixology2/themeScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,7 @@ var bookmarkLocation = "Ubooquity_Bookmarks2";
var Bookmarks = [];
var cacheLocation = "Ubooquity_IDcache2";
var IDcache = {"books": [], "comics": []};

/* Theme variant load/store. */
var themeVariants = [];
if(typeof(themeVariant) != "undefined"){
var themeVariant=null;
}
if(typeof Storage !== "undefined"){
if (localStorage.getItem('UbooquityThemeVariant') !== null) {
themeVariant=localStorage.getItem('UbooquityThemeVariant');
}else{
localStorage.setItem('UbooquityThemeVariant', '');
}
}


/* Load theme settings from settings.js. */
loadScript(proxyPrefix+"/theme/settings.js");

Expand All @@ -50,6 +37,20 @@ loadScript(proxyPrefix+"/theme/js/jquery-3.3.1.min.js", function(){

$.ajaxSetup({ cache: false });
$('head').append('<link rel="stylesheet" href="'+proxyPrefix+'/theme/comixology.css" type="text/css" />');

/* Theme variant load/store. */
var themeVariants = [];
if(typeof themeVariant === "undefined"){
var themeVariant='default';
}
if(typeof Storage !== "undefined"){
if (localStorage.getItem('UbooquityThemeVariant') !== null) {
themeVariant=localStorage.getItem('UbooquityThemeVariant');
}else{
localStorage.setItem('UbooquityThemeVariant', themeVariant);
}
}

if(typeof Storage !== "undefined"){
if (localStorage.getItem(bookmarkLocation) !== null) {
Bookmarks=JSON.parse(localStorage.getItem(bookmarkLocation));
Expand Down Expand Up @@ -859,11 +860,11 @@ function switchTheme(theme){
$('body').removeClass();
$('link[title=themeVariant]').remove();
if(theme == undefined){
theme = "";
theme = "default";
}
localStorage.setItem('UbooquityThemeVariant', theme);
themeVariant = theme;
if(theme != ""){
if((theme != "")&&(theme != "default")){
$('body').addClass(theme);
$('body').addClass('themed');
$('head').append('<link rel="stylesheet" title="themeVariant" href="'+proxyPrefix+'/theme/themes/'+theme+'/'+theme+'.css" type="text/css" />');
Expand Down

0 comments on commit 14681f8

Please sign in to comment.