add app notice
This commit is contained in:
@@ -1,4 +1,18 @@
|
||||
// Wait till the browser is ready to render the game (avoids glitches)
|
||||
window.requestAnimationFrame(function () {
|
||||
new GameManager(4, KeyboardInputManager, HTMLActuator, LocalStorageManager);
|
||||
|
||||
// TODO: This code is in need of a refactor (along with the rest)
|
||||
var storage = new LocalStorageManager;
|
||||
var noticeClose = document.querySelector(".notice-close-button");
|
||||
var notice = document.querySelector(".app-notice");
|
||||
if (storage.getNoticeClosed()) {
|
||||
notice.parentNode.removeChild(notice);
|
||||
} else {
|
||||
noticeClose.addEventListener("click", function () {
|
||||
notice.parentNode.removeChild(notice);
|
||||
storage.setNoticeClosed(true);
|
||||
ga("send", "event", "notice", "closed");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -21,6 +21,7 @@ window.fakeStorage = {
|
||||
function LocalStorageManager() {
|
||||
this.bestScoreKey = "bestScore";
|
||||
this.gameStateKey = "gameState";
|
||||
this.noticeClosedKey = "noticeClosed";
|
||||
|
||||
var supported = this.localStorageSupported();
|
||||
this.storage = supported ? window.localStorage : window.fakeStorage;
|
||||
@@ -61,3 +62,11 @@ LocalStorageManager.prototype.setGameState = function (gameState) {
|
||||
LocalStorageManager.prototype.clearGameState = function () {
|
||||
this.storage.removeItem(this.gameStateKey);
|
||||
};
|
||||
|
||||
LocalStorageManager.prototype.setNoticeClosed = function (noticeClosed) {
|
||||
this.storage.setItem(this.noticeClosedKey, JSON.stringify(noticeClosed));
|
||||
};
|
||||
|
||||
LocalStorageManager.prototype.getNoticeClosed = function () {
|
||||
return JSON.parse(this.storage.getItem(this.noticeClosedKey) || "false");
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user