Created
April 8, 2014 19:59
-
-
Save hugeuser/10181755 to your computer and use it in GitHub Desktop.
Easter Eggs
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 ( $ ) { | |
var i, j = 0; | |
var matching = false; | |
var secret = [ | |
{ | |
cheat: 'monochrome', | |
code: [77, 79, 78, 79, 67, 72, 82, 79, 77, 69] | |
}, | |
{ | |
cheat: 'sepia', | |
code: [83, 69, 80, 73, 65] | |
}, | |
{ | |
cheat: 'acid', | |
code: [65, 67, 73, 68] | |
} | |
// etc. | |
]; | |
var len = secret.length; | |
$(document).keydown(function easter(e) { | |
for (i = len; i--;) { | |
if(e.keyCode === secret[i].code[j]) { | |
j++; | |
if(j === secret[i].code.length) { | |
$(document).unbind('keydown', easter); | |
activate(secret[i].cheat); | |
} | |
matching = true; | |
break; // we have (beginnings of) a match… | |
} | |
} | |
if (!matching) { | |
j = 0; // otherwise, reset | |
} | |
matching = false; | |
}); | |
function activate(code){ | |
$.getScript('/path/to/cheat.js', function(){ HUGE.cheat.init(code); | |
}); | |
} | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment