diff --git a/css/main.css b/css/main.css index 9091a23..3ac9219 100644 --- a/css/main.css +++ b/css/main.css @@ -26,6 +26,7 @@ body { #current { color: lightgrey; + white-space: pre; } #asciiArt { diff --git a/js/commands.js b/js/commands.js index 917a9dc..fa425e1 100644 --- a/js/commands.js +++ b/js/commands.js @@ -20,7 +20,15 @@ function cmd_clear() { } function cmd_history() { - return ""; + let output = ""; + + const hl = history.list; + for (let i = 0; i < hl.length; i++) { + const lineBreak = (i !== hl.length - 1) ? "
" : ""; + output += `${i+1} ${hl[i]}${lineBreak}`; + } + + return output; } function cmd_exec(input) { diff --git a/js/main.js b/js/main.js index 4698dd7..c301ac4 100644 --- a/js/main.js +++ b/js/main.js @@ -92,7 +92,6 @@ document.addEventListener("keydown", e => { if (text !== "" || inputSet.has(" ") && inputSet.size === 1) { history.list.push(text); history.index = history.list.length; - console.log(history); } // Fix current input to page @@ -151,14 +150,13 @@ document.addEventListener("keydown", e => { function createText(str, safe=true) { const link = document.createElement("a"); link.style.color = "lightgrey"; + link.style.whiteSpace = "pre"; // No "HTML injection" if (safe) link.textContent = str; // "Anything goes" and keep formatting - else { - link.style.whiteSpace = "pre"; + else link.innerHTML = str; - } return link; }