summaryrefslogtreecommitdiff
path: root/sitestatic/konami.min.js
blob: d3eef8efdb76ee7c3ceb3980885e6b1852dd4430 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
/*
	* Konami-JS ~ 
	* :: Now with support for touch events and multiple instances for 
	* :: those situations that call for multiple easter eggs!
	* Code: http://konami-js.googlecode.com/
	* Examples: http://www.snaptortoise.com/konami-js
	* Copyright (c) 2009 George Mandis (georgemandis.com, snaptortoise.com)
	* Version: 1.4.0 (1/21/2013)
	* Licensed under the GNU General Public License v3
	* http://www.gnu.org/copyleft/gpl.html
	* Tested in: Safari 4+, Google Chrome 4+, Firefox 3+, IE7+, Mobile Safari 2.2.1 and Dolphin Browser
*/
var Konami=function(t){var i={addEvent:function(t,e,n,i){t.addEventListener?t.addEventListener(e,n,!1):t.attachEvent&&(t["e"+e+n]=n,t[e+n]=function(){t["e"+e+n](window.event,i)},t.attachEvent("on"+e,t[e+n]))},input:"",pattern:"3838404037393739666513",load:function(n){this.addEvent(document,"keydown",function(t,e){if(e&&(i=e),i.input+=t?t.keyCode:event.keyCode,i.input.length>i.pattern.length&&(i.input=i.input.substr(i.input.length-i.pattern.length)),i.input==i.pattern)return i.code(n),void(i.input="")},this),this.iphone.load(n)},code:function(t){window.location=t},iphone:{start_x:0,start_y:0,stop_x:0,stop_y:0,tap:!1,capture:!1,orig_keys:"",keys:["UP","UP","DOWN","DOWN","LEFT","RIGHT","LEFT","RIGHT","TAP","TAP","TAP"],code:function(t){i.code(t)},load:function(e){this.orig_keys=this.keys,i.addEvent(document,"touchmove",function(t){if(1==t.touches.length&&!0===i.iphone.capture){var e=t.touches[0];i.iphone.stop_x=e.pageX,i.iphone.stop_y=e.pageY,i.iphone.tap=!1,i.iphone.capture=!1,i.iphone.check_direction()}}),i.addEvent(document,"touchend",function(t){!0===i.iphone.tap&&i.iphone.check_direction(e)},!1),i.addEvent(document,"touchstart",function(t){i.iphone.start_x=t.changedTouches[0].pageX,i.iphone.start_y=t.changedTouches[0].pageY,i.iphone.tap=!0,i.iphone.capture=!0})},check_direction:function(t){var e=Math.abs(this.start_x-this.stop_x),n=Math.abs(this.start_y-this.stop_y),i=this.start_x-this.stop_x<0?"RIGHT":"LEFT",o=this.start_y-this.stop_y<0?"DOWN":"UP",s=n<e?i:o;(s=!0===this.tap?"TAP":s)==this.keys[0]&&(this.keys=this.keys.slice(1,this.keys.length)),0==this.keys.length&&(this.keys=this.orig_keys,this.code(t))}}};return"string"==typeof t&&i.load(t),"function"==typeof t&&(i.code=t,i.load()),i};