Last active
August 29, 2015 14:03
-
-
Save lyonsinbeta/42e74d930b02a132ff25 to your computer and use it in GitHub Desktop.
CU Online Easter Eggs
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
var beetlejuice = "6669698476697485736769"; | |
var konami = "38384040373937396665"; | |
var input = ""; | |
var timer; | |
//The following function sets a timer that checks for user input. You can change the variation in how long the user has to input by changing the number in ‘setTimeout.’ In this case, it’s set for 500 milliseconds or ½ second. | |
window.addEventListener("keyup", function(e) { | |
input += e.which; | |
clearTimeout(timer); | |
timer = setTimeout(function() { input = ""; }, 500); | |
check_input(); | |
}, false); | |
//Once the time is up, this function is run to see if the user’s input is the same as the secret code | |
function check_input() { | |
switch (input) { | |
case beetlejuice: | |
var audio = new Audio('beetlejuice.mp3'); | |
audio.play(); | |
break; | |
case konami: | |
alert("Straight A's unlocked!"); | |
break; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment