terminal features
This commit is contained in:
parent
8b0a0ed271
commit
eacc1db61a
2 changed files with 41 additions and 13 deletions
|
|
@ -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:<br>
|
||||
========================================<br>
|
||||
help     Shows the help screen<br>
|
||||
about    Provides background of the terminal<br>
|
||||
clear    Clears the terminal<br>
|
||||
echo     Display a line of text<br>
|
||||
exit     Exits the terminal<br>
|
||||
history  Prints command history<br>
|
||||
help      Shows the help screen<br>
|
||||
about     Provides background of the terminal<br>
|
||||
clear     Clears the terminal<br>
|
||||
echo      Display a line of text<br>
|
||||
exit      Exits the terminal<br>
|
||||
history   Prints command history<br>
|
||||
resume    Displays Resume<br>
|
||||
portfolio Displays Portfolio<br>
|
||||
games     Displays Games<br>
|
||||
music     Displays Music<br>
|
||||
contact   Displays Contact Info<br>
|
||||
<br>
|
||||
Terminal Functionality:<br>
|
||||
========================================<br>
|
||||
|
|
@ -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<br>XMPP: domdit@xmpp.jp'
|
||||
|
||||
} else if (promptText === 'history') {
|
||||
|
||||
returnText = this.commands.join('<br>')
|
||||
returnText = this.commands.join('<br>')
|
||||
|
||||
} 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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue