This repository has been archived on 2024-04-03. You can view files and clone it, but cannot push or open issues or pull requests.
OLD-GZod01.fr_Source_Code-OLD/api/scripts/gameStorage.js

38 lines
953 B
JavaScript
Raw Normal View History

2023-03-25 09:26:41 +00:00
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, {})
}
}
}