Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed bug where Konami-JS would not reset itself after execution in iOS.

git-svn-id: https://konami-js.googlecode.com/svn/trunk@24 a62f2a58-33d0-11de-8c0b-2fbac4a05959
  • Loading branch information...
commit ca262b2b546797ec4ecd58e049e442f17baa006b 1 parent 8593a8f
georgemandis authored
Showing with 6 additions and 7 deletions.
  1. +5 −6 konami.js
  2. +1 −1  konami.pack.js
View
11 konami.js
@@ -6,10 +6,10 @@
* Code: http://konami-js.googlecode.com/
* Examples: http://www.snaptortoise.com/konami-js
* Copyright (c) 2009 George Mandis (georgemandis.com, snaptortoise.com)
- * Version: 1.3.2 (7/02/2010)
+ * Version: 1.3.3 (4/16/2011)
* 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+ and Mobile Safari 2.2.1
+ * Tested in: Safari 4+, Google Chrome 4+, Firefox 3+, IE7+, Mobile Safari 2.2.1 and Dolphin Browser
*/
var Konami = function() {
@@ -30,8 +30,7 @@ var Konami = function() {
input:"",
pattern:"3838404037393739666513",
/*pattern:"38384040373937396665",*/
- load: function(link) {
-
+ load: function(link) {
this.addEvent(document,"keydown", function(e,ref_obj) {
if (ref_obj) konami = ref_obj; // IE
konami.input+= e ? e.keyCode : event.keyCode;
@@ -53,11 +52,11 @@ var Konami = function() {
stop_y:0,
tap:false,
capture:false,
- orig_keys:"",
+ orig_keys:"",
keys:["UP","UP","DOWN","DOWN","LEFT","RIGHT","LEFT","RIGHT","TAP","TAP","TAP"],
code: function(link) { konami.code(link);},
load: function(link){
- orig_keys = this.keys;
+ this.orig_keys = this.keys;
konami.addEvent(document,"touchmove",function(e){
if(e.touches.length == 1 && konami.iphone.capture==true){
var touch = e.touches[0];
View
2  konami.pack.js
@@ -1,4 +1,4 @@
var Konami=function(){var a={addEvent:function(b,c,d,e){if(b.addEventListener)b.addEventListener(c,d,false);else if(b.attachEvent){b["e"+c+d]=d;b[c+d]=function(){b["e"+c+d](window.event,e)};b.attachEvent("on"+c,b[c+d])}},input:"",pattern:"3838404037393739666513",load:function(b){this.addEvent(document,"keydown",function(c,d){if(d)a=d;a.input+=c?c.keyCode:event.keyCode;if(a.input.length>a.pattern.length)a.input=a.input.substr(a.input.length-a.pattern.length);if(a.input==a.pattern){a.code(b);a.input=
-""}},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,orig_keys:"",keys:["UP","UP","DOWN","DOWN","LEFT","RIGHT","LEFT","RIGHT","TAP","TAP","TAP"],code:function(b){a.code(b)},load:function(b){orig_keys=this.keys;a.addEvent(document,"touchmove",function(c){if(c.touches.length==1&&a.iphone.capture==true){c=c.touches[0];a.iphone.stop_x=c.pageX;a.iphone.stop_y=c.pageY;a.iphone.tap=false;a.iphone.capture=false;a.iphone.check_direction()}});
+""}},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,orig_keys:"",keys:["UP","UP","DOWN","DOWN","LEFT","RIGHT","LEFT","RIGHT","TAP","TAP","TAP"],code:function(b){a.code(b)},load:function(b){this.orig_keys=this.keys;a.addEvent(document,"touchmove",function(c){if(c.touches.length==1&&a.iphone.capture==true){c=c.touches[0];a.iphone.stop_x=c.pageX;a.iphone.stop_y=c.pageY;a.iphone.tap=false;a.iphone.capture=false;a.iphone.check_direction()}});
a.addEvent(document,"touchend",function(){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.keys=this.orig_keys;this.code(b)}}}};return a};
Please sign in to comment.
Something went wrong with that request. Please try again.