Full rebase

This commit is contained in:
Daniel
2023-10-14 01:43:36 +02:00
parent 63f51d9cac
commit 8c162678a7
14 changed files with 393 additions and 476 deletions
+47
View File
@@ -0,0 +1,47 @@
export default class Config {
constructor(config) {
this.config = config
// localStorage availability check
try {
window.localStorage
this.storageAvailable = true
}
catch (e) {
this.storageAvailable = false
}
}
get(key) {
let value = this.config["ui"][key]
if (this.storageAvailable) {
let type = typeof(value)
let stored_value = window.localStorage.getItem(key)
if (stored_value != null) {
value = stored_value
if (type == "number") value = Number(value)
else if (type == "boolean") value = value == "true"
}
}
return value
}
set(key, value) {
this.config["ui"][key] = value
if (this.storageAvailable) {
window.localStorage.setItem(key, value)
}
}
changed(key) {
return this.get(key) != this.config["ui"][key]
}
getServices() {
return this.config["services"]
}
}
+12
View File
@@ -0,0 +1,12 @@
export function showPage(target) {
let bg = document.getElementById("background").classList
if (target == "home") bg.add("scaled")
else bg.remove("scaled")
let pages = document.getElementsByClassName("page")
for (let page of pages) {
let p = page.getAttribute("p")
if (p == target) page.classList.add("current")
else page.classList.remove("current")
}
}