terminal features

This commit is contained in:
Dominic DiTaranto 2026-01-02 10:51:41 -05:00
parent 8b0a0ed271
commit eacc1db61a
2 changed files with 41 additions and 13 deletions

View file

@ -32,7 +32,7 @@ class Terminal {
}) })
} }
hide () { hide() {
this.terminalElem.style.display = "none" this.terminalElem.style.display = "none"
this.terminalContainerElem.style.display = "none" this.terminalContainerElem.style.display = "none"
terminalMode = false; terminalMode = false;
@ -59,7 +59,7 @@ class Terminal {
prompt.addEventListener("keypress", function(event) { prompt.addEventListener("keypress", function(event) {
if (event.key === "Enter") { if (event.key === "Enter") {
if (terminalMode && this.value !== ''){ if (terminalMode && this.value !== '') {
event.preventDefault(); event.preventDefault();
this.disabled = true; this.disabled = true;
self.handlePrompt(this.value); self.handlePrompt(this.value);
@ -102,12 +102,17 @@ class Terminal {
if (promptText === 'help') { if (promptText === 'help') {
returnText = `Documented Commands:<br> returnText = `Documented Commands:<br>
========================================<br> ========================================<br>
help &nbsp&nbsp&nbsp&nbspShows the help screen<br> help &nbsp&nbsp&nbsp&nbsp&nbspShows the help screen<br>
about &nbsp&nbsp&nbspProvides background of the terminal<br> about &nbsp&nbsp&nbsp&nbspProvides background of the terminal<br>
clear &nbsp&nbsp&nbspClears the terminal<br> clear &nbsp&nbsp&nbsp&nbspClears the terminal<br>
echo &nbsp&nbsp&nbsp&nbspDisplay a line of text<br> echo &nbsp&nbsp&nbsp&nbsp&nbspDisplay a line of text<br>
exit &nbsp&nbsp&nbsp&nbspExits the terminal<br> exit &nbsp&nbsp&nbsp&nbsp&nbspExits the terminal<br>
history &nbspPrints command history<br> history &nbsp&nbspPrints command history<br>
resume &nbsp&nbsp&nbspDisplays Resume<br>
portfolio Displays Portfolio<br>
games &nbsp&nbsp&nbsp&nbspDisplays Games<br>
music &nbsp&nbsp&nbsp&nbspDisplays Music<br>
contact &nbsp&nbspDisplays Contact Info<br>
<br> <br>
Terminal Functionality:<br> Terminal Functionality:<br>
========================================<br> ========================================<br>
@ -121,9 +126,29 @@ class Terminal {
promptText = promptText.replaceAll('"', '') promptText = promptText.replaceAll('"', '')
promptText = promptText.split(' ').slice(1) promptText = promptText.split(' ').slice(1)
returnText = promptText.join(' ') returnText = promptText.join(' ')
} else if (promptText == 'portfolio') {
portfolio.show(true)
returnText = 'Loading Portfolio...'
} else if (promptText == 'resume') {
resume.show(true)
returnText = 'Loading Resume...'
} else if (promptText == 'music') {
music.show(true)
returnText = 'Loading Music...'
} else if (promptText == 'games') {
games.show(true)
returnText = 'Loading Games...'
} else if (promptText == 'contact') {
returnText = 'EMAIL: me@domdit.com<br>XMPP: domdit@xmpp.jp'
} else if (promptText === 'history') { } else if (promptText === 'history') {
returnText = this.commands.join('<br>') returnText = this.commands.join('<br>')
} else if (promptText == 'exit') { } else if (promptText == 'exit') {
this.hide() this.hide()
@ -157,7 +182,7 @@ class Terminal {
getKeystroke() { getKeystroke() {
var self = this var self = this
_listener = function (event) { _listener = function(event) {
if ( if (
["ArrowUp", "ArrowDown", "ControlLeft"].indexOf(event.code,) > -1 ["ArrowUp", "ArrowDown", "ControlLeft"].indexOf(event.code,) > -1
) { ) {

View file

@ -4,13 +4,16 @@ class Window {
this.innerContainer = document.getElementById(id) this.innerContainer = document.getElementById(id)
} }
show() { show(fromTerminal=false) {
this.resize() this.resize()
this.container.style.display = 'block' this.container.style.display = 'block'
var self = this; var self = this;
document.addEventListener('keydown', function(event) { document.addEventListener('keydown', function(event) {
if (event.key === 'Escape') { if (event.key === 'Escape') {
self.hide() self.hide()
if (fromTerminal) {
terminal.show()
}
} }
}) })
} }