37 lines
953 B
JavaScript
37 lines
953 B
JavaScript
Object.prototype.itemSetJSON= function (name, value){
|
|
this[name]=value
|
|
}
|
|
Object.prototype.itemGetJSON = function(name){
|
|
return this[name]
|
|
}
|
|
function getGameStorage(){
|
|
return JSON.parse(localStorage['games'])
|
|
}
|
|
function getGameStorageByName(name){
|
|
return JSON.parse(localStorage['games'])[name]
|
|
}
|
|
function setGameStorage(gamedatas){
|
|
localStorage['games'] = JSON.stringify(gamedatas)
|
|
}
|
|
function setGameStorageByName(name, namedatas){
|
|
let cgamestorage = JSON.parse(localStorage['games'])
|
|
cgamestorage[name]=namedatas
|
|
localStorage['games'] = JSON.stringify(cgamestorage)
|
|
}
|
|
function getUSCPMStorage(){
|
|
initstorage('uscpm')
|
|
return JSON.parse(localStorage['games'])['uscpm']
|
|
}
|
|
function setUSCPMStorage(data){
|
|
setGameStorageByName('uscpm', data)
|
|
}
|
|
function initstorage(name=null){
|
|
if(localStorage['games']==undefined){
|
|
setGameStorage({})
|
|
}
|
|
if(name !=null){
|
|
if(getGameStorageByName(name)==undefined){
|
|
setGameStorageByName(name, {})
|
|
}
|
|
}
|
|
}
|