﻿var Konami = function () { var a = { addEvent: function (e, c, b, d) { if (e.addEventListener) { e.addEventListener(c, b, false) } else { if (e.attachEvent) { e["e" + c + b] = b; e[c + b] = function () { e["e" + c + b](window.event, d) }; e.attachEvent("on" + c, e[c + b]) } } }, input: "", pattern: "3838404037393739666513", load: function (b) { this.addEvent(document, "keydown", function (d, c) { if (c) { a = c } a.input += d ? d.keyCode : event.keyCode; if (a.input.indexOf(a.pattern) != -1) { a.code(b); a.input = ""; return } }, this); this.iphone.load(b) }, code: function (b) { window.location = b }, iphone: { start_x: 0, start_y: 0, stop_x: 0, stop_y: 0, tap: false, capture: false, keys: ["UP", "UP", "DOWN", "DOWN", "LEFT", "RIGHT", "LEFT", "RIGHT", "TAP", "TAP", "TAP"], code: function (b) { a.code(b) }, load: function (b) { a.addEvent(document, "touchmove", function (c) { if (c.touches.length == 1 && a.iphone.capture == true) { var d = c.touches[0]; a.iphone.stop_x = d.pageX; a.iphone.stop_y = d.pageY; a.iphone.tap = false; a.iphone.capture = false; a.iphone.check_direction() } }); a.addEvent(document, "touchend", function (c) { if (a.iphone.tap == true) { a.iphone.check_direction(b) } }, false); a.addEvent(document, "touchstart", function (c) { a.iphone.start_x = c.changedTouches[0].pageX; a.iphone.start_y = c.changedTouches[0].pageY; a.iphone.tap = true; a.iphone.capture = true }) }, check_direction: function (b) { x_magnitude = Math.abs(this.start_x - this.stop_x); y_magnitude = Math.abs(this.start_y - this.stop_y); x = ((this.start_x - this.stop_x) < 0) ? "RIGHT" : "LEFT"; y = ((this.start_y - this.stop_y) < 0) ? "DOWN" : "UP"; result = (x_magnitude > y_magnitude) ? x : y; result = (this.tap == true) ? "TAP" : result; if (result == this.keys[0]) { this.keys = this.keys.slice(1, this.keys.length) } if (this.keys.length == 0) { this.code(b) } } } }; return a };
