-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocalStorage.js
32 lines (28 loc) · 1 KB
/
LocalStorage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
export class LoadStorage {
static gameLayout(){
if(localStorage.getItem('gameLayout') !== null){
return JSON.parse(localStorage.getItem('gameLayout'))
}
return 'No local storage found'
}
// static history(){
// if(localStorage.getItem('history') !== null){
// return JSON.parse(localStorage.getItem('history')).history
// }
// return undefined
// }
}
export class SaveStorage {
static gameLayout(layout){
localStorage.setItem('gameLayout', JSON.stringify(layout))
}
// static history(layout = LoadStorage.gameLayout( )){
// if(localStorage.getItem('history') !== null){
// let obj = JSON.parse(localStorage.getItem('history'))
// obj.history.push(layout)
// localStorage.setItem('history', JSON.stringify(obj))
// }else{
// localStorage.setItem('history', JSON.stringify({history: [layout]}))
// }
// }
}