🎨 playground 输出

This commit is contained in:
Liang Ding 2019-05-19 01:53:31 +08:00
parent 7576910f43
commit 72a7281513
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
3 changed files with 11 additions and 6 deletions

View File

@ -179,7 +179,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request, channel map[string]*util
cmd.Process.Kill()
}
channelRet["output"] = "<span class='stderr'>run program timeout in 5s</span>\n"
channelRet["output"] = "\n<span class='stderr'>run program timeout in 5s</span>\n"
kill = true
case <-done:
channelRet["output"] = "\n<span class='stderr'>run program complete</span>\n"

View File

@ -305,8 +305,11 @@ var playground = {
playground.pid = data.pid;
var val = $("#output").val();
$("#output").val(val + data.output);
var output = data.output;
output = output.replace(/\r/g, '');
output = output.replace(/\n/g, '<br/>');
var oldOutput = $("#output").html();
$("#output").html(oldOutput + output);
};
playgroundWS.onclose = function (e) {
console.log('[playground onclose] disconnected (' + e.code + ')');
@ -424,7 +427,7 @@ var playground = {
var request = newWideRequest();
request.code = code;
$("#output").val("");
$("#output").html("");
$.ajax({
type: 'POST',
@ -455,7 +458,7 @@ var playground = {
var data = result.data;
$("#output").val(data.output);
$("#output").html(data.output);
if (!result.succ) {
return;

View File

@ -64,7 +64,9 @@
<div id="editorDiv">
<textarea rows="20" id='editor' class="fn-none">{{.code}}</textarea>
</div>
<textarea id="output" rows="20" readonly="readonly" ></textarea>
<div class="bottom-window-group">
<div id="output" class="output"></div>
</div>
</div>
<div class="fn-right" id="goNews"></div>
</div>