Created
October 25, 2011 09:25
-
-
Save RobinHerbots/1312012 to your computer and use it in GitHub Desktop.
jquery konami code plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$(document).ready(function() { | |
$(document).konami(function() { | |
var s = document.createElement('script'); | |
s.type = 'text/javascript'; | |
document.body.appendChild(s); | |
s.src = 'http://erkie.github.com/asteroids.min.js'; | |
}); | |
$(document).konami(function() { | |
var u = navigator.userAgent.toLowerCase(), v = (u.match(/.+?(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [0, '0'])[1]; | |
if (/msie/.test(u) && parseInt(v, 10) <= 9) { | |
if (confirm('Ready to kill the iexplorer?')) { | |
window.open('', '_parent', ''); | |
window.close(); | |
} | |
} | |
}, { 'code': [73, 69, 83, 85, 67, 75, 83] }); //iesucks | |
}); | |
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
//konami code plugin | |
$.konami = { | |
defaults: { | |
'code': [38, 38, 40, 40, 37, 39, 37, 39, 66, 65], | |
'step': 0 | |
} | |
}; | |
$.fn.konami = function(fn, options) { | |
var opts = $.extend({}, $.konami.defaults, options); | |
return this.each(function() { | |
$(this).bind('konami.' + opts.code.join(''), fn) | |
.bind('keyup', function(event) { | |
if (event.keyCode == opts.code[opts.step]) | |
opts.step++; | |
else | |
opts.step = 0; | |
if (opts.step == opts.code.length) { | |
$(this).trigger('konami.' + opts.code.join('')); | |
opts.step = 0; | |
} | |
}); | |
return this; | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment