diff --git a/public/main.js b/public/main.js index 3f31054..495cd98 100644 --- a/public/main.js +++ b/public/main.js @@ -163,26 +163,6 @@ function download(content, filename) { a.remove() } -function getLocal(key) { - return JSON.parse(localStorage.getItem(key)) -} - -function setLocal(key, value) { - value = JSON.stringify(value) - localStorage.setItem(key, value) - return value -} - -function getSession(key) { - return JSON.parse(sessionStorage.getItem(key)) -} - -function setSession(key, value) { - value = JSON.stringify(value) - sessionStorage.setItem(key, value) - return value -} - function newScript(url) { return new Promise((resolve, reject) => { var script = document.createElement('script'); @@ -214,6 +194,33 @@ function requiresStyle(url) { } +class Storage { + static get Local() { + return { + get(key) { + return JSON.parse(localStorage.getItem(key)) + }, + set(key, value) { + value = JSON.stringify(value) + localStorage.setItem(key, value) + return value + } + } + } + static get Session() { + return { + get(key) { + return JSON.parse(sessionStorage.getItem(key)) + }, + set(key, value) { + value = JSON.stringify(value) + sessionStorage.setItem(key, value) + return value + } + } + } +} + class Waiter { constructor(list, f){ this.list = {}