diff --git a/httpdocs/public/js/terminal.js b/httpdocs/public/js/terminal.js index 9fbf392..8597835 100644 --- a/httpdocs/public/js/terminal.js +++ b/httpdocs/public/js/terminal.js @@ -41,7 +41,6 @@ async function sendCommand(e){ } } createNewTerminalLine(); - addInputEventListeners(); return; } catch { handleExecutionResponse({"response": "Invalid Argument"}) @@ -54,7 +53,6 @@ async function sendCommand(e){ line.remove(); }) createNewTerminalLine(); - addInputEventListeners(); return; } @@ -102,27 +100,26 @@ function deactivateAllStuff() { function handleExecutionResponse(response) { //Show Response + createNewTextLine(response.response); + + //create new terminal line. + createNewTerminalLine(); +} + + +function createNewTextLine(text){ let commandResponse = document.createElement("div") commandResponse.classList.add("terminalLine"); let textElement = document.createElement("span"); textElement.classList.add("responseText"); - textElement.innerHTML = response.response; + textElement.innerHTML = text; commandResponse.appendChild(textElement) terminalContainer.appendChild(commandResponse); - - - //create new terminal line. - createNewTerminalLine(); - - addInputEventListeners(); } - - - function createNewTerminalLine(){ let newTerminalLine = document.createElement("div"); newTerminalLine.classList.add("terminalLine"); @@ -164,6 +161,8 @@ function createNewTerminalLine(){ newTerminalLine.appendChild(blinky); terminalContainer.appendChild(newTerminalLine) + + addInputEventListeners(); }