diff options
| author | s1n <[email protected]> | 2019-10-28 17:12:18 -0700 |
|---|---|---|
| committer | s1n <[email protected]> | 2019-10-28 17:12:18 -0700 |
| commit | d8b68deaec1a913cc6659083ac700a3979e9669f (patch) | |
| tree | fea84540a04a10f7b0b1303d6e672b42db7d84c3 /js | |
| parent | add discoird (diff) | |
| download | s1n.pw-admin-d8b68deaec1a913cc6659083ac700a3979e9669f.tar.xz s1n.pw-admin-d8b68deaec1a913cc6659083ac700a3979e9669f.zip | |
change konami to single page :)))
Diffstat (limited to 'js')
| -rw-r--r-- | js/app.js | 79 |
1 files changed, 77 insertions, 2 deletions
@@ -30,9 +30,21 @@ var allowedKeys = { 39: 'right',
40: 'down',
65: 'a',
- 66: 'b'
+ 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'];
@@ -62,9 +74,72 @@ document.addEventListener('keydown', function (e) { }
});
+// 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()
+}
+
+function deactivateCheats() {
- window.location.href = "/konami";
+ swapStyleSheet('/css/main.css');
+
+ changeFavicon('favicon.ico');
+
+ var x = document.getElementById("music");
+ function pauseAudio() {
+ x.pause();
+ }
+ pauseAudio()
}
var TxtRotate = function (el, toRotate, period) {
|