Created
January 7, 2015 04:56
-
-
Save jgrevich/bf74caa54982bca8c486 to your computer and use it in GitHub Desktop.
konami code easter egg in js
This file contains hidden or 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 - up up down down left right left right b a | |
var code1 = String.fromCharCode(38, 38, 40, 40, 37, 39, 37, 39, 66, 65); | |
var code2 = String.fromCharCode(38, 38, 40, 40, 37, 39, 37, 39, 65, 66); | |
var codeBuffer = ""; | |
$(document).keyup(function (e) { | |
codeBuffer += String.fromCharCode(e.which); | |
if (code1.substring(0, codeBuffer.length) == codeBuffer) { | |
if (code1.length == codeBuffer.length) { | |
toggle1(); | |
codeBuffer = String.fromCharCode(38, 38, 40, 40, 37, 39, 37, 39, 66); | |
} | |
} else if (code2.substring(0, codeBuffer.length) == codeBuffer) { | |
if (code2.length == codeBuffer.length) { | |
toggle2(); | |
codeBuffer = ""; | |
} | |
} else { | |
codeBuffer = ""; | |
} | |
}); | |
function toggle1() { | |
var $body = $("body"); | |
if ($body.raptorize) { | |
$body.raptorize(); | |
} else { | |
$("head").append('<script src="/_/logic/jquery.raptorize.1.0.js?'+Math.random()+'"></script>'); | |
} | |
} | |
function toggle2() { | |
window.DEBUG_FLAG = !window.DEBUG_FLAG; | |
window.DEBUG_FILTER_INCLUDE = null; | |
window.DEBUG_FILTER_EXCLUDE = null; | |
window.DEBUG_TO_CONSOLE = false; | |
window.logInited=true; | |
updateConsoleVisibility(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment