mirror of
https://github.com/ION606/ion606.github.io.git
synced 2026-05-14 22:16:59 +00:00
added unecessarily good file system
This commit is contained in:
@@ -575,3 +575,77 @@ body.flicker {
|
|||||||
#virusMsg {
|
#virusMsg {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vi editor overlay styles */
|
||||||
|
.vi-editor-overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
background: rgba(20, 20, 30, 0.97);
|
||||||
|
z-index: 9999;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vi-editor-box {
|
||||||
|
background: #181825;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 4px 32px #000a;
|
||||||
|
padding: 2rem;
|
||||||
|
width: min(90vw, 600px);
|
||||||
|
max-width: 100vw;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vi-editor-title {
|
||||||
|
color: #7c3aed;
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vi-editor-textarea {
|
||||||
|
width: 100%;
|
||||||
|
height: 250px;
|
||||||
|
resize: vertical;
|
||||||
|
background: #232136;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 1rem;
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 1rem;
|
||||||
|
outline: none;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vi-editor-btnrow {
|
||||||
|
display: flex;
|
||||||
|
gap: 1rem;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vi-editor-savebtn {
|
||||||
|
background: #7c3aed;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
padding: 0.5rem 1.2rem;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-weight: bold;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vi-editor-cancelbtn {
|
||||||
|
background: #232136;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
padding: 0.5rem 1.2rem;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
+125
-2
@@ -138,6 +138,12 @@ class TerminalFS {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.files = {
|
this.files = {
|
||||||
|
"/home/guest": `
|
||||||
|
Welcome, Guest!
|
||||||
|
|
||||||
|
Feel free to explore our terminal. Enjoy the interactive experience, and don't hesitate to check out the projects and fun files.
|
||||||
|
Have a great time!
|
||||||
|
`,
|
||||||
"/home/ion606/todo.txt": `
|
"/home/ion606/todo.txt": `
|
||||||
1. Take over the world
|
1. Take over the world
|
||||||
2. Make coffee ☕
|
2. Make coffee ☕
|
||||||
@@ -375,6 +381,124 @@ Boot sequence: 🕺💃🪩
|
|||||||
<li><strong>run [file]</strong> - Run a file (e.g., .exe)</li>
|
<li><strong>run [file]</strong> - Run a file (e.g., .exe)</li>
|
||||||
</ul>`,
|
</ul>`,
|
||||||
|
|
||||||
|
mkdir: (dirName) => {
|
||||||
|
const newpath = this.resolvePath(dirName);
|
||||||
|
if (this.fs[newpath]) return `Directory exists!`;
|
||||||
|
|
||||||
|
this.fs[newpath] = {
|
||||||
|
type: "dir",
|
||||||
|
children: [],
|
||||||
|
}
|
||||||
|
|
||||||
|
return `Created ${dirName}`;
|
||||||
|
},
|
||||||
|
|
||||||
|
rm: (fname) => {
|
||||||
|
if (!fname) return "please provide a file/folder to remove";
|
||||||
|
|
||||||
|
const fpath = this.resolvePath(fname),
|
||||||
|
strplit = fpath.split('/').filter(Boolean),
|
||||||
|
dirName = strplit.length > 1 ? strplit.slice(0, -1).join('/') : `/${strplit[0]}`
|
||||||
|
|
||||||
|
if (!dirName) return `file or folder "${fpath}" not found!`
|
||||||
|
|
||||||
|
// dir
|
||||||
|
if (this.fs[fpath]) {
|
||||||
|
for (const file of this.fs[fpath]?.children) {
|
||||||
|
delete this.files[this.resolvePath(file)];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fpath != '/') {
|
||||||
|
const parentDir = fpath.substring(0, fpath.lastIndexOf('/') + 1);
|
||||||
|
|
||||||
|
if (this.fs[parentDir]) {
|
||||||
|
this.fs[parentDir].children = this.fs[parentDir].children.filter(f => f !== fname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete this.fs[dirName];
|
||||||
|
return "removing folder";
|
||||||
|
}
|
||||||
|
// file
|
||||||
|
else if (this.files[fpath]) {
|
||||||
|
this.fs[`/${dirName}`].children = this.fs[`/${dirName}`].children.filter(c => c !== fname);
|
||||||
|
delete this.files[fpath];
|
||||||
|
|
||||||
|
return "removing file";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return `File "${fpath}" not found!`;
|
||||||
|
},
|
||||||
|
|
||||||
|
vi: (fname) => {
|
||||||
|
const newpath = this.resolvePath(fname);
|
||||||
|
if (!this.fs[newpath]) {
|
||||||
|
let dirName = newpath.split('/').slice(0, -1).join('/') || "/";
|
||||||
|
|
||||||
|
if (!this.fs[dirName]) return `path "${dirName}" not found!`;
|
||||||
|
this.fs[dirName].children.push(fname);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create editor overlay
|
||||||
|
let editorOverlay = document.getElementById("vi-editor-overlay");
|
||||||
|
if (editorOverlay) editorOverlay.remove();
|
||||||
|
|
||||||
|
editorOverlay = document.createElement("div");
|
||||||
|
editorOverlay.id = "vi-editor-overlay";
|
||||||
|
editorOverlay.className = "vi-editor-overlay";
|
||||||
|
|
||||||
|
const editorBox = document.createElement("div");
|
||||||
|
editorBox.className = "vi-editor-box";
|
||||||
|
|
||||||
|
const title = document.createElement("div");
|
||||||
|
title.textContent = `vi — ${fname}`;
|
||||||
|
title.className = "vi-editor-title";
|
||||||
|
|
||||||
|
const textarea = document.createElement("textarea");
|
||||||
|
textarea.value = this.files[newpath] || "";
|
||||||
|
textarea.className = "vi-editor-textarea";
|
||||||
|
|
||||||
|
const btnRow = document.createElement("div");
|
||||||
|
btnRow.className = "vi-editor-btnrow";
|
||||||
|
|
||||||
|
const saveBtn = document.createElement("button");
|
||||||
|
saveBtn.textContent = "Save & Exit";
|
||||||
|
saveBtn.className = "vi-editor-savebtn";
|
||||||
|
saveBtn.onclick = () => {
|
||||||
|
this.files[newpath] = textarea.value;
|
||||||
|
document.body.removeChild(editorOverlay);
|
||||||
|
const consoleOutput = document.querySelector(".consoleout");
|
||||||
|
consoleOutput.innerHTML += `<div>Saved <b>${fname}</b>!</div>`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const cancelBtn = document.createElement("button");
|
||||||
|
cancelBtn.textContent = "Cancel";
|
||||||
|
cancelBtn.className = "vi-editor-cancelbtn";
|
||||||
|
cancelBtn.onclick = () => {
|
||||||
|
document.body.removeChild(editorOverlay);
|
||||||
|
};
|
||||||
|
|
||||||
|
btnRow.append(saveBtn, cancelBtn);
|
||||||
|
editorBox.append(title, textarea, btnRow);
|
||||||
|
editorOverlay.appendChild(editorBox);
|
||||||
|
document.body.appendChild(editorOverlay);
|
||||||
|
|
||||||
|
// Focus textarea
|
||||||
|
setTimeout(() => textarea.focus(), 100);
|
||||||
|
|
||||||
|
// ESC closes editor
|
||||||
|
const escListener = (e) => {
|
||||||
|
if (e.key === "Escape") {
|
||||||
|
cancelBtn.click();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
editorOverlay.addEventListener("keydown", escListener);
|
||||||
|
textarea.addEventListener("keydown", (e) => e.stopPropagation());
|
||||||
|
|
||||||
|
return `<span style="color:#7c3aed">Opened editor for <b>${fname}</b>. Press ESC or Cancel to exit.</span>`;
|
||||||
|
},
|
||||||
|
|
||||||
exit: devConsoleToggle,
|
exit: devConsoleToggle,
|
||||||
|
|
||||||
theme: (arg) => {
|
theme: (arg) => {
|
||||||
@@ -424,7 +548,7 @@ Boot sequence: 🕺💃🪩
|
|||||||
const colors = ["#ff4081", "#7c3aed", "#4f46e5", "#00ff88"];
|
const colors = ["#ff4081", "#7c3aed", "#4f46e5", "#00ff88"];
|
||||||
document.body.style.color =
|
document.body.style.color =
|
||||||
colors[Math.floor(Math.random() * colors.length)];
|
colors[Math.floor(Math.random() * colors.length)];
|
||||||
return "🌈 Color chaos activated!";
|
return "🌈 Color changed!";
|
||||||
},
|
},
|
||||||
|
|
||||||
secret: () => {
|
secret: () => {
|
||||||
@@ -434,7 +558,6 @@ Boot sequence: 🕺💃🪩
|
|||||||
|
|
||||||
run: (filePath) => {
|
run: (filePath) => {
|
||||||
const absPath = terminalFS.resolvePath(filePath.trim());
|
const absPath = terminalFS.resolvePath(filePath.trim());
|
||||||
console.log(absPath, filePath);
|
|
||||||
|
|
||||||
// Project links
|
// Project links
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user