style: format JSON and JavaScript files for improved readability and consistency

style(mobile-navbar.js): format code for consistency and improve readability by adding semicolons and proper indentation
This commit is contained in:
2025-08-27 18:14:10 +02:00
parent 1dfdcd271c
commit d8f53890d2
4 changed files with 169 additions and 171 deletions

View File

@@ -1,30 +1,28 @@
let codes = document.querySelectorAll("pre") const codes = document.querySelectorAll("pre");
codes.forEach(code => { codes.forEach((code) => {
const elWrapper = document.createElement("div") const elWrapper = document.createElement("div");
elWrapper.classList.add("copy-code-wrapper") elWrapper.classList.add("copy-code-wrapper");
const el = document.createElement("span");
el.textContent = "Copy";
el.classList.add("copy-code");
const el = document.createElement("span") elWrapper.appendChild(el);
el.textContent = "Copy"
el.classList.add("copy-code")
elWrapper.appendChild(el) code.parentNode.insertBefore(elWrapper, code);
code.parentNode.insertBefore(elWrapper, code) let textContent = "";
code.childNodes.forEach((child) => {
let textContent = ""
code.childNodes.forEach(child => {
textContent += child.textContent; textContent += child.textContent;
}) });
elWrapper.addEventListener("click", (e) => { elWrapper.addEventListener("click", (e) => {
e.preventDefault() e.preventDefault();
navigator.clipboard.writeText(textContent) navigator.clipboard.writeText(textContent);
el.textContent = "Copied!" el.textContent = "Copied!";
setTimeout(() => { setTimeout(() => {
el.textContent = "Copy" el.textContent = "Copy";
}, 5000); }, 5000);
}) });
}) });

View File

