mirror of
https://gitlab.com/skysthelimit.dev/selenite.git
synced 2025-06-16 02:22:07 -05:00
35 lines
748 B
JavaScript
35 lines
748 B
JavaScript
window.fakeStorage = {
|
|
_data: {},
|
|
|
|
setItem: function (id, val) {
|
|
return this._data[id] = String(val);
|
|
},
|
|
|
|
getItem: function (id) {
|
|
return this._data.hasOwnProperty(id) ? this._data[id] : undefined;
|
|
},
|
|
|
|
removeItem: function (id) {
|
|
return delete this._data[id];
|
|
},
|
|
|
|
clear: function () {
|
|
return this._data = {};
|
|
}
|
|
};
|
|
|
|
function LocalScoreManager() {
|
|
var localSupported = !!window.localStorage;
|
|
|
|
this.key = "bestScore_9007199254740992";
|
|
this.storage = localSupported ? window.localStorage : window.fakeStorage;
|
|
}
|
|
|
|
LocalScoreManager.prototype.get = function () {
|
|
return this.storage.getItem(this.key) || 0;
|
|
};
|
|
|
|
LocalScoreManager.prototype.set = function (score) {
|
|
this.storage.setItem(this.key, score);
|
|
};
|