Save val2048 preference.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Wed, 10 Sep 2014 20:41:49 +0300
changeset 43 8b1577211149
parent 42 716508d5494c
child 44 518ab579d24b
Save val2048 preference.
2048.html
--- a/2048.html	Wed Sep 10 20:27:57 2014 +0300
+++ b/2048.html	Wed Sep 10 20:41:49 2014 +0300
@@ -236,6 +236,7 @@
     ui.board.val2048Dom = document.getElementById('2048');
     ui.board.val2048Dom.addEventListener("click", function(event) {
       ui.board.update(board.current);
+      localStorage.val2048 = ui.board.val2048Dom.checked;
       event.target.blur();
     });
     ui.board.val2048 = function(val) {
@@ -586,6 +587,11 @@
 
     ui.brdEngine = BoardArr2d; // TODO make user selectable
 
+    if (localStorage.val2048) {
+      try {
+        ui.board.val2048Dom.checked = JSON.parse(localStorage.val2048);
+      } catch (ex) { }
+    }
     if (localStorage.savedBoard) {
       try {
         board.current = JSON.parse(localStorage.savedBoard);