Fix README
Fix README

file:a/README.md -> file:b/README.md
--- a/README.md
+++ b/README.md
@@ -2,6 +2,15 @@
 A small clone of [1024](https://play.google.com/store/apps/details?id=com.veewo.a1024), based on [Saming's 2048](http://saming.fr/p/2048/) (also a clone).
 
 Made just for fun. [Play it here!](http://gabrielecirulli.github.io/2048/)
+
+### Contributions
+
+ - [TimPetricola](https://github.com/TimPetricola) added best score storage
+ - [chrisprice](https://github.com/chrisprice) added custom code for swipe handling on mobile
+
+Many thanks to [rayhaanj](https://github.com/rayhaanj), [Mechazawa](https://github.com/Mechazawa), [grant](https://github.com/grant), [remram44](https://github.com/remram44) and [ghoullier](https://github.com/ghoullier) for the many other good contributions.
+
+### Screenshot
 
 [![Screenshot](http://pictures.gabrielecirulli.com/2048-20140309-234100.png)](http://pictures.gabrielecirulli.com/2048-20140309-234100.png)
 

file:a/index.html -> file:b/index.html
--- a/index.html
+++ b/index.html
@@ -6,6 +6,8 @@
 
   <link href="style/main.css" rel="stylesheet" type="text/css">
   <link rel="shortcut icon" href="favicon.ico">
+  <link rel="apple-touch-icon" href="meta/apple-touch-icon.png">
+  <meta name="apple-mobile-web-app-capable" content="yes">
 
   <meta name="HandheldFriendly" content="True">
   <meta name="MobileOptimized" content="320">

--- a/js/game_manager.js
+++ b/js/game_manager.js
@@ -211,8 +211,6 @@
           var cell   = { x: x + vector.x, y: y + vector.y };
 
           var other  = self.grid.cellContent(cell);
-          if (other) {
-          }
 
           if (other && other.value === tile.value) {
             return true; // These two tiles can be merged

--- a/js/html_actuator.js
+++ b/js/html_actuator.js
@@ -1,7 +1,7 @@
 function HTMLActuator() {
   this.tileContainer    = document.querySelector(".tile-container");
   this.scoreContainer   = document.querySelector(".score-container");
-  this.bestContainer   = document.querySelector(".best-container");
+  this.bestContainer    = document.querySelector(".best-container");
   this.messageContainer = document.querySelector(".game-message");
 
   this.score = 0;
@@ -113,10 +113,6 @@
   var type    = won ? "game-won" : "game-over";
   var message = won ? "You win!" : "Game over!";
 
-  if (typeof ga !== "undefined") {
-    ga("send", "event", "game", "end", type, this.score);
-  }
-
   this.messageContainer.classList.add(type);
   this.messageContainer.getElementsByTagName("p")[0].textContent = message;
 };

--- a/js/keyboard_input_manager.js
+++ b/js/keyboard_input_manager.js
@@ -59,20 +59,22 @@
   // Listen to swipe events
   var touchStartClientX, touchStartClientY;
   var gameContainer = document.getElementsByClassName("game-container")[0];
-  gameContainer.addEventListener("touchstart", function(event) {
+
+  gameContainer.addEventListener("touchstart", function (event) {
     if (event.touches.length > 1) return;
 
     touchStartClientX = event.touches[0].clientX;
     touchStartClientY = event.touches[0].clientY;
     event.preventDefault();
   });
-  gameContainer.addEventListener("touchmove", function(event) {
+
+  gameContainer.addEventListener("touchmove", function (event) {
     event.preventDefault();
   });
-  gameContainer.addEventListener("touchend", function(event) {
-    if (event.touches.length > 0) {
-      return;
-    }
+
+  gameContainer.addEventListener("touchend", function (event) {
+    if (event.touches.length > 0) return;
+
     var dx = event.changedTouches[0].clientX - touchStartClientX;
     var absDx = Math.abs(dx);
 

--- a/js/local_score_manager.js
+++ b/js/local_score_manager.js
@@ -1,28 +1,32 @@
 window.fakeStorage = {
-  _data       : {},
-  setItem     : function (id, val) {
-    console.log('set');
+  _data: {},
+
+  setItem: function (id, val) {
     return this._data[id] = String(val);
   },
-  getItem     : function (id) {
+
+  getItem: function (id) {
     return this._data.hasOwnProperty(id) ? this._data[id] : undefined;
   },
-  removeItem  : function (id) { return delete this._data[id]; },
-  clear       : function () { return this._data = {}; }
+
+  removeItem: function (id) {
+    return delete this._data[id];
+  },
+
+  clear: function () {
+    return this._data = {};
+  }
 };
 
 function LocalScoreManager() {
   var localSupported = !!window.localStorage;
-  this.key = 'bestScore';
-  this.storage =  localSupported ? window.localStorage : window.fakeStorage;
+
+  this.key     = "bestScore";
+  this.storage = localSupported ? window.localStorage : window.fakeStorage;
 }
 
 LocalScoreManager.prototype.get = function () {
-  var score = this.storage.getItem(this.key);
-  if (typeof score === "undefined" || score === null) {
-    score = 0;
-  }
-  return score;
+  return this.storage.getItem(this.key) || 0;
 };
 
 LocalScoreManager.prototype.set = function (score) {

 Binary files /dev/null and b/meta/apple-touch-icon.png differ
--- a/style/main.css
+++ b/style/main.css
@@ -50,7 +50,8 @@
     opacity: 0; } }
 
 .scores-container {
-  float: right; }
+  float: right;
+  text-align: right; }
 
 .score-container, .best-container {
   position: relative;
@@ -460,14 +461,17 @@
     padding: 0 20px; }
 
   h1.title {
-    font-size: 50px; }
+    font-size: 27px;
+    margin-top: 15px; }
 
   .container {
     width: 280px;
     margin: 0 auto; }
 
-  .score-container {
-    margin-top: 0; }
+  .score-container, .best-container {
+    margin-top: 0;
+    padding: 15px 10px;
+    min-width: 40px; }
 
   .heading {
     margin-bottom: 10px; }

--- a/style/main.scss
+++ b/style/main.scss
@@ -60,6 +60,7 @@
 
 .scores-container {
   float: right;
+  text-align: right;
 }
 
 .score-container, .best-container {
@@ -445,7 +446,8 @@
   }
 
   h1.title {
-    font-size: 50px;
+    font-size: 27px;
+    margin-top: 15px;
   }
 
   .container {
@@ -453,8 +455,15 @@
     margin: 0 auto;
   }
 
-  .score-container {
+  // .scores-container {
+  //   float: left;
+  //   clear: left;
+  // }
+
+  .score-container, .best-container {
     margin-top: 0;
+    padding: 15px 10px;
+    min-width: 40px;
   }
 
   .heading {

comments