@@ -1,107 +1,109 @@
const c = document.querySelector(".console") const c = document.querySelector(".console");
const ps1 = "[fr@website ~]$ " const ps1 = "[fr@website ~]$ ";
const motd = "Welcome to my website!<br>You can use `help` for more informations :)" const motd = "Welcome to my website!<br>You can use `help` for more informations :)";
let line = ""; let line = "";
function exec(command) { function exec(command) {
switch (command[0]) { switch (command[0]) {
case "help": case "help":
line = "help<br>author<br>contact<br>clear<br>echo" line = "help<br>author<br>contact<br>clear<br>echo";
break; break;
case "author": case "author":
line = "Filip Rojek, 2023" line = "Filip Rojek, 2023";
break break;
case "contact": case "contact":
line = "Filip Rojek &lt<a href='mailto: &#102;&#105;&#108;&#105;&#112;&#064;&#102;&#105;&#108;&#105;&#112;&#114;&#111;&#106;&#101;&#107;&#046;&#099;&#122;'>&#102;&#105;&#108;&#105;&#112;&#064;&#102;&#105;&#108;&#105;&#112;&#114;&#111;&#106;&#101;&#107;&#046;&#099;&#122;</a>&gt<br>web: <a href='https://filiprojek.cz' target='_blank'>www.filiprojek.cz</a><br>telegram: <a href='https://t.me/filiprojek' target='_blank'>@filiprojek</a>" line =
break "Filip Rojek &lt<a href='mailto: &#102;&#105;&#108;&#105;&#112;&#064;&#102;&#105;&#108;&#105;&#112;&#114;&#111;&#106;&#101;&#107;&#046;&#099;&#122;'>&#102;&#105;&#108;&#105;&#112;&#064;&#102;&#105;&#108;&#105;&#112;&#114;&#111;&#106;&#101;&#107;&#046;&#099;&#122;</a>&gt<br>web: <a href='https://filiprojek.cz' target='_blank'>www.filiprojek.cz</a><br>telegram: <a href='https://t.me/filiprojek' target='_blank'>@filiprojek</a>";
break;
case "clear": case "clear":
write("000ctrll") write("000ctrll");
return false return false;
case "echo": case "echo":
line = "" line = "";
command.forEach((cmd, i) => { command.forEach((cmd, i) => {
if (i === 0) return if (i === 0) return;
line += cmd + " " line += cmd + " ";
}); });
line = line.substring(0, line.length - 1) // remove last space line = line.substring(0, line.length - 1); // remove last space
break break;
default: default:
line = "frsh: " + command[0] + ": command not found" line = "frsh: " + command[0] + ": command not found";
break; break;
} }
return line return line;
} }
function write(key, payload) { function write(key, payload) {
switch (key) { switch (key) {
case "Enter": case "Enter": {
command = c.lastChild.textContent.replace(ps1, "") command = c.lastChild.textContent.replace(ps1, "");
command = command.split(" "); command = command.split(" ");
let out = exec(command) const out = exec(command);
if (out !== false) { if (out !== false) {
line = document.createElement("p") line = document.createElement("p");
line.innerHTML += out line.innerHTML += out;
line.innerHTML += "<br>" line.innerHTML += "<br>";
c.appendChild(line) c.appendChild(line);
line = document.createElement("p") line = document.createElement("p");
line.innerHTML += ps1 line.innerHTML += ps1;
c.appendChild(line) c.appendChild(line);
}
command = "";
break;
} }
command = ""
break
case "000ctrll": case "000ctrll":
c.innerHTML = "" c.innerHTML = "";
if(payload == motd) c.innerHTML = motd if (payload == motd) c.innerHTML = motd;
line = document.createElement("p") line = document.createElement("p");
line.innerHTML += ps1 line.innerHTML += ps1;
c.appendChild(line) c.appendChild(line);
break break;
case "000backspace": case "000backspace":
if (c.lastChild.textContent.slice(0, -1) !== ps1.slice(0, -1)) { if (c.lastChild.textContent.slice(0, -1) !== ps1.slice(0, -1)) {
c.lastChild.innerHTML = c.lastChild.textContent.slice(0, -1) c.lastChild.innerHTML = c.lastChild.textContent.slice(0, -1);
} }
break break;
default: default:
c.lastChild.innerHTML += key c.lastChild.innerHTML += key;
} }
} }
function customCtrlShortcuts(plusKey) { function customCtrlShortcuts(plusKey) {
document.addEventListener("keydown", e => { document.addEventListener("keydown", (e) => {
if (e.ctrlKey && e.key == plusKey) { if (e.ctrlKey && e.key == plusKey) {
e.preventDefault() e.preventDefault();
write("000ctrl"+plusKey) write("000ctrl" + plusKey);
} }
}) });
} }
// On load init the terminal // On load init the terminal
window.addEventListener("load", () => { window.addEventListener("load", () => {
write("000ctrll", motd) write("000ctrll", motd);
if (navigator.userAgent.toLowerCase().includes("mobile")) { if (navigator.userAgent.toLowerCase().includes("mobile")) {
const mi = document.querySelector(".mobile-input") const mi = document.querySelector(".mobile-input");
mi.style="opacity: 0; width: 0; height: 0" mi.style = "opacity: 0; width: 0; height: 0";
c.addEventListener("click", e => { c.addEventListener("click", (e) => {
mi.focus() mi.focus();
}) });
} }
}) });
// Capture the keypress // Capture the keypress
window.addEventListener("keypress", e => { window.addEventListener("keypress", (e) => {
e.preventDefault() e.preventDefault();
write(e.key) write(e.key);
}) });
window.addEventListener("keydown", e => { window.addEventListener("keydown", (e) => {
if (e.key == "Backspace") { if (e.key == "Backspace") {
e.preventDefault() e.preventDefault();
write("000backspace") write("000backspace");
} }
}) });
// Register custom ctrl shortcuts // Register custom ctrl shortcuts
customCtrlShortcuts("l") // ctrl + l customCtrlShortcuts("l"); // ctrl + l
customCtrlShortcuts("c") // ctrl + c customCtrlShortcuts("c"); // ctrl + c

View File

@@ -1,26 +1,24 @@
const burger = document.querySelector(".hamburger") const burger = document.querySelector(".hamburger");
const links = document.querySelector(".links") const links = document.querySelector(".links");
const body = document.querySelector("body") const body = document.querySelector("body");
const main = document.querySelector("main") const main = document.querySelector("main");
let shown = false let shown = false;
burger.addEventListener("click", (e) => { burger.addEventListener("click", (e) => {
e.preventDefault() e.preventDefault();
if (!shown) { if (!shown) {
links.style.display = "flex" links.style.display = "flex";
body.classList.add("disable-scroll") body.classList.add("disable-scroll");
burger.textContent = "x" burger.textContent = "x";
main.style.visibility = "hidden" main.style.visibility = "hidden";
} else { } else {
links.style.display = "none" links.style.display = "none";
body.classList.remove("disable-scroll") body.classList.remove("disable-scroll");
burger.textContent = "☰" burger.textContent = "☰";
main.style.visibility = "visible" main.style.visibility = "visible";
} }
shown = !shown shown = !shown;
}) });