website/src/assets/js/canopy.js

45 lines
1.3 KiB
JavaScript

(function() {
// Logo Easter Egg
document.querySelector("span.logo").addEventListener("dblclick", (e) => {
e.currentTarget.classList.toggle("rotated");
});
// Konami Code Easter Egg
var pattern = ['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight', 'b', 'a'];
var current = 0;
var keyHandler = function (event) {
// If the key isn't in the pattern, or isn't the current key in the pattern, reset
if (pattern.indexOf(event.key) < 0 || event.key !== pattern[current]) {
current = 0;
return;
}
// Update how much of the pattern is complete
current++;
// If complete, alert and reset
if (pattern.length === current) {
current = 0;
document.querySelector("body").classList.add("animate");
}
};
// Listen for keydown events
document.addEventListener('keydown', keyHandler, false);
// Discord
document.getElementById("discord").addEventListener("click", () => {
let widget = document.querySelector("#discord > .widget");
if (widget.style.display === "block") {
widget.style.display = "none";
} else {
widget.style.display = "block";
}
});
})();