diff options
| author | s1n <[email protected]> | 2020-03-28 10:31:08 -0700 |
|---|---|---|
| committer | s1n <[email protected]> | 2020-03-28 10:31:08 -0700 |
| commit | 6b81836e6b9815a2996a55ad37dcaa4d89f99e42 (patch) | |
| tree | 74bb9aa78ca31a6acfffd908e34dfb0df433c707 /js/app.js | |
| parent | Create .gitignore (diff) | |
| download | cyne.cf-backup-master.tar.xz cyne.cf-backup-master.zip | |
Diffstat (limited to 'js/app.js')
| -rw-r--r-- | js/app.js | 210 |
1 files changed, 210 insertions, 0 deletions
diff --git a/js/app.js b/js/app.js new file mode 100644 index 0000000..2b21815 --- /dev/null +++ b/js/app.js @@ -0,0 +1,210 @@ +// KONAMI CODE HINTS +$(window).on("load", function () { + console.log("UP, UP, DOWN, DOWN, LEFT, RIGHT, LEFT, RIGHT, B, A") + +}) + +/* +// THIS CHECKS WHAT OS THE USER IS ON +// This is a old variation so don't use this. +if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent)) { + location.href = './mobile/'; +} +*/ + +/* Honestly I have NO idea what this is but it was in the original site source code so I kept it :) +**(async () => { +** if (navigator.webdriver || document.visibilityState === 'prerender' || !location.hostname) { +** return; +** } +** +** document.querySelector('a[href="/cdn-cgi/l/email-protection"]').href = `\x6dailto:hi\x40${location.hostname}`; +** })(); +*/ + +// KONAMI CODE FOR ALTERNATE 90S SITE +// A key map of allowed keys +var allowedKeys = { + 37: 'left', + 38: 'up', + 39: 'right', + 40: 'down', + 65: 'a', + 66: 'b', + 8: 'backspace' +}; + +// To somewhat stop backspace/ refresh spamming +window.addEventListener('keydown', function (event) { + + if (event.keyCode === 8) { + + event.preventDefault(); + + return false; + } +}); + +// The 'official' Konami Code sequence +var konamiCode = ['up', 'up', 'down', 'down', 'left', 'right', 'left', 'right', 'b', 'a']; + +// A variable to remember the 'position' the user has reached so far. +var konamiCodePosition = 0; + +// Add keydown event listener +document.addEventListener('keydown', function (e) { + // Get the value of the key code from the key map + var key = allowedKeys[e.keyCode]; + // Get the value of the required key from the Konami Code + var requiredKey = konamiCode[konamiCodePosition]; + + // Compare the key with the required key + if (key == requiredKey) { + + // Move to the next key in the Konami Code sequence + konamiCodePosition++; + + // Ff the last key is reached, activate cheats + if (konamiCodePosition == konamiCode.length) { + activateCheats(); + konamiCodePosition = 0; + } + } else { + konamiCodePosition = 0; + } +}); + +// Back to normal sequence +var backCode = ['backspace']; + +var backCodePosition = 0; + +document.addEventListener('keydown', function (e) { + var key = allowedKeys[e.keyCode]; + var requiredKey = backCode[backCodePosition]; + + if (key == requiredKey) { + + backCodePosition++; + + if (backCodePosition == backCode.length) { + deactivateCheats(); + backCodePosition = 0; + } + } else { + backCodePosition = 0; + } +}); + +function swapStyleSheet(sheet) { + document.getElementById('pagestyle').setAttribute('href', sheet); +} + +// Change favicon +document.head = document.head || document.getElementsByTagName('head')[0]; + +function changeFavicon(src) { + var link = document.createElement('link'), + oldLink = document.getElementById('dynamic-favicon'); + link.id = 'dynamic-favicon'; + link.rel = 'shortcut icon'; + link.href = src; + if (oldLink) { + document.head.removeChild(oldLink); + } + document.head.appendChild(link); +} + +function activateCheats() { + swapStyleSheet('/konami/css/main.css'); + // I overworked for this smh... + + changeFavicon('/konami/assets/images/small-spinning-globe3.gif'); + + var x = document.getElementById("music"); + function playAudio() { + x.play(); + } + playAudio(); + + document.getElementById("directory-konami").innerHTML = ` + <a href="/directory/" class="nav-item" active-color="rebeccapurple">Directory</a> + `; + + if (screen.width > 768) { // If Desktop + document.getElementById("m-konami").innerHTML = ` + <img src="/assets/imgs/clairo2.gif" alt="" width="30px"> + `; + } else { // If Mobile + document.getElementById("m-konami").innerHTML = ` + <img src="/assets/imgs/clairo2.gif" onclick="deactivateCheats()" alt="" width="30px"> + `; + } + + document.title = "// s1n.ical // Landing Page //" +} + +function deactivateCheats() { + + swapStyleSheet('/css/main.css'); + + changeFavicon('favicon.ico'); + + var x = document.getElementById("music"); + function pauseAudio() { + x.pause(); + } + pauseAudio(); + + document.getElementById("directory-konami").innerHTML = ``; + + document.getElementById("m-konami").innerHTML = ` + <div class="clairo"> + <img src="/assets/imgs/clairo2.gif" alt="" width="30px" onclick="activateCheats()"> + </div> + `; + + document.title = "s1nical - Landing Page"; +} + +var TxtRotate = function (el, toRotate, period) { + this.toRotate = toRotate; + this.el = el; + this.loopNum = 0; + this.period = parseInt(period, 10) || 2000; + this.txt = ''; + this.tick(); + this.isDeleting = false; +}; + +TxtRotate.prototype.tick = function () { + var i = this.loopNum % this.toRotate.length; + var fullTxt = this.toRotate[i]; + + if (this.isDeleting) { + this.txt = fullTxt.substring(0, this.txt.length - 1); + } else { + this.txt = fullTxt.substring(0, this.txt.length + 1); + } + + this.el.innerHTML = '<span class="wrap">' + this.txt + '</span>'; + + var that = this; + var delta = 300 - Math.random() * 100; + + + setTimeout(function () { + that.tick(); + }, delta); +}; + +window.onload = function () { + var elements = document.getElementsByClassName('txt-rotate'); + for (var i = 0; i < elements.length; i++) { + var toRotate = elements[i].getAttribute('data-rotate'); + var period = elements[i].getAttribute('data-period'); + if (toRotate) { + new TxtRotate(elements[i], JSON.parse(toRotate), period); + } + } +}; |