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() { function init() {
//check if localStorage is available //init passwordhash to retrieve cookie info and set passwordHash
try { passwordHash.initHash();
window.localStorage.getItem("test")
} catch (e) {
console.log("localStorage not available");
activeState.settings.persistentStorage = "false";
}
//init passwordhash to retrieve cookie info
passwordHash.init();
//set user id //set user id
activeState.userId = getUsrId(); activeState.userId = getUsrId();
@ -74,16 +66,14 @@ function init() {
document.getElementById("login").style.display = "block"; document.getElementById("login").style.display = "block";
} }
//load settings from storage //load settings from storage and apply
let settings = storeSettings("getInit", true); let settings = storeSettings("getInit", true);
if (settings != null) { if (settings != null) {
for (let setting of Object.entries(settings)) { for (let setting of Object.entries(settings)) {
activeState.settings[setting[0]] = setting[1]; activeState.settings[setting[0]] = setting[1];
} }
} }
//load NavigationBar with templates according to server //load NavigationBar with templates according to server
loadNavBar(); loadNavBar();

View File

@ -15,7 +15,7 @@ export const passwordHash = {
activeState.sessionToken = XORCipher.encode(this.name, pw); activeState.sessionToken = XORCipher.encode(this.name, pw);
}, },
init: function () { initHash: function () {
//check if cookie exists //check if cookie exists
if (getCookie(sha256(this.name)) != null) { if (getCookie(sha256(this.name)) != null) {
if (getCookie(sha256(this.name)) != "") { if (getCookie(sha256(this.name)) != "") {

View File

@ -182,17 +182,25 @@ function saveSettings() {
if (activeState.settings[setting[0]] != setting[1]) { if (activeState.settings[setting[0]] != setting[1]) {
//change detected //change detected
if (setting[0] == "persistentStorage") { if (setting[0] == "persistentStorage") {
//get tF from old storage
let tF = retrieveData("templateFiles"); let tF = retrieveData("templateFiles");
//get previous settings
let settings = storeSettings("get", true); let settings = storeSettings("get", true);
//store the new settings in old storage
storeSettings(obj); storeSettings(obj);
//apply the new setting
activeState.settings[setting[0]] = setting[1]; 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") { if (setting[1] == "false") {
let msg = (activeState.settings.persistentStorage == "false") ? "temporary" : "persistent"; let msg = (activeState.settings.persistentStorage == "false") ? "temporary" : "persistent";
printVersion("storage mode: "+msg+" |"); printVersion("storage mode: "+msg+" |");
} }
if (settings != "") storeSettings(obj);
if (tF != null) storeData("templateFiles", tF);
} }
} }
activeState.settings[setting[0]] = setting[1]; activeState.settings[setting[0]] = setting[1];