diff --git a/output/cross.go b/output/cross.go index 365ef15..5047e40 100644 --- a/output/cross.go +++ b/output/cross.go @@ -34,8 +34,8 @@ import ( // CrossCompilationHandler handles request of cross compilation. func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) { - data := map[string]interface{}{"succ": true} - defer util.RetJSON(w, r, data) + result := util.NewResult() + defer util.RetResult(w, r, result) httpSession, _ := session.HTTPSession.Get(r, "wide-session") if httpSession.IsNew { @@ -50,7 +50,7 @@ func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) { if err := json.NewDecoder(r.Body).Decode(&args); err != nil { logger.Error(err) - data["succ"] = false + result.Succ = false return } @@ -101,7 +101,7 @@ func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) { stdout, err := cmd.StdoutPipe() if nil != err { logger.Error(err) - data["succ"] = false + result.Succ = false return } @@ -109,12 +109,12 @@ func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) { stderr, err := cmd.StderrPipe() if nil != err { logger.Error(err) - data["succ"] = false + result.Succ = false return } - if !data["succ"].(bool) { + if !result.Succ { return } @@ -141,7 +141,7 @@ func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) { if err := cmd.Start(); nil != err { logger.Error(err) - data["succ"] = false + result.Succ = false return } diff --git a/output/get.go b/output/get.go index 52fabe8..958daa2 100644 --- a/output/get.go +++ b/output/get.go @@ -32,8 +32,8 @@ import ( // GoGetHandler handles request of go get. func GoGetHandler(w http.ResponseWriter, r *http.Request) { - data := map[string]interface{}{"succ": true} - defer util.RetJSON(w, r, data) + result := util.NewResult() + defer util.RetResult(w, r, result) httpSession, _ := session.HTTPSession.Get(r, "wide-session") if httpSession.IsNew { @@ -47,7 +47,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) { var args map[string]interface{} if err := json.NewDecoder(r.Body).Decode(&args); err != nil { logger.Error(err) - data["succ"] = false + result.Succ = false return } @@ -65,7 +65,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) { stdout, err := cmd.StdoutPipe() if nil != err { logger.Error(err) - data["succ"] = false + result.Succ = false return } @@ -73,12 +73,12 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) { stderr, err := cmd.StderrPipe() if nil != err { logger.Error(err) - data["succ"] = false + result.Succ = false return } - if !data["succ"].(bool) { + if !result.Succ { return } @@ -105,7 +105,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) { if err := cmd.Start(); nil != err { logger.Error(err) - data["succ"] = false + result.Succ = false return } diff --git a/output/install.go b/output/install.go index b485f59..1fc5b81 100644 --- a/output/install.go +++ b/output/install.go @@ -34,8 +34,8 @@ import ( // GoInstallHandler handles request of go install. func GoInstallHandler(w http.ResponseWriter, r *http.Request) { - data := map[string]interface{}{"succ": true} - defer util.RetJSON(w, r, data) + result := util.NewResult() + defer util.RetResult(w, r, result) httpSession, _ := session.HTTPSession.Get(r, "wide-session") if httpSession.IsNew { @@ -50,7 +50,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) { if err := json.NewDecoder(r.Body).Decode(&args); err != nil { logger.Error(err) - data["succ"] = false + result.Succ = false return } @@ -70,7 +70,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) { stdout, err := cmd.StdoutPipe() if nil != err { logger.Error(err) - data["succ"] = false + result.Succ = false return } @@ -78,12 +78,12 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) { stderr, err := cmd.StderrPipe() if nil != err { logger.Error(err) - data["succ"] = false + result.Succ = false return } - if !data["succ"].(bool) { + if !result.Succ { return } @@ -110,7 +110,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) { if err := cmd.Start(); nil != err { logger.Error(err) - data["succ"] = false + result.Succ = false return } diff --git a/output/run.go b/output/run.go index 0dea317..a82fd9e 100644 --- a/output/run.go +++ b/output/run.go @@ -41,20 +41,20 @@ type outputBuf struct { // RunHandler handles request of executing a binary file. func RunHandler(w http.ResponseWriter, r *http.Request) { - data := map[string]interface{}{"succ": true} - defer util.RetJSON(w, r, data) + result := util.NewResult() + defer util.RetResult(w, r, result) var args map[string]interface{} if err := json.NewDecoder(r.Body).Decode(&args); err != nil { logger.Error(err) - data["succ"] = false + result.Succ = false } sid := args["sid"].(string) wSession := session.WideSessions.Get(sid) if nil == wSession { - data["succ"] = false + result.Succ = false } filePath := args["executable"].(string) @@ -70,13 +70,13 @@ func RunHandler(w http.ResponseWriter, r *http.Request) { stdout, err := cmd.StdoutPipe() if nil != err { logger.Error(err) - data["succ"] = false + result.Succ = false } stderr, err := cmd.StderrPipe() if nil != err { logger.Error(err) - data["succ"] = false + result.Succ = false } outReader := bufio.NewReader(stdout) @@ -84,14 +84,14 @@ func RunHandler(w http.ResponseWriter, r *http.Request) { if err := cmd.Start(); nil != err { logger.Error(err) - data["succ"] = false + result.Succ = false } wsChannel := session.OutputWS[sid] channelRet := map[string]interface{}{} - if !data["succ"].(bool) { + if !result.Succ { if nil != wsChannel { channelRet["cmd"] = "run-done" channelRet["output"] = "" @@ -235,13 +235,13 @@ func RunHandler(w http.ResponseWriter, r *http.Request) { // StopHandler handles request of stoping a running process. func StopHandler(w http.ResponseWriter, r *http.Request) { - data := map[string]interface{}{"succ": true} - defer util.RetJSON(w, r, data) + result := util.NewResult() + defer util.RetResult(w, r, result) var args map[string]interface{} if err := json.NewDecoder(r.Body).Decode(&args); err != nil { logger.Error(err) - data["succ"] = false + result.Succ = false return } @@ -251,7 +251,7 @@ func StopHandler(w http.ResponseWriter, r *http.Request) { wSession := session.WideSessions.Get(sid) if nil == wSession { - data["succ"] = false + result.Succ = false return } diff --git a/static/js/menu.js b/static/js/menu.js index 92b3ad9..9b72578 100644 --- a/static/js/menu.js +++ b/static/js/menu.js @@ -186,10 +186,10 @@ var menu = { url: config.context + '/go/get', data: JSON.stringify(request), dataType: "json", - beforeSend: function (data) { + beforeSend: function () { bottomGroup.resetOutput(); }, - success: function (data) { + success: function (result) { } }); }, @@ -213,10 +213,10 @@ var menu = { url: config.context + '/go/install', data: JSON.stringify(request), dataType: "json", - beforeSend: function (data) { + beforeSend: function () { bottomGroup.resetOutput(); }, - success: function (data) { + success: function (result) { } }); }, @@ -241,10 +241,10 @@ var menu = { url: config.context + '/go/test', data: JSON.stringify(request), dataType: "json", - beforeSend: function (data) { + beforeSend: function () { bottomGroup.resetOutput(); }, - success: function (data) { + success: function (result) { } }); }, @@ -269,10 +269,10 @@ var menu = { url: config.context + '/go/vet', data: JSON.stringify(request), dataType: "json", - beforeSend: function (data) { + beforeSend: function () { bottomGroup.resetOutput(); }, - success: function (data) { + success: function (result) { } }); }, @@ -304,7 +304,7 @@ var menu = { url: config.context + '/build', data: JSON.stringify(request), dataType: "json", - beforeSend: function (result) { + beforeSend: function () { bottomGroup.resetOutput(); }, success: function (result) { @@ -336,7 +336,7 @@ var menu = { url: config.context + '/build', data: JSON.stringify(request), dataType: "json", - beforeSend: function (result) { + beforeSend: function () { bottomGroup.resetOutput(); }, success: function (result) { @@ -445,7 +445,7 @@ var menu = { "editorTabSize": $editorTabSize.val(), "keymap": $keymap.val() }); - + if (config.keymap !== $keymap.val()) { window.location.reload(); } @@ -473,7 +473,7 @@ var menu = { $editorTheme.data("value", $editorTheme.val()); $editorTabSize.data("value", $editorTabSize.val()); $keymap.data("value", $keymap.val()); - + // update the config config.keymap = $keymap.val(); diff --git a/static/js/tree.js b/static/js/tree.js index 5db3381..bf633f0 100644 --- a/static/js/tree.js +++ b/static/js/tree.js @@ -182,9 +182,9 @@ var tree = { url: config.context + '/cross', data: JSON.stringify(request), dataType: "json", - success: function (data) { - if (!data.succ) { - $("#dialogAlert").dialog("open", data.msg); + success: function (result) { + if (!result.succ) { + $("#dialogAlert").dialog("open", result.msg); return false; } diff --git a/static/js/wide.js b/static/js/wide.js index 5b94be6..32f1e91 100644 --- a/static/js/wide.js +++ b/static/js/wide.js @@ -617,7 +617,7 @@ var wide = { url: config.context + '/build', data: JSON.stringify(request), dataType: "json", - beforeSend: function (result) { + beforeSend: function () { bottomGroup.resetOutput(); }, success: function (result) { @@ -650,7 +650,7 @@ var wide = { url: config.context + '/stop', data: JSON.stringify(request), dataType: "json", - success: function (data) { + success: function (result) { $("#buildRun").removeClass("ico-stop") .addClass("ico-buildrun").attr("title", config.label.build_n_run); }