Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.

Additional html-output functions. #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions bin/classes/Prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,29 @@ class Prompt extends Shell{
return this.generateRow()
}
}

// Could be integrated in generateOutput() with an additional parameter "html = false" and
// if(html){pre.innerHTML=out} else {pre.textContent=out}
generateHtmlOutput(out = '', newLine = true) {
if (Array.isArray(out)) {
out = out.join("\n")
}
const pre = document.createElement('pre')
pre.innerHTML = out
pre.className = 'terminal-output'
this.container.appendChild(pre)
if (newLine) {
return this.generateRow()
}
}

appendHtmlOutput(out, newLine = true) {
out.className += ' terminal-output'
this.container.appendChild(out)
if (newLine) {
return this.generateRow()
}
}

clear() {
this.container.innerHTML = ''
Expand Down