(function() { var lastTime = 0; var vendors = ['webkit', 'moz']; for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'] } if (!window.requestAnimationFrame) { window.requestAnimationFrame = function(callback, element) { var currTime = new Date().getTime(); var timeToCall = Math.max(0, 16 - (currTime - lastTime)); var id = window.setTimeout(function() { callback(currTime + timeToCall) }, timeToCall); lastTime = currTime + timeToCall; return id } } if (!window.cancelAnimationFrame) { window.cancelAnimationFrame = function(id) { clearTimeout(id) } } } ()); var TOOL; var STORAGE; var CONTROL; var ENGINE; var GAME; $(function() { TOOL = new Tool(); STORAGE = new Storage(); CONTROL = new Control(); ENGINE = new Engine(); GAME = new Game(); var e = $(".engine"); var top = (CLIENT_H - e.height()) / 4; e.css("marginTop", top); $(".modal-dialog").css("marginTop", top * 2); if (TOOL.isPC) {} }); function Storage() { this.path = ""; this.storage = window.localStorage } Storage.prototype.init = function(path) { this.path = path }; Storage.prototype.getInt = function(key) { return parseInt(this.storage.getItem(this.path + key) || 0) }; Storage.prototype.getStr = function(key) { return (this.storage.getItem(this.path + key) || "") }; Storage.prototype.save = function(key, value) { this.storage.setItem(this.path + key, value) }; Storage.prototype.getJSON = function(key) { var value = this.storage.getItem(this.path + key); return (value ? JSON.parse(value) : null) }; Storage.prototype.saveJSON = function(key, value) { this.storage.setItem(this.path + key, JSON.stringify(value)) }; Storage.prototype.erase = function(key) { this.storage.removeItem(this.path + key) }; function Control() { CLICK_EVENT = "click"; $(document).on("keydown", this, this.keyDownDelegate) } Control.prototype.clickOn = function(o, f) { $(o).on(CLICK_EVENT, f) }; Control.prototype.touchOn = function(o) { $(o).on(TOOL.isPC ? "mousedown": "touchstart", this, this.touchStartDelegate); $(o).on(TOOL.isPC ? "mouseup": "touchend", this, this.touchEndDelegate) }; Control.prototype.keyDownDelegate = function(e) { var c = e.data; c.keyDown(e) }; Control.prototype.keyDown = function(event) {}; Control.prototype.touchStartDelegate = function(e) { var t = TOOL.isPC ? e: e.originalEvent.touches[0]; var c = e.data; c.touchStartX = t.pageX; c.touchStartY = t.pageY; c.touchStart(e); c.checkTouchPrevent(e) }; Control.prototype.touchStart = function(event) {}; Control.prototype.touchEndDelegate = function(e) { var ct = TOOL.isPC ? e: e.originalEvent.changedTouches[0]; var c = e.data; c.touchEndX = ct.pageX; c.touchEndY = ct.pageY; var dx = c.touchEndX - c.touchStartX; var absDx = Math.abs(dx); var dy = c.touchEndY - c.touchStartY; var absDy = Math.abs(dy); if (Math.max(absDx, absDy) > 10) { c.touchDir = (absDx > absDy ? (dx > 0 ? DIR_RIGHT: DIR_LEFT) : (dy > 0 ? DIR_DOWN: DIR_UP)); c.touchSlide(e) } c.touchEnd(e); c.checkTouchPrevent(e) }; Control.prototype.touchEnd = function(event) {}; Control.prototype.touchSlide = function(event) {}; Control.prototype.checkTouchPrevent = function(e) { switch (e.target.tagName.toLowerCase()) { case "input": case "button": case "a": return } e.preventDefault() }; function Engine() { var menu = $(".dropdown-menu"); menu.append("