diff --git a/css/main.css b/css/main.css index da522b1..9de7471 100644 --- a/css/main.css +++ b/css/main.css @@ -2,7 +2,6 @@ body { background-color: black; font-family: 'Lucida Console'; font-size: large; - /* white-space: pre; */ } #cursor { diff --git a/js/main.js b/js/main.js index 5d570c1..f1ffeab 100644 --- a/js/main.js +++ b/js/main.js @@ -8,15 +8,15 @@ document.addEventListener("keypress", e=>{ return; let textbox = document.getElementById("input"); const index = cursorPosition - startPosition; - if (e.key == ' ' && (textbox.innerText[index-1] == ' ' || cursorPosition == startPosition)) + if (e.key == ' ' && (textbox.textContent[index-1] == ' ' || cursorPosition == startPosition)) return; - if (index <= textbox.innerText.length-1) { - const text = textbox.innerText; + if (index <= textbox.textContent.length-1) { + const text = textbox.textContent; const a = text.substring(0, index); const b = text.substring(index, text.length); - textbox.innerText = a + e.key + b; + textbox.textContent = a + e.key + b; } else - textbox.innerText += e.key; + textbox.textContent += e.key; cursorPosition++; updateCursor(); }); @@ -24,18 +24,18 @@ document.addEventListener("keypress", e=>{ document.addEventListener("keydown", e=>{ let textbox = document.getElementById("input"); const index = cursorPosition - startPosition; - const text = textbox.innerText; + const text = textbox.textContent; switch (e.key) { case "Backspace": // Ein Zeichen nach links löschen if (index == 0) return; - if (index <= textbox.innerText.length-1) { + if (index <= textbox.textContent.length-1) { const a = text.substring(0, index-1); const b = text.substring(index, text.length); - textbox.innerText=a+b; + textbox.textContent=a+b; } else - textbox.innerText = text.substring(0,text.length-1); + textbox.textContent = text.substring(0,text.length-1); cursorPosition--; updateCursor(); break; @@ -48,18 +48,18 @@ document.addEventListener("keydown", e=>{ break; case "ArrowRight": // Ein Zeichen nach reckts - if (index < textbox.innerText.length) { + if (index < textbox.textContent.length) { cursorPosition++; updateCursor(); } break; case "Delete": // Ein Zeichen nach rechts löschen - if (index == 0 || index >= textbox.innerText.length) + if (index == 0 || index >= textbox.textContent.length) return; const a = text.substring(0, index); const b = text.substring(index+1, text.length); - textbox.innerText=a+b; + textbox.textContent=a+b; break; case "Enter": // Befehl absenden / Zeilenumbruch @@ -70,7 +70,7 @@ document.addEventListener("keydown", e=>{ const commandOutput = ""; parent.innerHTML += '' + text + '
' + commandOutput + pretext; - textbox.innerText = ""; + textbox.textContent = ""; parent.appendChild(textbox); cursorPosition = startPosition; cursorYOffset++;