diff options
Diffstat (limited to 'smoke/astro.build-main/public/scripts/konami.js')
-rw-r--r-- | smoke/astro.build-main/public/scripts/konami.js | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/smoke/astro.build-main/public/scripts/konami.js b/smoke/astro.build-main/public/scripts/konami.js deleted file mode 100644 index 7995842a8..000000000 --- a/smoke/astro.build-main/public/scripts/konami.js +++ /dev/null @@ -1,59 +0,0 @@ -// Aha! These are not analytics at all! -class KonamiCode { - enabled = false; - keys = ["ArrowUp", "ArrowUp", "ArrowDown", "ArrowDown", "ArrowLeft", "ArrowRight", "ArrowLeft", "ArrowRight", "b", "a"]; - accepted = [...new Set(this.keys)]; - inputs = []; - - constructor({ enable, disable }) { - this.enable = enable; - this.disable = disable; - this.handleKey = this.handleKey.bind(this); - document.addEventListener('keydown', this.handleKey); - } - - handleKey({ key }) { - if (this.enabled) { - this.reset(); - return; - } - if (!this.accepted.includes(key)) return; - - if (this.keys[this.inputs.length] === key) { - this.handleInput(key) - } else { - this.reset(); - } - } - - handleInput(key) { - this.inputs.push(key); - - if (this.inputs.length === 10) { - this.handleMatch(); - } - } - - handleMatch() { - this.enabled = true; - this.enable(); - this.inputs = []; - } - - reset() { - if (this.enabled) { - this.enabled = false; - this.disable(); - } - if (this.inputs.length) { - this.inputs = []; - } - } -} - -export function init() { - new KonamiCode({ - enable: () => document.body.classList.add('🥚'), - disable: () => document.body.classList.remove('🥚'), - }); -} |