mirror of
https://github.com/khairul169/honey.git
synced 2026-10-04 18:03:54 +07:00
Full rebase
This commit is contained in:
@@ -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"]
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user