File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -62,8 +62,15 @@ const out = document.getElementById("output");
6262function 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
6976const compile_button = document . getElementById ( "compile" ) ;
@@ -118,11 +125,11 @@ socket.on('stdout', function(msg) {
118125 out . scrollTop = out . scrollHeight ;
119126} ) ;
120127socket . on ( 'stderr' , function ( msg ) {
121- outAppend ( msg . data ) ;
128+ outAppend ( msg . data , 'red' ) ;
122129 out . scrollTop = out . scrollHeight ;
123130} ) ;
124131socket . on ( 'stdin_ack' , function ( msg ) {
125- outAppend ( msg . data ) ;
132+ outAppend ( msg . data , 'blue' ) ;
126133 out . scrollTop = out . scrollHeight ;
127134} ) ;
128135socket . on ( 'done' , function ( msg ) {
You can’t perform that action at this time.
0 commit comments