From 2714479c98da8f33e8687a3c4d3d5f0431113f1c Mon Sep 17 00:00:00 2001 From: minie4 Date: Tue, 27 Apr 2021 15:32:11 +0200 Subject: [PATCH] Refactored the javascript code --- index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 9598aae..dfd34e1 100644 --- a/index.js +++ b/index.js @@ -14,7 +14,7 @@ const username = "root"; const welcomecmd = 'screen -d -m sh -c "sh /dev/console 2>&1;read";TERM="xterm-256color";stty sane;/etc/init.d/S99welcome'; document.addEventListener("DOMContentLoaded", () => { - // Debug + // Show the internal screen if "#debug" is appended to the url var v86_display = undefined; if(window.location.hash == "#debug") { document.getElementById("screen").classList.add("visible"); @@ -44,10 +44,12 @@ document.addEventListener("DOMContentLoaded", () => { }); termcontainer = document.getElementById('terminal'); term.open(termcontainer); - // Fit xterm to the size of the container + + // Initialize the xterm-fit addon termfit = new FitAddon.FitAddon(); term.loadAddon(termfit); - termfit.fit() + termfit.fit(); + // Write a "Booting WebTerm ..." message term.write('\033[1;34mDownloading\033[0m OS images ...\r\n') @@ -80,7 +82,7 @@ function onConsoleOutput(char) { var debugcnt = 0; var debugword = "+++debug+++" function onConsoleInput(key) { - // If key is Strg+V + // Paste (Strg+Alt+V) if((key.domEvent.key == "v") && key.domEvent.altKey && key.domEvent.ctrlKey) { debug("paste") navigator.clipboard.readText().then((text) => { @@ -89,6 +91,7 @@ function onConsoleInput(key) { return; } + // Copy (Strg+Alt+C) if((key.domEvent.key == "c") && key.domEvent.altKey && key.domEvent.ctrlKey) { debug("copy") document.execCommand("copy")