🎨 更新 Playground 示例
This commit is contained in:
parent
d764f13192
commit
67c36e0089
|
@ -55,7 +55,7 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// try to load file
|
||||
code := conf.HelloWorld
|
||||
fileName := "8b7cc38b4c12e6fde5c4d15a4f2f32e5.go" // MD5 of HelloWorld.go
|
||||
fileName := "6c5595ec6fbadf4cfce3edbfcfd8c6d0.go" // MD5 of HelloWorld.go
|
||||
|
||||
if strings.HasSuffix(r.URL.Path, ".go") {
|
||||
fileNameArg := r.URL.Path[len("/playground/"):]
|
||||
|
|
|
@ -303,11 +303,19 @@ var playground = {
|
|||
|
||||
playground.pid = data.pid;
|
||||
|
||||
var output = data.output;
|
||||
var output = $("#output").html();
|
||||
if ("" === output) {
|
||||
output = "<pre>" + data.output + "</pre>";
|
||||
} else {
|
||||
output = output.replace(/<\/pre>$/g, data.output + '</pre>');
|
||||
}
|
||||
output = output.replace(/\r/g, '');
|
||||
output = output.replace(/\n/g, '<br/>');
|
||||
var oldOutput = $("#output").html();
|
||||
$("#output").html(oldOutput + output);
|
||||
if (-1 !== output.indexOf("<br/>")) {
|
||||
output = Autolinker.link(output);
|
||||
}
|
||||
|
||||
$("#output").html(output);
|
||||
};
|
||||
playgroundWS.onclose = function (e) {
|
||||
console.log('[playground onclose] disconnected (' + e.code + ')');
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
|
||||
<script type="text/javascript" src="/static/js/lib/jquery-2.1.1.min.js"></script>
|
||||
<script type="text/javascript" src="/static/js/lib/reconnecting-websocket.js"></script>
|
||||
|
||||
<script type="text/javascript" src="/static/js/lib/Autolinker.min.js"></script>
|
||||
<script type="text/javascript" src="/static/js/lib/codemirror-{{.codeMirrorVer}}/codemirror.min.js"></script>
|
||||
<script type="text/javascript" src="/static/js/lib/codemirror-{{.codeMirrorVer}}/addon/selection/active-line.js"></script>
|
||||
<script type="text/javascript" src="/static/js/overwrite/codemirror/addon/hint/show-hint.js"></script>
|
||||
|
|
Loading…
Reference in New Issue