This commit is contained in:
maru21 2023-10-28 20:42:23 +02:00
parent a39c16e54b
commit 7dcc5815e3
3 changed files with 14 additions and 16 deletions

View File

@ -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();

View File

@ -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)) != "") {

View File

@ -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];