1/* 2 * Konami-JS ~ 3 * :: Now with support for touch events and multiple instances for 4 * :: those situations that call for multiple easter eggs! 5 * Code: http://konami-js.googlecode.com/ 6 * Examples: http://www.snaptortoise.com/konami-js 7 * Copyright (c) 2009 George Mandis (georgemandis.com, snaptortoise.com) 8 * Version: 1.4.1 (3/1//2013) 9 * Licensed under the GNU General Public License v3 10 * http://www.gnu.org/copyleft/gpl.html 11 * Tested in: Safari 4+, Google Chrome 4+, Firefox 3+, IE7+, Mobile Safari 2.2.1 and Dolphin Browser 12*/ 13 14var Konami = function(callback) { 15 var konami= { 16 addEvent:function ( obj, type, fn, ref_obj ) 17 { 18 if (obj.addEventListener) 19 obj.addEventListener( type, fn, false ); 20 else if (obj.attachEvent) 21 { 22 // IE 23 obj["e"+type+fn] = fn; 24 obj[type+fn] = function() { obj["e"+type+fn]( window.event,ref_obj ); } 25 obj.attachEvent( "on"+type, obj[type+fn] ); 26 } 27 }, 28 input:"", 29 pattern:"3838404037393739666513", 30 load: function(link) { 31 this.addEvent(document,"keydown", function(e,ref_obj) { 32 if (ref_obj) konami = ref_obj; // IE 33 konami.input+= e ? e.keyCode : event.keyCode; 34 if (konami.input.length > konami.pattern.length) konami.input = konami.input.substr((konami.input.length - konami.pattern.length)); 35 if (konami.input == konami.pattern) { 36 konami.code(link); 37 konami.input=""; 38 return; 39 } 40 },this); 41 this.iphone.load(link); 42 43 }, 44 code: function(link) { window.location=link}, 45 iphone:{ 46 start_x:0, 47 start_y:0, 48 stop_x:0, 49 stop_y:0, 50 tap:false, 51 capture:false, 52 orig_keys:"", 53 keys:["UP","UP","DOWN","DOWN","LEFT","RIGHT","LEFT","RIGHT","TAP","TAP","TAP"], 54 code: function(link) { konami.code(link);}, 55 load: function(link){ 56 this.orig_keys = this.keys; 57 konami.addEvent(document,"touchmove",function(e){ 58 if(e.touches.length == 1 && konami.iphone.capture==true){ 59 var touch = e.touches[0]; 60 konami.iphone.stop_x = touch.pageX; 61 konami.iphone.stop_y = touch.pageY; 62 konami.iphone.tap = false; 63 konami.iphone.capture=false; 64 konami.iphone.check_direction(); 65 } 66 }); 67 konami.addEvent(document,"touchend",function(evt){ 68 if (konami.iphone.tap==true) konami.iphone.check_direction(link); 69 },false); 70 konami.addEvent(document,"touchstart", function(evt){ 71 konami.iphone.start_x = evt.changedTouches[0].pageX; 72 konami.iphone.start_y = evt.changedTouches[0].pageY; 73 konami.iphone.tap = true; 74 konami.iphone.capture = true; 75 }); 76 }, 77 check_direction: function(link){ 78 x_magnitude = Math.abs(this.start_x-this.stop_x); 79 y_magnitude = Math.abs(this.start_y-this.stop_y); 80 x = ((this.start_x-this.stop_x) < 0) ? "RIGHT" : "LEFT"; 81 y = ((this.start_y-this.stop_y) < 0) ? "DOWN" : "UP"; 82 result = (x_magnitude > y_magnitude) ? x : y; 83 result = (this.tap==true) ? "TAP" : result; 84 85 if (result==this.keys[0]) this.keys = this.keys.slice(1,this.keys.length); 86 if (this.keys.length==0) { 87 this.keys=this.orig_keys; 88 this.code(link); 89 } 90 } 91 } 92 } 93 94 typeof callback === "string" && konami.load(callback); 95 if(typeof callback === "function") { 96 konami.code = callback; 97 konami.load(); 98 } 99 100 return konami; 101}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.