my eye

Simplify and optimize konami code

Committed edd148

--- a/canopy/static/enliven.js
+++ b/canopy/static/enliven.js

 import { _, cookies, go, upgradeLink } from '/static/web.js'
 
 let mode = 'site'
-const konamiCharacters = [38, 40, 37, 39, 65, 66, 13]
-const konamiSolution = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13]
-let konamiQueue = ['', '', '', '', '', '', '', '', '', '', '']
+const konamiCode = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13]
+const konamiCodeJSON = JSON.stringify(konamiCode)
+let konamiCodeFIFO = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
 
 // TODO $.load(...)
 document.addEventListener('DOMContentLoaded', ev => {
     }
     if (ev.target.tagName == 'INPUT' || ev.target.tagName == 'TEXTAREA')
       return
-    if (konamiCharacters.indexOf(ev.keyCode) != -1) {
-      konamiQueue = konamiQueue.slice(1).concat([ev.keyCode])  // FIFO
-      if (JSON.stringify(konamiQueue) == JSON.stringify(konamiSolution)) {
-        console.log('KONAMI')
+    if (konamiCode.indexOf(ev.keyCode) != -1) {
+      konamiCodeFIFO = konamiCodeFIFO.slice(1).concat(ev.keyCode)
+      if (JSON.stringify(konamiCodeFIFO) == konamiCodeJSON) {
         return
       }
     }