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,41 +1,41 @@
{
"$schema": "https://biomejs.dev/schemas/2.2.2/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"includes": ["**", "!public", "!content", "!templates", "!static/img", "!**/*.min.js"]
},
"formatter": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"lineWidth": 100,
"quoteStyle": "double",
"jsxQuoteStyle": "double",
"trailingCommas": "all",
"semicolons": "always"
}
},
"json": {
"formatter": {
"lineWidth": 100
}
},
"css": {
"formatter": {
"enabled": true,
"lineWidth": 100,
"quoteStyle": "single"
}
}
"$schema": "https://biomejs.dev/schemas/2.2.2/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"includes": ["**", "!public", "!content", "!templates", "!static/img", "!**/*.min.js"]
},
"formatter": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"lineWidth": 100,
"quoteStyle": "double",
"jsxQuoteStyle": "double",
"trailingCommas": "all",
"semicolons": "always"
}
},
"json": {
"formatter": {
"lineWidth": 100
}
},
"css": {
"formatter": {
"enabled": true,
"lineWidth": 100,
"quoteStyle": "single"
}
}
}

View File

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

View File

@@ -1,107 +1,109 @@
const c = document.querySelector(".console")
const ps1 = "[fr@website ~]$ "
const motd = "Welcome to my website!<br>You can use `help` for more informations :)"
const c = document.querySelector(".console");
const ps1 = "[fr@website ~]$ ";
const motd = "Welcome to my website!<br>You can use `help` for more informations :)";
let line = "";
function exec(command) {
switch (command[0]) {
case "help":
line = "help<br>author<br>contact<br>clear<br>echo"
break;
case "author":
line = "Filip Rojek, 2023"
break
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>"
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;
}
switch (command[0]) {
case "help":
line = "help<br>author<br>contact<br>clear<br>echo";
break;
case "author":
line = "Filip Rojek, 2023";
break;
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>";
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
return line;
}
function write(key, payload) {
switch(key) {
case "Enter":
command = c.lastChild.textContent.replace(ps1, "")
command = command.split(" ");
let out = exec(command)
if(out !== false) {
line = document.createElement("p")
line.innerHTML += out
line.innerHTML += "<br>"
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
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 += "<br>";
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
}
default:
c.lastChild.innerHTML += key;
}
}
function customCtrlShortcuts(plusKey) {
document.addEventListener("keydown", e => {
if(e.ctrlKey && e.key == plusKey) {
e.preventDefault()
write("000ctrl"+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()
})
}
})
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("keypress", (e) => {
e.preventDefault();
write(e.key);
});
window.addEventListener("keydown", e => {
if(e.key == "Backspace") {
e.preventDefault()
write("000backspace")
}
})
window.addEventListener("keydown", (e) => {
if (e.key == "Backspace") {
e.preventDefault();
write("000backspace");
}
});
// Register custom ctrl shortcuts
customCtrlShortcuts("l") // ctrl + l
customCtrlShortcuts("c") // ctrl + c
customCtrlShortcuts("l"); // ctrl + l
customCtrlShortcuts("c"); // ctrl + c

View File

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