summaryrefslogtreecommitdiff
path: root/konami/js
diff options
context:
space:
mode:
authors1nical <[email protected]>2019-08-11 17:21:35 -0700
committers1nical <[email protected]>2019-08-11 17:21:35 -0700
commit996634e14f343cdbb5bb62c98012a5522baedf3e (patch)
tree219c8b6461104d031872b12d9f01f97b0f14139b /konami/js
parentfix various formatting issues (diff)
downloads1n.pw-admin-996634e14f343cdbb5bb62c98012a5522baedf3e.tar.xz
s1n.pw-admin-996634e14f343cdbb5bb62c98012a5522baedf3e.zip
added easter eggs
- fixed formatting issue - added bttf - console log codes - easter egg pack
Diffstat (limited to 'konami/js')
-rw-r--r--konami/js/main.js111
1 files changed, 110 insertions, 1 deletions
diff --git a/konami/js/main.js b/konami/js/main.js
index 47e21f7..9ffed54 100644
--- a/konami/js/main.js
+++ b/konami/js/main.js
@@ -1,3 +1,10 @@
+// LOADER ANIMATION
+$(window).on("load", function () {
+ console.log("UP, UP, DOWN, DOWN, LEFT, RIGHT, LEFT, RIGHT, B, A")
+ console.log("Biff, Marty, Emmett, Goldie")
+ console.log("pie, ufo, walk, cool, balloon, hangover, kirby, no, onmyway, haters, board, snorlax, fly, earth, thankyou, swim, penguin, handsome, tank, jump, winner, fox, mario, joker, rabbit, piggy, psyduck, dragon, salamander, airguitar, pikachu, bravo, ghost, britney, pikarun, catrun, koggy, sonic, doggy, spongebob, gun, money, bird, piqiu, lol, ohhh, nyancat")
+})
+
// SCROLLING TITLE
var space = " ";
var speed = "60";
@@ -109,4 +116,106 @@ window.onload = function () {
new TxtRotate(elements[i], JSON.parse(toRotate), period);
}
}
-}; \ No newline at end of file
+};
+
+// BIFF, MARTY, EMMETT, GOLDIE
+
+// give $ to jQuery
+(function ($) {
+
+ /**==============================================================
+ * BTTF CHARACTER EASTER EGGS
+ * ==============================================================
+ */
+ var characters = {};
+ var pressedKeys = [];
+
+ /**
+ * Plays the audio clip for a specific easter egg character
+ * @param {string} character name of character
+ */
+ function playAudio(character) {
+ setTimeout(function () {
+ characters[character].audioFile.play();
+ setTimeout(function () {
+ toggleShowChar(character);
+ updateEggs();
+ }, characters[character].audioLength);
+ }, 300);
+ }
+
+ /**
+ * Toggles the display of an easter egg character
+ * @param {string} character character name
+ */
+ function toggleShowChar(character) {
+ $('body').toggleClass(characters[character].name + '-show');
+ }
+
+ /**
+ * Add characters' information once page loads
+ */
+ $(document).ready(function () {
+ characters = {
+ 'guessed': [],
+ 'marty': {
+ 'name': 'marty',
+ 'nameKeys': "77,65,82,84,89",
+ 'audioFile': $('audio.marty')[0],
+ 'audioLength': 1300,
+ },
+ 'docbrown': {
+ 'name': 'docbrown',
+ 'nameKeys': "69,77,77,69,84,84",
+ 'audioFile': $('audio.docbrown')[0],
+ 'audioLength': 2500,
+ },
+ 'biff': {
+ 'name': 'biff',
+ 'nameKeys': "66,73,70,70",
+ 'audioFile': $('audio.biff')[0],
+ 'audioLength': 1100,
+ },
+ 'goldie': {
+ 'name': 'goldie',
+ 'nameKeys': "71,79,76,68,73,69",
+ 'audioFile': $('audio.goldie')[0],
+ 'audioLength': 4000,
+ }
+ };
+ });
+
+ /**
+ * Track character names being typed
+ */
+ $(window).keydown(function (e) {
+
+ pressedKeys.push(e.keyCode);
+
+ // loop through characters
+ for (var character in characters) {
+
+ // if the "pressedKeys" contains the current character name
+ if (pressedKeys.toString().indexOf(characters[character].nameKeys) >= 0) {
+
+ // reset the pressedKeys array
+ pressedKeys = [];
+
+ // add "show" class to animate the character in
+ toggleShowChar(character);
+
+ if ($.inArray(character, characters.guessed) === -1) {
+ characters.guessed.push(character);
+ }
+
+ // wait a second and play the character's audio file
+ playAudio(character);
+ }
+ }
+
+ // reset pressedKeys at 50 keypresses to save memory
+ if (pressedKeys.length > 500) { pressedKeys = []; }
+
+ });
+
+})(jQuery); \ No newline at end of file