Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
titaniumnetwork-dev
GitHub Repository: titaniumnetwork-dev/Incognito-old
Path: blob/main/static/src/gs/public/radius-raid/js/storage.js
1325 views
1
// local storage helpers - source: http://stackoverflow.com/questions/2010892/storing-objects-in-html5-localstorage/3146971#3146971
2
Storage.prototype.setObject = function( key, value ) {
3
this.setItem( key, JSON.stringify( value ) );
4
}
5
6
Storage.prototype.getObject = function( key ) {
7
var value = this.getItem( key );
8
return value && JSON.parse( value );
9
}
10
11
Storage.prototype.removeObject = function( key ) {
12
this.removeItem( key );
13
}
14
15
$.setupStorage = function() {
16
$.storage = localStorage.getObject( 'radiusraid' ) || {
17
'mute': 0,
18
'autofire': 0,
19
'score': 0,
20
'level': 0,
21
'rounds': 0,
22
'kills': 0,
23
'bullets': 0,
24
'powerups': 0,
25
'time': 0
26
};
27
};
28
29
$.updateStorage = function() {
30
localStorage.setObject( 'radiusraid', $.storage );
31
};
32
33
$.clearStorage = function() {
34
localStorage.removeObject( 'radiusraid' );
35
$.setupStorage();
36
};
37