class Dialog {
constructor() {
this.dialogElem = document.getElementById('dialog')
this.dialogTextElem = document.getElementById('dialog-text')
this.currentDialogIndex = 0
this.dialogOrder = ['intro', 'controls', 'resume']
this.dialogMap = {
'intro': 'Hello! Welcome to my Interactive Portfolio!
Press ENTER to continue, or click the links below for quick access to my Resume & Projects.',
'controls': 'Use ARROW KEYS or WASD or VIM keys (HJKL) to move around.
Press the ENTER key to interact with what you see on the screen.
',
'resume': 'Walk over to the DESK and click on my RESUME.
The RESUME is marked by the flashing red indicator light
.',
'portfolio': 'Thanks for looking at my Resume!
Check out my PORTFOLIO by clicking on the BOOKSHELF.'
}
this.resumeIndicator = document.getElementById('resume-indicator')
}
dialogListener(event) {
console.log(event)
if (event.key === 'Enter') {
event.currentTarget.self.startIntroDialogSequence()
}
}
startIntroDialogSequence() {
document.removeEventListener("keydown", this.dialogListener);
console.log('hit')
if (this.currentDialogIndex > this.dialogOrder.length - 1) {
this.dialogElem.style.display = 'none'
} else {
var dialog = this.dialogMap[this.dialogOrder[this.currentDialogIndex]]
this.display(dialog)
if (this.dialogOrder[this.currentDialogIndex] in indicator.indicatorMap) {
indicator.show(this.dialogOrder[this.currentDialogIndex])
}
this.currentDialogIndex++
var self = this
document.addEventListener('keydown', this.dialogListener)
document.self = self
}
}
display(dialog) {
this.dialogElem.style.display = 'block'
this.dialogTextElem.innerHTML = this.dialogMap[this.dialogOrder[this.currentDialogIndex]]
}
}