Skip to content

Commit d4838a0

Browse files
committed
UI-js: color code stderr and stdin-ack
1 parent c3214f1 commit d4838a0

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

static/js/main.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,15 @@ const out = document.getElementById("output");
6262
function outClear() {
6363
out.innerHTML = "";
6464
}
65-
function outAppend(str) {
66-
out.innerHTML += htmlEscape(str);
65+
function outAppend(str, color) {
66+
var node = document.createTextNode(str);
67+
if (color) {
68+
var span = document.createElement("span");
69+
span.style.color = color;
70+
span.appendChild(node);
71+
node = span;
72+
}
73+
out.appendChild(node);
6774
}
6875

6976
const compile_button = document.getElementById("compile");
@@ -118,11 +125,11 @@ socket.on('stdout', function(msg) {
118125
out.scrollTop = out.scrollHeight;
119126
});
120127
socket.on('stderr', function(msg) {
121-
outAppend(msg.data);
128+
outAppend(msg.data, 'red');
122129
out.scrollTop = out.scrollHeight;
123130
});
124131
socket.on('stdin_ack', function(msg) {
125-
outAppend(msg.data);
132+
outAppend(msg.data, 'blue');
126133
out.scrollTop = out.scrollHeight;
127134
});
128135
socket.on('done', function(msg) {

0 commit comments

Comments
 (0)