From 173af04d11cdb14dcafc1c084cb00e5df7e9629f Mon Sep 17 00:00:00 2001 From: Filip Rojek Date: Wed, 27 Aug 2025 18:27:53 +0200 Subject: [PATCH] chore(console.js): remove obsolete console.js file --- static/js/console.js | 109 ------------------------------------------- 1 file changed, 109 deletions(-) delete mode 100644 static/js/console.js diff --git a/static/js/console.js b/static/js/console.js deleted file mode 100644 index ef91e3f..0000000 --- a/static/js/console.js +++ /dev/null @@ -1,109 +0,0 @@ -const c = document.querySelector(".console"); -const ps1 = "[fr@website ~]$ "; -const motd = "Welcome to my website!
You can use `help` for more informations :)"; -let line = ""; - -function exec(command) { - switch (command[0]) { - case "help": - line = "help
author
contact
clear
echo"; - break; - case "author": - line = "Filip Rojek, 2023"; - break; - case "contact": - line = - "Filip Rojek <filip@filiprojek.cz>
web: www.filiprojek.cz
telegram: @filiprojek"; - break; - case "clear": - write("000ctrll"); - return false; - case "echo": - line = ""; - command.forEach((cmd, i) => { - if (i === 0) return; - line += cmd + " "; - }); - line = line.substring(0, line.length - 1); // remove last space - break; - default: - line = "frsh: " + command[0] + ": command not found"; - break; - } - - return line; -} - -function write(key, payload) { - switch (key) { - case "Enter": { - command = c.lastChild.textContent.replace(ps1, ""); - command = command.split(" "); - const out = exec(command); - if (out !== false) { - line = document.createElement("p"); - line.innerHTML += out; - line.innerHTML += "
"; - c.appendChild(line); - line = document.createElement("p"); - line.innerHTML += ps1; - c.appendChild(line); - } - command = ""; - break; - } - case "000ctrll": - c.innerHTML = ""; - if (payload == motd) c.innerHTML = motd; - line = document.createElement("p"); - line.innerHTML += ps1; - c.appendChild(line); - break; - case "000backspace": - if (c.lastChild.textContent.slice(0, -1) !== ps1.slice(0, -1)) { - c.lastChild.innerHTML = c.lastChild.textContent.slice(0, -1); - } - break; - - default: - c.lastChild.innerHTML += key; - } -} - -function customCtrlShortcuts(plusKey) { - document.addEventListener("keydown", (e) => { - if (e.ctrlKey && e.key == plusKey) { - e.preventDefault(); - write("000ctrl" + plusKey); - } - }); -} - -// On load init the terminal -window.addEventListener("load", () => { - write("000ctrll", motd); - if (navigator.userAgent.toLowerCase().includes("mobile")) { - const mi = document.querySelector(".mobile-input"); - mi.style = "opacity: 0; width: 0; height: 0"; - c.addEventListener("click", (e) => { - mi.focus(); - }); - } -}); - -// Capture the keypress -window.addEventListener("keypress", (e) => { - e.preventDefault(); - write(e.key); -}); - -window.addEventListener("keydown", (e) => { - if (e.key == "Backspace") { - e.preventDefault(); - write("000backspace"); - } -}); - -// Register custom ctrl shortcuts -customCtrlShortcuts("l"); // ctrl + l -customCtrlShortcuts("c"); // ctrl + c