Merge pull request #48 from iharosi/master
Merge pull request #48 from iharosi/master

minimal-ui added to allow fullscreen on iOS 7.1

file:a/index.html -> file:b/index.html
--- a/index.html
+++ b/index.html
@@ -11,7 +11,7 @@
 
   <meta name="HandheldFriendly" content="True">
   <meta name="MobileOptimized" content="320">
-  <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0, maximum-scale=1, user-scalable=no">
+  <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0, maximum-scale=1, user-scalable=no, minimal-ui">
 </head>
 <body>
   <div class="container">
@@ -28,7 +28,6 @@
       <div class="game-message">
         <p></p>
         <div class="lower">
-	  <a class="keep-playing-button">Keep playing</a>
           <a class="retry-button">Try again</a>
         </div>
       </div>
@@ -70,6 +69,10 @@
     </p>
     <hr>
     <p>
+    <strong class="important">Note:</strong> This site is the official version of 2048. You can play it on your phone via <a href="http://git.io/2048">http://git.io/2048.</a> All other apps or sites are derivatives or fakes, and should be used with caution.
+    </p>
+    <hr>
+    <p>
     Created by <a href="http://gabrielecirulli.com" target="_blank">Gabriele Cirulli.</a> Based on <a href="https://itunes.apple.com/us/app/1024!/id823499224" target="_blank">1024 by Veewo Studio</a> and conceptually similar to <a href="http://asherv.com/threes/" target="_blank">Threes by Asher Vollmer.</a>
     </p>
   </div>

--- a/js/game_manager.js
+++ b/js/game_manager.js
@@ -8,7 +8,6 @@
 
   this.inputManager.on("move", this.move.bind(this));
   this.inputManager.on("restart", this.restart.bind(this));
-  this.inputManager.on("keepPlaying", this.keepPlaying.bind(this));
 
   this.setup();
 }
@@ -19,22 +18,6 @@
   this.setup();
 };
 
-// Keep playing after winning
-GameManager.prototype.keepPlaying = function () {
-  this.keepPlaying = true;
-  this.actuator.keepPlaying();
-};
-
-GameManager.prototype.isGameOver = function() {
-  if (this.over || (this.won && !this.keepPlaying) ) {
-    return true;
-  }
-  else {
-    return false;
-  }
-}
-
-
 // Set up the game
 GameManager.prototype.setup = function () {
   this.grid         = new Grid(this.size);
@@ -42,7 +25,6 @@
   this.score        = 0;
   this.over         = false;
   this.won          = false;
-  this.keepPlaying  = false;
 
   // Add the initial tiles
   this.addStartTiles();
@@ -78,8 +60,7 @@
     score:     this.score,
     over:      this.over,
     won:       this.won,
-    bestScore: this.scoreManager.get(),
-    gameOver:  this.isGameOver()
+    bestScore: this.scoreManager.get()
   });
 
 };
@@ -106,7 +87,7 @@
   // 0: up, 1: right, 2:down, 3: left
   var self = this;
 
-  if (this.isGameOver()) return; // Don't do anything if the game's over
+  if (this.over || this.won) return; // Don't do anything if the game's over
 
   var cell, tile;
 

--- a/js/html_actuator.js
+++ b/js/html_actuator.js
@@ -24,21 +24,14 @@
     self.updateScore(metadata.score);
     self.updateBestScore(metadata.bestScore);
 
-    if (metadata.gameOver) {
-      if (metadata.over) self.message(false); // You lose
-      else if (metadata.won) self.message(true); // You win!
-    }
-
+    if (metadata.over) self.message(false); // You lose
+    if (metadata.won) self.message(true); // You win!
   });
 };
 
 HTMLActuator.prototype.restart = function () {
   this.clearMessage();
 };
-
-HTMLActuator.prototype.keepPlaying = function () {
-  this.clearMessage();
-}
 
 HTMLActuator.prototype.clearContainer = function (container) {
   while (container.firstChild) {
@@ -49,13 +42,12 @@
 HTMLActuator.prototype.addTile = function (tile) {
   var self = this;
 
-  var element       = document.createElement("div");
-  var position      = tile.previousPosition || { x: tile.x, y: tile.y };
-  var positionClass = this.positionClass(position);
-  var styleClass    = this.styleClass(tile);
+  var element   = document.createElement("div");
+  var position  = tile.previousPosition || { x: tile.x, y: tile.y };
+  positionClass = this.positionClass(position);
 
   // We can't use classlist because it somehow glitches when replacing classes
-  var classes = ["tile", styleClass, positionClass];
+  var classes = ["tile", "tile-" + tile.value, positionClass];
   this.applyClasses(element, classes);
 
   element.textContent = tile.value;
@@ -96,15 +88,6 @@
   return "tile-position-" + position.x + "-" + position.y;
 };
 
-HTMLActuator.prototype.styleClass = function (tile) {
-  var className = 'tile-'+tile.value;
-
-  if (tile.value > 2048 ) {
-    className = className+' tile-gold';
-  }
-  return className;
-};
-
 HTMLActuator.prototype.updateScore = function (score) {
   this.clearContainer(this.scoreContainer);
 

--- a/js/keyboard_input_manager.js
+++ b/js/keyboard_input_manager.js
@@ -53,12 +53,9 @@
     }
   });
 
-  var retry = document.querySelector(".retry-button");
+  var retry = document.getElementsByClassName("retry-button")[0];
   retry.addEventListener("click", this.restart.bind(this));
   retry.addEventListener("touchend", this.restart.bind(this));
-
-  var keepPlaying = document.querySelector(".keep-playing-button");
-  keepPlaying.addEventListener("click", this.keepPlaying.bind(this));
 
   // Listen to swipe events
   var touchStartClientX, touchStartClientY;
@@ -97,8 +94,3 @@
   this.emit("restart");
 };
 
-KeyboardInputManager.prototype.keepPlaying = function (event) {
-  event.preventDefault();
-  this.emit("keepPlaying");
-};
-

--- a/style/main.css
+++ b/style/main.css
@@ -189,13 +189,9 @@
       height: 40px;
       line-height: 42px;
       margin-left: 9px; }
-      .game-container .game-message a.keep-playing-button {
-	display: none; }
     .game-container .game-message.game-won {
       background: rgba(237, 194, 46, 0.5);
       color: #f9f6f2; }
-      .game-container .game-message.game-won a.keep-playing-button {
-	display: inline-block; }
     .game-container .game-message.game-won, .game-container .game-message.game-over {
       display: block; }
 

--- a/style/main.scss
+++ b/style/main.scss
@@ -218,10 +218,6 @@
         @include button;
         margin-left: 9px;
         // margin-top: 59px;
-
-	&.keep-playing-button {
-	  display: none;
-	}
       }
 
       @include animation(fade-in 800ms ease $transition-speed * 12);
@@ -230,10 +226,6 @@
       &.game-won {
         background: rgba($tile-gold-color, .5);
         color: $bright-text-color;
-
-	a.keep-playing-button {
-	  display: inline-block;
-	}
       }
 
       &.game-won, &.game-over {

comments