added Storage class
This commit is contained in:
1 parent
373f6c397a
commit
e25d134cfa
1 file changed
+27
-20
+27
-20
@@ -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 = {}
|
||||
|
||||
Reference in new issue
Block a user