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:
		
							
								
								
									
										78
									
								
								biome.json
									
									
									
									
									
								
							
							
						
						
									
										78
									
								
								biome.json
									
									
									
									
									
								
							@@ -1,41 +1,41 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "$schema": "https://biomejs.dev/schemas/2.2.2/schema.json",
 | 
						"$schema": "https://biomejs.dev/schemas/2.2.2/schema.json",
 | 
				
			||||||
  "vcs": {
 | 
						"vcs": {
 | 
				
			||||||
    "enabled": true,
 | 
							"enabled": true,
 | 
				
			||||||
    "clientKind": "git",
 | 
							"clientKind": "git",
 | 
				
			||||||
    "useIgnoreFile": true
 | 
							"useIgnoreFile": true
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
  "files": {
 | 
						"files": {
 | 
				
			||||||
    "includes": ["**", "!public", "!content", "!templates", "!static/img", "!**/*.min.js"]
 | 
							"includes": ["**", "!public", "!content", "!templates", "!static/img", "!**/*.min.js"]
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
  "formatter": {
 | 
						"formatter": {
 | 
				
			||||||
    "enabled": true
 | 
							"enabled": true
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
  "linter": {
 | 
						"linter": {
 | 
				
			||||||
    "enabled": true,
 | 
							"enabled": true,
 | 
				
			||||||
    "rules": {
 | 
							"rules": {
 | 
				
			||||||
      "recommended": true
 | 
								"recommended": true
 | 
				
			||||||
    }
 | 
							}
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
  "javascript": {
 | 
						"javascript": {
 | 
				
			||||||
    "formatter": {
 | 
							"formatter": {
 | 
				
			||||||
      "lineWidth": 100,
 | 
								"lineWidth": 100,
 | 
				
			||||||
      "quoteStyle": "double",
 | 
								"quoteStyle": "double",
 | 
				
			||||||
      "jsxQuoteStyle": "double",
 | 
								"jsxQuoteStyle": "double",
 | 
				
			||||||
      "trailingCommas": "all",
 | 
								"trailingCommas": "all",
 | 
				
			||||||
      "semicolons": "always"
 | 
								"semicolons": "always"
 | 
				
			||||||
    }
 | 
							}
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
  "json": {
 | 
						"json": {
 | 
				
			||||||
    "formatter": {
 | 
							"formatter": {
 | 
				
			||||||
      "lineWidth": 100
 | 
								"lineWidth": 100
 | 
				
			||||||
    }
 | 
							}
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
  "css": {
 | 
						"css": {
 | 
				
			||||||
    "formatter": {
 | 
							"formatter": {
 | 
				
			||||||
      "enabled": true,
 | 
								"enabled": true,
 | 
				
			||||||
      "lineWidth": 100,
 | 
								"lineWidth": 100,
 | 
				
			||||||
      "quoteStyle": "single"
 | 
								"quoteStyle": "single"
 | 
				
			||||||
    }
 | 
							}
 | 
				
			||||||
  }
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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 = ""
 | 
							textContent += child.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);
 | 
					 | 
				
			||||||
  })
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						elWrapper.addEventListener("click", (e) => {
 | 
				
			||||||
 | 
							e.preventDefault();
 | 
				
			||||||
 | 
							navigator.clipboard.writeText(textContent);
 | 
				
			||||||
 | 
							el.textContent = "Copied!";
 | 
				
			||||||
 | 
							setTimeout(() => {
 | 
				
			||||||
 | 
								el.textContent = "Copy";
 | 
				
			||||||
 | 
							}, 5000);
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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 <<a href='mailto: filip@filiprojek.cz'>filip@filiprojek.cz</a>><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 <<a href='mailto: filip@filiprojek.cz'>filip@filiprojek.cz</a>><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>";
 | 
				
			||||||
    case "clear":
 | 
								break;
 | 
				
			||||||
      write("000ctrll")
 | 
							case "clear":
 | 
				
			||||||
      return false
 | 
								write("000ctrll");
 | 
				
			||||||
    case "echo":
 | 
								return false;
 | 
				
			||||||
      line = ""
 | 
							case "echo":
 | 
				
			||||||
      command.forEach((cmd, i) => {
 | 
								line = "";
 | 
				
			||||||
        if (i === 0) return
 | 
								command.forEach((cmd, i) => {
 | 
				
			||||||
        line += cmd + " "
 | 
									if (i === 0) return;
 | 
				
			||||||
      });
 | 
									line += cmd + " ";
 | 
				
			||||||
      line = line.substring(0, line.length - 1) // remove last space
 | 
								});
 | 
				
			||||||
      break
 | 
								line = line.substring(0, line.length - 1); // remove last space
 | 
				
			||||||
    default:
 | 
								break;
 | 
				
			||||||
      line = "frsh: " + command[0] + ": command not found"
 | 
							default:
 | 
				
			||||||
      break;
 | 
								line = "frsh: " + command[0] + ": command not found";
 | 
				
			||||||
  }
 | 
								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 = ""
 | 
								command = "";
 | 
				
			||||||
      break
 | 
								break;
 | 
				
			||||||
    case "000ctrll":
 | 
							}
 | 
				
			||||||
      c.innerHTML = ""
 | 
							case "000ctrll":
 | 
				
			||||||
      if(payload == motd) c.innerHTML = motd
 | 
								c.innerHTML = "";
 | 
				
			||||||
      line = document.createElement("p")
 | 
								if (payload == motd) c.innerHTML = motd;
 | 
				
			||||||
      line.innerHTML += ps1
 | 
								line = document.createElement("p");
 | 
				
			||||||
      c.appendChild(line)
 | 
								line.innerHTML += ps1;
 | 
				
			||||||
      break
 | 
								c.appendChild(line);
 | 
				
			||||||
    case "000backspace":
 | 
								break;
 | 
				
			||||||
      if(c.lastChild.textContent.slice(0, -1) !== ps1.slice(0, -1)) {
 | 
							case "000backspace":
 | 
				
			||||||
        c.lastChild.innerHTML = c.lastChild.textContent.slice(0, -1)
 | 
								if (c.lastChild.textContent.slice(0, -1) !== ps1.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
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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) {
 | 
					 | 
				
			||||||
    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
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						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;
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user