diff --git a/cache.appcache b/cache.appcache
index bc71d8a706d3ac261fdbb3aed33896b2b62f1bcd..d1396f66c5c4f67b3076a01970de1ad85d0d2a49 100644
--- a/cache.appcache
+++ b/cache.appcache
@@ -3,7 +3,7 @@ CACHE MANIFEST
# Adds the ability to play the game online.
# The following comment needs to be updated whenever a change is made.
# Run `rake appcache:update` to do so
-# Updated: 2014-03-22T18:46:07+01:00
+# Updated: 2014-03-23T19:52:45+01:00
# Main page
index.html
diff --git a/index.html b/index.html
index 6166058ddd0897132375bbe8d95d05a7a4bc927b..cb2ce18f3c5ea3fa8e2975d71598a0d39dabec6b 100644
--- a/index.html
+++ b/index.html
@@ -108,6 +108,8 @@
+
+
diff --git a/js/bind_polyfill.js b/js/bind_polyfill.js
new file mode 100644
index 0000000000000000000000000000000000000000..8d9c4a4886dd1b0b9ae857ab0cf947c697b125b5
--- /dev/null
+++ b/js/bind_polyfill.js
@@ -0,0 +1,9 @@
+Function.prototype.bind = Function.prototype.bind || function (target) {
+ var self = this;
+ return function (args) {
+ if (!(args instanceof Array)) {
+ args = [args];
+ }
+ self.apply(target, args);
+ };
+};
diff --git a/js/classlist_polyfill.js b/js/classlist_polyfill.js
new file mode 100644
index 0000000000000000000000000000000000000000..1789ae788939fa86560a96f376400b7069f4d093
--- /dev/null
+++ b/js/classlist_polyfill.js
@@ -0,0 +1,71 @@
+(function () {
+ if (typeof window.Element === "undefined" ||
+ "classList" in document.documentElement) {
+ return;
+ }
+
+ var prototype = Array.prototype,
+ push = prototype.push,
+ splice = prototype.splice,
+ join = prototype.join;
+
+ function DOMTokenList(el) {
+ this.el = el;
+ // The className needs to be trimmed and split on whitespace
+ // to retrieve a list of classes.
+ var classes = el.className.replace(/^\s+|\s+$/g, '').split(/\s+/);
+ for (var i = 0; i < classes.length; i++) {
+ push.call(this, classes[i]);
+ }
+ }
+
+ DOMTokenList.prototype = {
+ add: function (token) {
+ if (this.contains(token)) return;
+ push.call(this, token);
+ this.el.className = this.toString();
+ },
+ contains: function (token) {
+ return this.el.className.indexOf(token) != -1;
+ },
+ item: function (index) {
+ return this[index] || null;
+ },
+ remove: function (token) {
+ if (!this.contains(token)) return;
+ for (var i = 0; i < this.length; i++) {
+ if (this[i] == token) break;
+ }
+ splice.call(this, i, 1);
+ this.el.className = this.toString();
+ },
+ toString: function () {
+ return join.call(this, ' ');
+ },
+ toggle: function (token) {
+ if (!this.contains(token)) {
+ this.add(token);
+ } else {
+ this.remove(token);
+ }
+
+ return this.contains(token);
+ }
+ };
+
+ window.DOMTokenList = DOMTokenList;
+
+ function defineElementGetter(obj, prop, getter) {
+ if (Object.defineProperty) {
+ Object.defineProperty(obj, prop, {
+ get: getter
+ });
+ } else {
+ obj.__defineGetter__(prop, getter);
+ }
+ }
+
+ defineElementGetter(HTMLElement.prototype, 'classList', function () {
+ return new DOMTokenList(this);
+ });
+})();
diff --git a/js/game_manager.js b/js/game_manager.js
index e018ef993fc894610c347820073cacdc99f2561e..aea99f335af91940991c9286147d1c1c1e171084 100644
--- a/js/game_manager.js
+++ b/js/game_manager.js
@@ -16,14 +16,14 @@ function GameManager(size, InputManager, Actuator, StorageManager) {
// Restart the game
GameManager.prototype.restart = function () {
this.storageManager.clearGameState();
- this.actuator.continue(); // Clear the game won/lost message
+ this.actuator.continueGame(); // Clear the game won/lost message
this.setup();
};
// Keep playing after winning (allows going over 2048)
GameManager.prototype.keepPlaying = function () {
this.keepPlaying = true;
- this.actuator.continue(); // Clear the game won/lost message
+ this.actuator.continueGame(); // Clear the game won/lost message
};
// Return true if the game is lost, or has won and the user hasn't kept playing
diff --git a/js/html_actuator.js b/js/html_actuator.js
index 8f7e779e98c61536aef1fb55c8a70dd366a1f0cf..a37b8fe90c96eaedf14672b9a3a4c6db41d0ca03 100644
--- a/js/html_actuator.js
+++ b/js/html_actuator.js
@@ -37,7 +37,7 @@ HTMLActuator.prototype.actuate = function (grid, metadata) {
};
// Continues the game (both restart and keep playing)
-HTMLActuator.prototype.continue = function () {
+HTMLActuator.prototype.continueGame = function () {
if (typeof ga !== "undefined") {
ga("send", "event", "game", "restart");
}