zektyc/public/js/portfolio.js

369 lines
No EOL
14 KiB
JavaScript

(function () {
"use strict";
var FR = /^\/en(\/|$)/.test(location.pathname) ? false : true;
var T = {
boot: FR
? ["Debian GNU/Linux 12 (bookworm) tty1", "zektyc login: dotriric", "Password: ********", "Last login: a l'instant depuis votre navigateur", "Bienvenue sur le terminal de presentation de Riric.", "Tapez 'help' pour la liste des commandes."]
: ["Debian GNU/Linux 12 (bookworm) tty1", "zektyc login: dotriric", "Password: ********", "Last login: right now from your browser", "Welcome to Riric's presentation terminal.", "Type 'help' for the list of commands."],
promptUser: "dotriric",
promptHost: "zektyc",
unknown: function (c) { return FR ? ("bash: " + c + " : commande introuvable") : ("bash: " + c + ": command not found"); },
helpLines: FR
? [
"Commandes disponibles :",
"",
" help affiche cette aide",
" whoami qui suis-je",
" cat about.txt mon profil",
" cat projects.txt mes projets",
" neofetch infos systeme + profil",
" ls, pwd, date, hostname, uname -a",
" contact le meilleur moyen de me joindre",
" clear efface l'ecran",
" exit quitter le terminal",
"",
"Astuce : essayez aussi 'sudo' ou 'apt update'.",
]
: [
"Available commands:",
"",
" help show this help",
" whoami who am I",
" cat about.txt my profile",
" cat projects.txt my projects",
" neofetch system info + profile",
" ls, pwd, date, hostname, uname -a",
" contact best way to reach me",
" clear clear the screen",
" exit quit the terminal",
"",
"Tip: try 'sudo' or 'apt update' too.",
],
neofetch: FR
? [
" .---. dotriric@zektyc",
" / \\ ----------------",
" \\ / OS: Debian GNU/Linux 12 (bookworm)",
" '---' Host: Zektyc, sheberge en France",
" Shell: zeke 1.0",
" Roles: CEO · Fondateur · Architecte",
" Le site web tourne derriere nginx + Caddy + Bun.",
]
: [
" .---. dotriric@zektyc",
" / \\ ----------------",
" \\ / OS: Debian GNU/Linux 12 (bookworm)",
" '---' Host: Zektyc, hosted in France",
" Shell: zeke 1.0",
" Roles: CEO · Founder · Architect",
" The website runs behind nginx + Caddy + Bun.",
],
about: FR
? [
"Riric (alias DotRiric) — fondateur de Zektyc.",
"",
"CEO · Fondateur · Architecte",
"",
"Vision, direction technique, architecture, design, securite.",
"Riric construit Zektyc de A a Z — du serveur au premier pixel.",
"",
"Une personne reelle derriere chaque service : pas de promesses vagues,",
"du concret, de la transparence, et un vrai travail d'infrastructure.",
"",
"Avec OpenCode, programmeur, il ecrit et maintient le code source",
"de Zektyc — du serveur Bun aux pages statiques.",
]
: [
"Riric (a.k.a. DotRiric) — founder of Zektyc.",
"",
"CEO · Founder · Architect",
"",
"Vision, technical direction, architecture, design, security.",
"Riric builds Zektyc from A to Z — from the server to the first pixel.",
"",
"A real person behind every service: no vague promises, concrete work,",
"transparency, and real infrastructure engineering.",
"",
"With OpenCode, programmer, he writes and maintains Zektyc's",
"source code — from the Bun server to static pages.",
],
projects: FR
? [
"Projets actuels :",
"",
" /fingerprint-test Test de fingerprinting navigateur (local, rien n'est envoye).",
" /zmap/ ZMap — calculateur de vitesses maximales (donnees Europe).",
" /zenyth/ Zenyth — navigateur de confiance.",
" /projets/ Tous les projets et contributions.",
"",
"Vous pouvez ouvrir ces liens en cliquant dessus.",
]
: [
"Current projects:",
"",
" /fingerprint-test Browser fingerprinting test (local, nothing is sent).",
" /zmap/ ZMap — max speed calculator (Europe data).",
" /zenyth/ Zenyth — a browser you can trust.",
" /projets/ All projects and contributions.",
"",
"You can open these links by clicking on them.",
],
contact: FR
? ["Email: riric65@protonmail.com", "Mastodon: @zektyc@piaille.fr", "Repond generalement en francais ou en anglais."]
: ["Email: riric65@protonmail.com", "Mastodon: @zektyc@piaille.fr", "Usually replies in French or English."],
bashrc: FR ? ["# Config bash de dotriric", 'export PS1="dotriric@zektyc:~$ "', "alias ll='ls -alF'", "# Je n'aime pas le sucre."] : ["# dotriric's bash config", 'export PS1="dotriric@zektyc:~$ "', "alias ll='ls -alF'", "# I don't like sugar."],
profile: FR ? ["# .profile — charge le bashrc", "source ~/.bashrc", "# Bienvenue."] : ["# .profile — loads bashrc", "source ~/.bashrc", "# Welcome."],
sudo: FR ? ["dotriric n'est pas dans le fichier sudoers. Cet incident sera signale."] : ["dotriric is not in the sudoers file. This incident will be reported."],
apt: FR ? ["Lecture des listes de paquets... Termine.", "Construction de l'arbre des dependances... Termine.", "0 paquet(s) mis a niveau."] : ["Reading package lists... Done.", "Building dependency tree... Done.", "0 packages can be upgraded."],
shutdown: FR ? ["connexion fermee.", "terminal de presentation quitte — la page reste, evidemment. :)"] : ["connection closed.", "presentation terminal exited — the page stays, of course. :)"],
};
var root = document.getElementById("terminal");
if (!root) return;
var body = root.querySelector(".terminal-body");
var history = [];
var histIdx = -1;
var locked = false;
function makeLink(text, href) {
var a = document.createElement("a");
a.href = href;
a.textContent = text;
return a;
}
function makeRich(lines) {
var frag = document.createDocumentFragment();
var i;
for (i = 0; i < lines.length; i++) {
var item = lines[i];
var div = document.createElement("div");
div.className = "terminal-line";
if (item && item.color) div.classList.add(item.color);
if (item && typeof item.link === "string") {
div.appendChild(makeLink(item.text, item.link));
} else if (item && typeof item === "object") {
div.textContent = item.text || "";
} else {
div.textContent = item;
}
frag.appendChild(div);
}
return frag;
}
function print(lines) {
if (typeof lines === "string") lines = [lines];
body.appendChild(makeRich(lines));
scrollDown();
}
function printAscii(lines) {
var div = document.createElement("div");
div.className = "term-ascii";
div.textContent = (typeof lines === "string" ? lines : lines.join("\n"));
body.appendChild(div);
scrollDown();
}
function scrollDown() {
body.scrollTop = body.scrollHeight;
}
function promptEl() {
var p = document.createElement("span");
p.className = "term-prompt";
var sp = document.createElement("span");
sp.className = "t-user";
sp.textContent = T.promptUser + "@" + T.promptHost;
var ct = document.createElement("span");
ct.className = "t-path";
ct.textContent = ":~$ ";
p.appendChild(sp);
p.appendChild(ct);
return p;
}
function currentPrompt() {
return body.querySelector(".prompt-line");
}
function newPrompt() {
var line = document.createElement("div");
line.className = "terminal-line prompt-line term-line-input";
line.appendChild(promptEl());
var inp = document.createElement("input");
inp.type = "text";
inp.className = "term-input";
inp.setAttribute("autocomplete", "off");
inp.setAttribute("autocapitalize", "off");
inp.setAttribute("spellcheck", "false");
inp.setAttribute("aria-label", FR ? "Commande" : "Command");
line.appendChild(inp);
body.appendChild(line);
bindInput(inp);
scrollDown();
return inp;
}
function bindInput(inp) {
inp.addEventListener("keydown", function (e) {
if (e.key === "Enter") {
e.preventDefault();
submit(inp);
} else if (e.key === "ArrowUp") {
e.preventDefault();
if (history.length) {
histIdx = Math.max(0, histIdx - 1);
inp.value = history[histIdx] || "";
}
} else if (e.key === "ArrowDown") {
e.preventDefault();
if (history.length) {
histIdx = Math.min(history.length, histIdx + 1);
inp.value = histIdx >= history.length ? "" : history[histIdx];
}
}
});
inp.addEventListener("input", scrollDown);
}
function submit(inp) {
var raw = inp.value;
var line = inp.closest(".prompt-line");
var txt = document.createElement("span");
txt.textContent = raw;
inp.replaceWith(txt);
if (raw.trim()) history.push(raw);
histIdx = history.length;
var cmd = raw.trim();
if (cmd === "clear" || cmd === "cls") {
body.innerHTML = "";
newPrompt().focus();
return;
}
if (cmd) runCommand(cmd);
if (locked) return;
newPrompt().focus();
scrollDown();
}
function runCommand(cmd) {
var parts = cmd.split(/[ \t]+/);
var c = parts[0].toLowerCase();
var arg = parts.slice(1).join(" ");
switch (true) {
case c === "help" || c === "h" || c === "?":
print(T.helpLines);
break;
case c === "whoami":
print("dotriric");
break;
case c === "id":
print("uid=1000(dotriric) gid=1000(dotriric) groupes=1000(dotriric)");
break;
case c === "pwd":
print("/home/dotriric");
break;
case c === "hostname":
print(T.promptHost);
break;
case c === "ls" || c === "ll" || c === "dir":
if (arg === "-la" || arg === "-al" || c === "ll") {
print(["total 24", "drwxr-xr-x dotriric dotriric dots .", "drwxr-xr-x root root dots ..", "-rw-r--r-- dotriric dotriric dots .bashrc", "-rw-r--r-- dotriric dotriric dots .profile", "-rw-r--r-- dotriric dotriric dots about.txt", "-rw-r--r-- dotriric dotriric dots projects.txt", "-rw-r--r-- dotriric dotriric dots contact.txt"]);
} else {
print(["about.txt projects.txt contact.txt .bashrc .profile"]);
}
break;
case c === "uname":
print("Linux zektyc 6.1.0 localhost x86_64 GNU/Linux");
break;
case c === "date":
print(new Date().toUTCString().replace("GMT", "UTC"));
break;
case c === "neofetch" || c === "fetch":
printAscii(T.neofetch);
break;
case c === "about" || c === "profil" || c === "profile":
print(T.about);
break;
case c === "cat":
switch (true) {
case arg.indexOf("about") !== -1:
print(T.about);
break;
case arg.indexOf("project") !== -1:
print(T.projects.map(function (l) {
var m = l.match(/^\s*(\/[a-z-]+\/?\s*)\s(.*)$/);
if (m) return { text: m[1] + " " + m[2], link: m[1].trim() };
return l;
}));
break;
case arg.indexOf("contact") !== -1:
print(T.contact);
break;
case arg.indexOf("bashrc") !== -1:
print(T.bashrc);
break;
case arg.indexOf("profile") !== -1:
print(T.profile);
break;
default:
print(FR ? "cat: " + (arg || "?") + ": fichier introuvable" : "cat: " + (arg || "?") + ": No such file or directory");
}
break;
case c === "contact" || c === "email" || c === "mail":
print(T.contact.map(function (l) {
var m = l.match(/^([A-Za-z]+:)\s*(\S+)$/);
if (m && m[1] === "Email:") return { text: l, link: "mailto:" + m[2] };
if (m && m[1] === "Mastodon:") return { text: l, link: "https://piaille.fr/@zektyc" };
return l;
}));
break;
case c === "sudo" || c === "su":
print(T.sudo);
break;
case c === "apt":
print(T.apt);
break;
case c === "exit" || c === "logout" || c === "quit":
print(T.shutdown);
locked = true;
break;
case c === "echo":
print(arg || "");
break;
case c === "history":
print(history.length ? history : [FR ? "(aucune commande)" : "(no commands)"]);
break;
default:
print(T.unknown(c));
}
}
root.addEventListener("click", function () {
var ln = currentPrompt();
if (ln) {
var inp = ln.querySelector(".term-input");
if (inp && !inp.disabled) inp.focus();
}
});
(function boot() {
printAscii(["", T.boot.join("\n"), ""]);
var inp = newPrompt();
setTimeout(function () {
inp.focus();
}, 50);
})();
})();