2019-03-17 06:55:50 +01:00
|
|
|
/// <reference path="./jquery.js" />
|
|
|
|
|
2019-03-29 02:55:28 +01:00
|
|
|
let konamiCode = ["ArrowUp", "ArrowUp", "ArrowDown", "ArrowDown", "ArrowLeft", "ArrowRight", "ArrowLeft", "ArrowRight", "b", "a"]
|
|
|
|
let lastKeys = []
|
2019-04-01 03:17:19 +02:00
|
|
|
let devKeys = false;
|
2019-03-29 02:55:28 +01:00
|
|
|
|
2019-03-17 06:55:50 +01:00
|
|
|
// Make this on all pages so video page also doesn't do this
|
|
|
|
$(document).on("keydown", function (e) {
|
2019-04-01 03:17:19 +02:00
|
|
|
lastKeys.push(e);
|
|
|
|
if (lastKeys.length > 10) {
|
|
|
|
lastKeys.shift();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (devKeys) {
|
|
|
|
let modifiedLastKeys = []
|
|
|
|
lastKeys.forEach((e) => {
|
|
|
|
switch (e.key) {
|
|
|
|
case " ":
|
|
|
|
modifiedLastKeys.push(`Space - ${e.keyCode}`);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
modifiedLastKeys.push(`${e.key} - ${e.keyCode}`);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
$("#devKeys").html(`'${modifiedLastKeys.join("', '")}'`);
|
|
|
|
}
|
2019-03-29 02:55:28 +01:00
|
|
|
|
2019-03-17 06:55:50 +01:00
|
|
|
if (e.which === 8 && !$(e.target).is("input, textarea")) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
2019-04-01 03:17:19 +02:00
|
|
|
|
|
|
|
checkKonami(e);
|
2019-03-17 06:55:50 +01:00
|
|
|
});
|
2019-03-29 02:55:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
function checkKonami(e) {
|
|
|
|
if (lastKeys.length === konamiCode.length) {
|
|
|
|
for (let i = 0; i < lastKeys.length; i++) {
|
2019-04-12 02:00:02 +02:00
|
|
|
if (lastKeys[i].key != konamiCode[i]) {
|
2019-03-29 02:55:28 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-04-01 03:17:19 +02:00
|
|
|
$("#remote").css("display", "block");
|
2019-03-29 02:55:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function flipRemote() {
|
|
|
|
$("#remote").attr("src", "/static/img/remote_active.png");
|
|
|
|
setTimeout(() => {
|
|
|
|
$("#remote").attr("src", "/static/img/remote.png");
|
|
|
|
}, Math.round(Math.random() * 10000) + 1000);
|
|
|
|
}
|
2019-04-01 03:17:19 +02:00
|
|
|
|
|
|
|
function enableDebug() {
|
|
|
|
devKeys = true;
|
|
|
|
$("#devKeys").css("display", "block");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
// Just add a / above to uncomment the block
|
|
|
|
setTimeout(() => {
|
|
|
|
enableDebug();
|
|
|
|
alert("Comment this out. It shows the keys.");
|
|
|
|
}, 150);
|
|
|
|
//*/
|