From eacc1db61a988efa19f814c0adfa69b9b78fdacc Mon Sep 17 00:00:00 2001 From: Dominic DiTaranto Date: Fri, 2 Jan 2026 10:51:41 -0500 Subject: [PATCH] terminal features --- assets/js/terminal.js | 49 ++++++++++++++++++++++++++++++++----------- assets/js/window.js | 5 ++++- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/assets/js/terminal.js b/assets/js/terminal.js index cb6ef29..fa2510b 100644 --- a/assets/js/terminal.js +++ b/assets/js/terminal.js @@ -31,8 +31,8 @@ class Terminal { } }) } - - hide () { + + hide() { this.terminalElem.style.display = "none" this.terminalContainerElem.style.display = "none" terminalMode = false; @@ -59,7 +59,7 @@ class Terminal { prompt.addEventListener("keypress", function(event) { if (event.key === "Enter") { - if (terminalMode && this.value !== ''){ + if (terminalMode && this.value !== '') { event.preventDefault(); this.disabled = true; self.handlePrompt(this.value); @@ -102,12 +102,17 @@ class Terminal { if (promptText === 'help') { returnText = `Documented Commands:
========================================
- help     Shows the help screen
- about    Provides background of the terminal
- clear    Clears the terminal
- echo     Display a line of text
- exit     Exits the terminal
- history  Prints command history
+ help      Shows the help screen
+ about     Provides background of the terminal
+ clear     Clears the terminal
+ echo      Display a line of text
+ exit      Exits the terminal
+ history   Prints command history
+ resume    Displays Resume
+ portfolio Displays Portfolio
+ games     Displays Games
+ music     Displays Music
+ contact   Displays Contact Info

Terminal Functionality:
========================================
@@ -121,9 +126,29 @@ class Terminal { promptText = promptText.replaceAll('"', '') promptText = promptText.split(' ').slice(1) 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
XMPP: domdit@xmpp.jp' + } else if (promptText === 'history') { - returnText = this.commands.join('
') + returnText = this.commands.join('
') } else if (promptText == 'exit') { this.hide() @@ -157,7 +182,7 @@ class Terminal { getKeystroke() { var self = this - _listener = function (event) { + _listener = function(event) { if ( ["ArrowUp", "ArrowDown", "ControlLeft"].indexOf(event.code,) > -1 ) { @@ -167,7 +192,7 @@ class Terminal { if (event.ctrlKey && event.key === 'd') { event.preventDefault(); } - + if (event.key === "ArrowUp") { if (self.commands.length > 0) { var nextCommandPosition = self.commandPosition - 1 diff --git a/assets/js/window.js b/assets/js/window.js index 7e6c574..c8a3aad 100644 --- a/assets/js/window.js +++ b/assets/js/window.js @@ -4,13 +4,16 @@ class Window { this.innerContainer = document.getElementById(id) } - show() { + show(fromTerminal=false) { this.resize() this.container.style.display = 'block' var self = this; document.addEventListener('keydown', function(event) { if (event.key === 'Escape') { self.hide() + if (fromTerminal) { + terminal.show() + } } }) }