diff --git a/index.html b/index.html index 4694f16..1abda24 100644 --- a/index.html +++ b/index.html @@ -27,6 +27,7 @@ font-family: monospace; font-size: 16px; caret-color: white; + width: 100%; } Linux Emulator @@ -38,7 +39,6 @@ const terminal = document.getElementById('terminal'); const inputElement = document.createElement('input'); inputElement.setAttribute('type', 'text'); - inputElement.style.width = '100%'; terminal.appendChild(inputElement); let commandHistory = []; @@ -49,6 +49,7 @@ event.preventDefault(); const command = inputElement.value.trim(); if (command !== '') { + displayInput(command); handleCommand(command); commandHistory.unshift(command); historyIndex = -1; @@ -69,40 +70,6 @@ } }); - const localStorageKey = 'linux_emulator_fs'; - let fileSystem = JSON.parse(localStorage.getItem(localStorageKey)) || { - '/': { - type: 'directory', - contents: { - home: { - type: 'directory', - contents: { - user: { - type: 'directory', - contents: { - file1: { type: 'file', content: 'Content of file1' }, - file2: { type: 'file', content: 'Content of file2' }, - script.sh: { type: 'file', content: 'echo "Shell script output"' }, - }, - }, - }, - }, - bin: { - type: 'directory', - contents: { - echo: { type: 'executable', execute: echoCommand }, - ls: { type: 'executable', execute: lsCommand }, - cat: { type: 'executable', execute: catCommand }, - runscript: { type: 'executable', execute: runScriptCommand }, - touch: { type: 'executable', execute: touchCommand }, - write: { type: 'executable', execute: writeCommand }, - exit: { type: 'executable', execute: exitCommand }, - }, - }, - }, - }, - }; - function handleCommand(command) { const [cmd, ...args] = command.split(' '); switch (cmd.toLowerCase()) { @@ -205,10 +172,18 @@ currentDirectory = directory; } + function displayInput(command) { + const inputElement = document.createElement('div'); + inputElement.className = 'input'; + inputElement.textContent = '$ ' + command; + terminal.appendChild(inputElement); + } + function displayOutput(output) { const outputElement = document.createElement('div'); + outputElement.className = 'output'; outputElement.textContent = output; - terminal.insertBefore(outputElement, inputElement); + terminal.appendChild(outputElement); } function echoCommand(args) {