1
0
mirror of https://github.com/danog/2048.git synced 2024-12-13 17:57:42 +01:00
2048/js/local_score_manager.js

25 lines
443 B
JavaScript
Raw Normal View History

function LocalScoreManager() {
this.key = 'bestScore';
}
LocalScoreManager.prototype.get = function () {
if (!this.isSupported()) {
return 0;
}
return localStorage.getItem(this.key);
};
LocalScoreManager.prototype.set = function (score) {
if (!this.isSupported()) {
return false;
}
localStorage.setItem(this.key, score);
};
LocalScoreManager.prototype.isSupported = function () {
return !!window.localStorage;
};