Created
March 25, 2013 16:34
-
-
Save bholmberg/5238495 to your computer and use it in GitHub Desktop.
AngularJS directive to cornify a web page when the "konami code" entered on the keyboard. I wrapped js I found on a blog into a DDO.
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
ngApp.directive("cornify", function () { | |
return { | |
link: function (scope, element, attrs) { | |
var konami_keys = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65]; | |
var konami_index = 0; | |
$(document).keydown(function(e){ | |
if (e.keyCode === konami_keys[konami_index++]) { | |
if (konami_index === konami_keys.length) { | |
$(document).unbind('keydown', arguments.callee); | |
$.getScript('http://www.cornify.com/js/cornify.js',function(){ | |
cornify_add(); | |
$(document).keydown(cornify_add); | |
}); | |
} | |
} else { | |
konami_index = 0; | |
} | |
}); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have modified this directive a bit to take custom callback to call when user enters the konami code :) https://github.com/dos1/angular-konami/blob/master/angular-konami.js