Console fixed, hide about and projects page
All checks were successful
Build Zola Website / build (pull_request) Successful in 17s

This commit is contained in:
Filip Rojek 2023-12-18 03:27:31 +01:00
parent f168112294
commit d365dd4d25
3 changed files with 37 additions and 21 deletions

View File

@ -16,7 +16,7 @@ smart_punctuation = true
git = "https://git.filiprojek.cz/fr/website"
nav_items = [
{name="Home", path="/"},
{name="About", path="/about"},
{name="Projects", path="/projects/"},
#{name="About", path="/about"},
#{name="Projects", path="/projects/"},
]

View File

@ -1,53 +1,63 @@
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 = "";
let command = ""
function exec(command) {
console.log(command)
switch (command[0]) {
case "help":
line = "about<br>projects<br>contact<br>"
line = "help<br>author<br>contact<br>clear<br>echo"
break;
case "author":
line = "Filip Rojek, 2023"
break
case "contact":
line = "Filip Rojek &ltfilip@filiprojek.cz&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 = "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;
}
l = document.createElement("p").innerHTML = line
c.appendChild(l)
return line
}
function write(key) {
console.log("KEY:", key)
function write(key, payload) {
switch(key) {
case "Enter":
command = c.lastChild.textContent.replace(ps1, "")
command = command.split(" ");
exec(command)
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":
console.log(c.textContent.slice(0, -1))
console.log(ps1 == c.textContent)
if(c.lastChild.textContent.slice(0, -1) !== ps1.slice(0, -1)) {
c.lastChild.innerHTML = c.lastChild.textContent.slice(0, -1)
}
@ -55,7 +65,6 @@ function write(key) {
default:
c.lastChild.innerHTML += key
command += key
}
}
@ -70,7 +79,14 @@ function customCtrlShortcuts(plusKey) {
// On load init the terminal
window.addEventListener("load", () => {
write("000ctrll")
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
@ -89,4 +105,3 @@ window.addEventListener("keydown", e => {
// Register custom ctrl shortcuts
customCtrlShortcuts("l") // ctrl + l
customCtrlShortcuts("c") // ctrl + c

View File

@ -7,5 +7,6 @@
{% block content %}
<section class="console content" >
</section>
<textarea class="mobile-input" style="display: none" disabled autofocus></textarea>
<script src="/js/console.js" defer></script>
{% endblock content %}