diff --git a/ccp/js/logterminalcontroller.js b/ccp/js/logterminalcontroller.js new file mode 100644 index 0000000..7b2b6bb --- /dev/null +++ b/ccp/js/logterminalcontroller.js @@ -0,0 +1,75 @@ +class LogTerminal extends HTMLElement { + + #maxlines = 10; + #rootdoc = null; + #lines = [] + + constructor(){ + super() + this.#maxlines = this.getAttribute("maxlines") + this.#rootdoc = this.attachShadow({ "mode" : "open"}) + this.render() + } + + connectedCallback(){ + + } + + render(){ + this.innerHTML = ` + + + +
+ ` + } + + refresh(){ + BSS.apply(this.#terminal_bss) + } + + #terminal_bss = { + template : "#TERMINAL_TEMPLATE", + target : "div[name=terminal]", + in : ()=>this, + recurse : { + target : "div.line", + in: d=>d.#lines, + apply: (e,d,i)=>{ + if(d.source === "stderr") e.classList.add("error"); + e.innerHTML = `${d.line}` + } + } + } +} + +window.customElements.define('d4s-ccp-logterminal', LogTerminal); \ No newline at end of file