2048.html
changeset 43 8b1577211149
parent 42 716508d5494c
child 44 518ab579d24b
equal deleted inserted replaced
42:716508d5494c 43:8b1577211149
   234     var ui = {};
   234     var ui = {};
   235     ui.board = {};
   235     ui.board = {};
   236     ui.board.val2048Dom = document.getElementById('2048');
   236     ui.board.val2048Dom = document.getElementById('2048');
   237     ui.board.val2048Dom.addEventListener("click", function(event) {
   237     ui.board.val2048Dom.addEventListener("click", function(event) {
   238       ui.board.update(board.current);
   238       ui.board.update(board.current);
       
   239       localStorage.val2048 = ui.board.val2048Dom.checked;
   239       event.target.blur();
   240       event.target.blur();
   240     });
   241     });
   241     ui.board.val2048 = function(val) {
   242     ui.board.val2048 = function(val) {
   242       if (ui.board.val2048Dom.checked)
   243       if (ui.board.val2048Dom.checked)
   243         return Math.pow(2, val);
   244         return Math.pow(2, val);
   584       ui.ai.current = ui.ai.algList[aiDom.id](aiDom);
   585       ui.ai.current = ui.ai.algList[aiDom.id](aiDom);
   585     }
   586     }
   586 
   587 
   587     ui.brdEngine = BoardArr2d; // TODO make user selectable
   588     ui.brdEngine = BoardArr2d; // TODO make user selectable
   588 
   589 
       
   590     if (localStorage.val2048) {
       
   591       try {
       
   592         ui.board.val2048Dom.checked = JSON.parse(localStorage.val2048);
       
   593       } catch (ex) { }
       
   594     }
   589     if (localStorage.savedBoard) {
   595     if (localStorage.savedBoard) {
   590       try {
   596       try {
   591         board.current = JSON.parse(localStorage.savedBoard);
   597         board.current = JSON.parse(localStorage.savedBoard);
   592         ui.board.update(board.current);
   598         ui.board.update(board.current);
   593       } catch (ex) { }
   599       } catch (ex) { }