From 14681f8d281795ac5c6800797a4b0dd91ba30454 Mon Sep 17 00:00:00 2001
From: scooterpsu <3433982+scooterpsu@users.noreply.github.com>
Date: Tue, 26 Mar 2019 15:34:36 -0400
Subject: [PATCH] Fix for settings.js variable overriding localStorage
---
comixology2/templates/footer.html | 2 +-
comixology2/themeScript.js | 33 ++++++++++++++++---------------
2 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/comixology2/templates/footer.html b/comixology2/templates/footer.html
index 74e8538..3cc866d 100644
--- a/comixology2/templates/footer.html
+++ b/comixology2/templates/footer.html
@@ -43,7 +43,7 @@
Settings
diff --git a/comixology2/themeScript.js b/comixology2/themeScript.js
index d4bc0e1..d4dcfbd 100644
--- a/comixology2/themeScript.js
+++ b/comixology2/themeScript.js
@@ -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");
@@ -50,6 +37,20 @@ loadScript(proxyPrefix+"/theme/js/jquery-3.3.1.min.js", function(){
$.ajaxSetup({ cache: false });
$('head').append('');
+
+ /* 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));
@@ -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('');