diff --git a/js/9.9.9/init.js b/js/9.9.9/init.js index 11e54ef..e1cb51d 100644 --- a/js/9.9.9/init.js +++ b/js/9.9.9/init.js @@ -51,16 +51,8 @@ window.activeState = { function init() { - //check if localStorage is available - try { - window.localStorage.getItem("test") - } catch (e) { - console.log("localStorage not available"); - activeState.settings.persistentStorage = "false"; - } - - //init passwordhash to retrieve cookie info - passwordHash.init(); + //init passwordhash to retrieve cookie info and set passwordHash + passwordHash.initHash(); //set user id activeState.userId = getUsrId(); @@ -74,16 +66,14 @@ function init() { document.getElementById("login").style.display = "block"; } - //load settings from storage + //load settings from storage and apply let settings = storeSettings("getInit", true); - if (settings != null) { for (let setting of Object.entries(settings)) { activeState.settings[setting[0]] = setting[1]; } } - //load NavigationBar with templates according to server loadNavBar(); diff --git a/js/9.9.9/scripts.js b/js/9.9.9/scripts.js index 8ea1616..c1712a2 100644 --- a/js/9.9.9/scripts.js +++ b/js/9.9.9/scripts.js @@ -15,7 +15,7 @@ export const passwordHash = { activeState.sessionToken = XORCipher.encode(this.name, pw); }, - init: function () { + initHash: function () { //check if cookie exists if (getCookie(sha256(this.name)) != null) { if (getCookie(sha256(this.name)) != "") { diff --git a/js/9.9.9/settings.js b/js/9.9.9/settings.js index c1318e4..5691cc9 100644 --- a/js/9.9.9/settings.js +++ b/js/9.9.9/settings.js @@ -182,17 +182,25 @@ function saveSettings() { if (activeState.settings[setting[0]] != setting[1]) { //change detected if (setting[0] == "persistentStorage") { + //get tF from old storage let tF = retrieveData("templateFiles"); + //get previous settings let settings = storeSettings("get", true); + //store the new settings in old storage storeSettings(obj); + //apply the new setting activeState.settings[setting[0]] = setting[1]; + //store the new settings in the new storage + if (settings != "") storeSettings(obj); + //transfer tF + if (tF != null) storeData("templateFiles", tF); + if (setting[1] == "false") { let msg = (activeState.settings.persistentStorage == "false") ? "temporary" : "persistent"; printVersion("storage mode: "+msg+" |"); } - if (settings != "") storeSettings(obj); - if (tF != null) storeData("templateFiles", tF); + } } activeState.settings[setting[0]] = setting[1];