2014-08-18 17:45:43 +04:00
|
|
|
|
var wide = {
|
2014-08-29 13:24:08 +04:00
|
|
|
|
curNode: undefined,
|
|
|
|
|
curEditor: undefined,
|
2014-09-24 09:40:19 +04:00
|
|
|
|
curProcessId: undefined, // 当前正在运行的进程 id(pid)
|
2014-09-17 06:10:26 +04:00
|
|
|
|
bottomWindowTab: undefined,
|
2014-09-24 08:07:20 +04:00
|
|
|
|
_initDialog: function () {
|
2014-09-24 07:35:03 +04:00
|
|
|
|
$("#dialogAlert").dialog({
|
|
|
|
|
"height": 26,
|
|
|
|
|
"width": 260,
|
|
|
|
|
"title": config.label.tip,
|
|
|
|
|
"hiddenOk": true,
|
|
|
|
|
"cancelText": config.label.confirm,
|
2014-09-24 08:07:20 +04:00
|
|
|
|
"afterOpen": function (msg) {
|
2014-09-24 07:35:03 +04:00
|
|
|
|
$("#dialogAlert").html(msg);
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-09-24 08:07:20 +04:00
|
|
|
|
|
2014-09-22 13:44:34 +04:00
|
|
|
|
$("#dialogRemoveConfirm").dialog({
|
|
|
|
|
"height": 26,
|
|
|
|
|
"width": 260,
|
|
|
|
|
"title": config.label.delete,
|
|
|
|
|
"okText": config.label.delete,
|
|
|
|
|
"cancelText": config.label.cancel,
|
2014-09-24 08:07:20 +04:00
|
|
|
|
"afterOpen": function () {
|
2014-09-22 13:44:34 +04:00
|
|
|
|
$("#dialogRemoveConfirm > b").html('"' + wide.curNode.name + '"');
|
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
"ok": function () {
|
2014-09-22 13:44:34 +04:00
|
|
|
|
var request = newWideRequest();
|
|
|
|
|
request.path = wide.curNode.path;
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: 'POST',
|
|
|
|
|
url: '/file/remove',
|
|
|
|
|
data: JSON.stringify(request),
|
|
|
|
|
dataType: "json",
|
2014-09-24 08:07:20 +04:00
|
|
|
|
success: function (data) {
|
2014-09-22 13:44:34 +04:00
|
|
|
|
if (!data.succ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("#dialogRemoveConfirm").dialog("close");
|
|
|
|
|
tree.fileTree.removeNode(wide.curNode);
|
|
|
|
|
|
|
|
|
|
if ("ico-ztree-dir " !== wide.curNode.iconSkin) {
|
|
|
|
|
// 是文件的话,查看 editor 中是否被打开,如打开则移除
|
|
|
|
|
for (var i = 0, ii = editors.data.length; i < ii; i++) {
|
|
|
|
|
if (editors.data[i].id === wide.curNode.tId) {
|
2014-09-25 12:40:05 +04:00
|
|
|
|
$(".edit-panel .tabs > div[data-index=" + wide.curNode.tId + "]").find(".ico-close").click();
|
2014-09-22 13:44:34 +04:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for (var i = 0, ii = editors.data.length; i < ii; i++) {
|
|
|
|
|
if (tree._isParents(editors.data[i].id, wide.curNode.tId)) {
|
2014-09-25 12:40:05 +04:00
|
|
|
|
$(".edit-panel .tabs > div[data-index=" + editors.data[i].id + "]").find(".ico-close").click();
|
2014-09-22 13:44:34 +04:00
|
|
|
|
i--;
|
|
|
|
|
ii--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2014-09-24 08:07:20 +04:00
|
|
|
|
$(".dialog-prompt > input").keydown(function (event) {
|
2014-09-22 14:09:16 +04:00
|
|
|
|
$(".dialog-prompt > .tip").text('');
|
2014-09-24 08:07:20 +04:00
|
|
|
|
|
2014-09-22 14:09:16 +04:00
|
|
|
|
if (event.which === 13) {
|
|
|
|
|
$(this).closest(".dialog-main").find(".dialog-footer > button:eq(0)").click();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2014-09-22 13:44:34 +04:00
|
|
|
|
$("#dialogNewFilePrompt").dialog({
|
2014-09-22 14:09:16 +04:00
|
|
|
|
"height": 52,
|
2014-09-22 13:44:34 +04:00
|
|
|
|
"width": 260,
|
|
|
|
|
"title": config.label.create_file,
|
|
|
|
|
"okText": config.label.create,
|
|
|
|
|
"cancelText": config.label.cancel,
|
2014-09-24 08:07:20 +04:00
|
|
|
|
"afterOpen": function () {
|
2014-09-22 13:44:34 +04:00
|
|
|
|
$("#dialogNewFilePrompt > input").val('').focus();
|
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
"ok": function () {
|
2014-09-22 13:44:34 +04:00
|
|
|
|
var request = newWideRequest(),
|
2014-09-22 14:09:16 +04:00
|
|
|
|
name = $("#dialogNewFilePrompt > input").val();
|
|
|
|
|
if ($.trim(name) === "") {
|
|
|
|
|
$("#dialogNewFilePrompt > .tip").text(config.label.input_no_empty);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-22 13:44:34 +04:00
|
|
|
|
request.path = wide.curNode.path + '\\' + name;
|
|
|
|
|
request.fileType = "f";
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: 'POST',
|
|
|
|
|
url: '/file/new',
|
|
|
|
|
data: JSON.stringify(request),
|
|
|
|
|
dataType: "json",
|
2014-09-24 08:07:20 +04:00
|
|
|
|
success: function (data) {
|
2014-09-22 13:44:34 +04:00
|
|
|
|
if (!data.succ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$("#dialogNewFilePrompt").dialog("close");
|
|
|
|
|
var suffix = name.split(".")[1],
|
|
|
|
|
iconSkin = "ico-ztree-other ";
|
|
|
|
|
switch (suffix) {
|
|
|
|
|
case "html", "htm":
|
|
|
|
|
iconSkin = "ico-ztree-html ";
|
|
|
|
|
break;
|
|
|
|
|
case "go":
|
|
|
|
|
iconSkin = "ico-ztree-go ";
|
|
|
|
|
break;
|
|
|
|
|
case "css":
|
|
|
|
|
iconSkin = "ico-ztree-css ";
|
|
|
|
|
break;
|
|
|
|
|
case "txt":
|
|
|
|
|
iconSkin = "ico-ztree-text ";
|
|
|
|
|
break;
|
|
|
|
|
case "sql":
|
|
|
|
|
iconSkin = "ico-ztree-sql ";
|
|
|
|
|
break;
|
|
|
|
|
case "properties":
|
|
|
|
|
iconSkin = "ico-ztree-pro ";
|
|
|
|
|
break;
|
|
|
|
|
case "md":
|
|
|
|
|
iconSkin = "ico-ztree-md ";
|
|
|
|
|
break;
|
|
|
|
|
case "js", "json":
|
|
|
|
|
iconSkin = "ico-ztree-js ";
|
|
|
|
|
break;
|
|
|
|
|
case "xml":
|
|
|
|
|
iconSkin = "ico-ztree-xml ";
|
|
|
|
|
break;
|
|
|
|
|
case "jpg", "jpeg", "bmp", "gif", "png", "svg", "ico":
|
|
|
|
|
iconSkin = "ico-ztree-img ";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tree.fileTree.addNodes(wide.curNode, [{
|
|
|
|
|
"name": name,
|
|
|
|
|
"iconSkin": iconSkin,
|
|
|
|
|
"path": request.path,
|
|
|
|
|
"mode": data.mode
|
|
|
|
|
}]);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#dialogNewDirPrompt").dialog({
|
2014-09-22 14:09:16 +04:00
|
|
|
|
"height": 52,
|
2014-09-22 13:44:34 +04:00
|
|
|
|
"width": 260,
|
|
|
|
|
"title": config.label.create_dir,
|
|
|
|
|
"okText": config.label.create,
|
|
|
|
|
"cancelText": config.label.cancel,
|
2014-09-24 08:07:20 +04:00
|
|
|
|
"afterOpen": function () {
|
2014-09-22 13:44:34 +04:00
|
|
|
|
$("#dialogNewDirPrompt > input").val('').focus();
|
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
"ok": function () {
|
2014-09-22 13:44:34 +04:00
|
|
|
|
var name = $("#dialogNewDirPrompt > input").val(),
|
|
|
|
|
request = newWideRequest();
|
2014-09-22 14:09:16 +04:00
|
|
|
|
if ($.trim(name) === "") {
|
|
|
|
|
$("#dialogNewDirPrompt > .tip").text(config.label.input_no_empty);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-09-22 13:44:34 +04:00
|
|
|
|
request.path = wide.curNode.path + '\\' + name;
|
|
|
|
|
request.fileType = "d";
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: 'POST',
|
|
|
|
|
url: '/file/new',
|
|
|
|
|
data: JSON.stringify(request),
|
|
|
|
|
dataType: "json",
|
2014-09-24 08:07:20 +04:00
|
|
|
|
success: function (data) {
|
2014-09-22 13:44:34 +04:00
|
|
|
|
if (!data.succ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("#dialogNewDirPrompt").dialog("close");
|
|
|
|
|
|
|
|
|
|
tree.fileTree.addNodes(wide.curNode, [{
|
|
|
|
|
"name": name,
|
|
|
|
|
"iconSkin": "ico-ztree-dir ",
|
|
|
|
|
"path": request.path
|
|
|
|
|
}]);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#dialogGoLinePrompt").dialog({
|
2014-09-22 14:09:16 +04:00
|
|
|
|
"height": 52,
|
2014-09-22 13:44:34 +04:00
|
|
|
|
"width": 260,
|
|
|
|
|
"title": config.label.goto_line,
|
|
|
|
|
"okText": config.label.goto,
|
|
|
|
|
"cancelText": config.label.cancel,
|
2014-09-24 08:07:20 +04:00
|
|
|
|
"afterOpen": function () {
|
2014-09-22 13:44:34 +04:00
|
|
|
|
$("#dialogGoLinePrompt > input").val('').focus();
|
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
"ok": function () {
|
2014-09-22 13:44:34 +04:00
|
|
|
|
var line = parseInt($("#dialogGoLinePrompt > input").val());
|
2014-09-25 12:03:14 +04:00
|
|
|
|
if ($.trim($("#dialogGoLinePrompt > input").val()) === "") {
|
2014-09-22 14:09:16 +04:00
|
|
|
|
$("#dialogGoLinePrompt > .tip").text(config.label.input_no_empty);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-09-22 13:44:34 +04:00
|
|
|
|
$("#dialogGoLinePrompt").dialog("close");
|
|
|
|
|
wide.curEditor.setCursor(CodeMirror.Pos(line - 1, 0));
|
|
|
|
|
wide.curEditor.focus();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
_initLayout: function () {
|
2014-09-26 13:58:54 +04:00
|
|
|
|
var mainH = $(window).height() - $(".menu").height() - $(".footer").height() - 1,
|
2014-09-24 12:25:26 +04:00
|
|
|
|
bottomH = Math.floor(mainH * 0.3);
|
2014-09-25 07:04:17 +04:00
|
|
|
|
$(".content").height(mainH);
|
|
|
|
|
$(".side .tabs-panel").height(mainH - 20);
|
2014-09-05 10:33:43 +04:00
|
|
|
|
|
2014-09-26 13:58:54 +04:00
|
|
|
|
$(".bottom-window-group .output").height(bottomH - 27);
|
2014-09-24 12:25:26 +04:00
|
|
|
|
$(".bottom-window-group .notification, .bottom-window-group .search").height(bottomH - 20);
|
2014-09-02 14:09:01 +04:00
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
_initBottomWindowGroup: function () {
|
2014-09-17 06:10:26 +04:00
|
|
|
|
this.bottomWindowTab = new Tabs({
|
2014-09-19 13:58:29 +04:00
|
|
|
|
id: ".bottom-window-group",
|
2014-09-24 08:07:20 +04:00
|
|
|
|
clickAfter: function (id) {
|
2014-09-19 13:58:29 +04:00
|
|
|
|
this._$tabsPanel.find("." + id).focus();
|
|
|
|
|
}
|
2014-09-16 13:48:19 +04:00
|
|
|
|
});
|
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
_initWS: function () {
|
|
|
|
|
var outputWS = new WebSocket(config.channel.output + '/output/ws?sid=' + config.wideSessionId);
|
|
|
|
|
outputWS.onopen = function () {
|
|
|
|
|
console.log('[output onopen] connected');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
outputWS.onmessage = function (e) {
|
|
|
|
|
console.log('[output onmessage]' + e.data);
|
|
|
|
|
var data = JSON.parse(e.data);
|
|
|
|
|
|
|
|
|
|
if (goLintFound) {
|
|
|
|
|
goLintFound = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ('run' === data.nextCmd) {
|
|
|
|
|
var request = newWideRequest();
|
|
|
|
|
request.executable = data.executable;
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: 'POST',
|
|
|
|
|
url: '/run',
|
|
|
|
|
data: JSON.stringify(request),
|
|
|
|
|
dataType: "json",
|
|
|
|
|
beforeSend: function (data) {
|
|
|
|
|
$('.bottom-window-group .output').text('');
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ('run' === data.cmd) { // 正在运行
|
|
|
|
|
$('.bottom-window-group .output').text($('.bottom-window-group .output').text() + data.output);
|
2014-09-24 09:40:19 +04:00
|
|
|
|
|
|
|
|
|
wide.curProcessId = data.pid;
|
|
|
|
|
} else if ('run-done' === data.cmd) { // 运行结束
|
|
|
|
|
wide.curProcessId = undefined;
|
2014-09-24 11:24:37 +04:00
|
|
|
|
// 运行结束后修改 [构建&运行] 图标状态为可用状态
|
|
|
|
|
$(".toolbars .ico-stop").removeClass("ico-stop")
|
|
|
|
|
.addClass("ico-buildrun").attr("title", config.label.build_n_run);
|
2014-09-24 08:07:20 +04:00
|
|
|
|
} else if ('build' === data.cmd || 'go install' === data.cmd) {
|
|
|
|
|
$('.bottom-window-group .output').text(data.output);
|
|
|
|
|
|
|
|
|
|
if (0 !== data.output.length) { // 说明编译有错误输出
|
|
|
|
|
for (var i = 0; i < data.lints.length; i++) {
|
|
|
|
|
var lint = data.lints[i];
|
|
|
|
|
|
|
|
|
|
goLintFound.push({from: CodeMirror.Pos(lint.lineNo, 0),
|
|
|
|
|
to: CodeMirror.Pos(lint.lineNo, 0),
|
|
|
|
|
message: lint.msg, severity: lint.severity});
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-24 11:24:37 +04:00
|
|
|
|
$(".toolbars .ico-stop").removeClass("ico-stop")
|
|
|
|
|
.addClass("ico-buildrun").attr("title", config.label.build_n_run);
|
2014-09-24 08:07:20 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 触发一次 gutter lint
|
|
|
|
|
CodeMirror.signal(wide.curEditor, "change", wide.curEditor);
|
|
|
|
|
} else if ('go get' === data.cmd || 'go install' === data.cmd) {
|
|
|
|
|
$('.bottom-window-group .output').text($('.bottom-window-group .output').text() + data.output);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
outputWS.onclose = function (e) {
|
|
|
|
|
console.log('[output onclose] disconnected (' + e.code + ')');
|
|
|
|
|
delete outputWS;
|
|
|
|
|
};
|
|
|
|
|
outputWS.onerror = function (e) {
|
|
|
|
|
console.log('[output onerror] ' + e);
|
|
|
|
|
};
|
|
|
|
|
},
|
2014-09-25 12:03:14 +04:00
|
|
|
|
_initFooter: function () {
|
|
|
|
|
$(".footer .cursor").dblclick(function () {
|
|
|
|
|
$("#dialogGoLinePrompt").dialog("open");
|
|
|
|
|
});
|
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
init: function () {
|
2014-09-25 12:03:14 +04:00
|
|
|
|
this._initFooter();
|
2014-09-24 11:24:37 +04:00
|
|
|
|
|
2014-09-24 12:25:26 +04:00
|
|
|
|
this._initWS();
|
2014-09-17 06:04:41 +04:00
|
|
|
|
|
2014-09-16 13:48:19 +04:00
|
|
|
|
this._initBottomWindowGroup();
|
2014-08-18 17:45:43 +04:00
|
|
|
|
|
2014-09-24 08:07:20 +04:00
|
|
|
|
$("body").bind("mousedown", function (event) {
|
2014-08-18 17:45:43 +04:00
|
|
|
|
if (!(event.target.id === "dirRMenu" || $(event.target).closest("#dirRMenu").length > 0)) {
|
|
|
|
|
$("#dirRMenu").hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(event.target.id === "fileRMenu" || $(event.target).closest("#fileRMenu").length > 0)) {
|
|
|
|
|
$("#fileRMenu").hide();
|
|
|
|
|
}
|
2014-09-10 14:08:35 +04:00
|
|
|
|
|
|
|
|
|
if (!($(event.target).closest(".frame").length > 0 || event.target.className === "frame")) {
|
|
|
|
|
$(".frame").hide();
|
|
|
|
|
$(".menu > ul > li > a, .menu > ul> li > span").unbind("mouseover");
|
|
|
|
|
menu.subMenu();
|
|
|
|
|
}
|
2014-08-18 17:45:43 +04:00
|
|
|
|
});
|
2014-09-13 20:07:03 +04:00
|
|
|
|
|
2014-09-22 13:44:34 +04:00
|
|
|
|
this._initDialog();
|
2014-09-24 12:25:26 +04:00
|
|
|
|
|
|
|
|
|
this._initLayout();
|
2014-08-18 17:45:43 +04:00
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
_save: function () {
|
2014-09-17 06:04:41 +04:00
|
|
|
|
var request = newWideRequest();
|
2014-09-26 11:39:13 +04:00
|
|
|
|
request.file = editors.getCurrentPath();
|
2014-09-17 06:04:41 +04:00
|
|
|
|
request.code = wide.curEditor.getValue();
|
|
|
|
|
|
2014-08-18 17:45:43 +04:00
|
|
|
|
$.ajax({
|
|
|
|
|
type: 'POST',
|
2014-08-22 06:09:48 +04:00
|
|
|
|
url: '/file/save',
|
2014-08-18 17:45:43 +04:00
|
|
|
|
data: JSON.stringify(request),
|
|
|
|
|
dataType: "json",
|
2014-09-24 08:07:20 +04:00
|
|
|
|
success: function (data) {
|
2014-08-18 17:45:43 +04:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
saveFile: function () {
|
2014-09-20 07:54:33 +04:00
|
|
|
|
// 格式化后会对文件进行保存
|
|
|
|
|
this.fmt();
|
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
saveAllFiles: function () {
|
2014-09-22 13:44:34 +04:00
|
|
|
|
// TODO: save all open files
|
|
|
|
|
for (var i = 0, ii = editors.data.length; i < ii; i++) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
console.log("TODO: save all files");
|
2014-09-10 18:43:34 +04:00
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
closeFile: function () {
|
2014-09-14 16:37:48 +04:00
|
|
|
|
// TODO: close file
|
2014-09-10 18:43:34 +04:00
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
closeAllFiles: function () {
|
2014-09-14 16:37:48 +04:00
|
|
|
|
// TODO: close all files
|
2014-09-10 18:43:34 +04:00
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
exit: function () {
|
2014-09-10 18:43:34 +04:00
|
|
|
|
// TODO: exit
|
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
stop: function () {
|
2014-09-24 11:24:37 +04:00
|
|
|
|
if ($(".toolbars .ico-buildrun").length === 1) {
|
2014-09-24 08:07:20 +04:00
|
|
|
|
wide.run();
|
|
|
|
|
return false;
|
2014-09-24 11:24:37 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-24 08:07:20 +04:00
|
|
|
|
var request = newWideRequest();
|
2014-09-24 09:40:19 +04:00
|
|
|
|
request.pid = wide.curProcessId;
|
2014-09-24 08:07:20 +04:00
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: 'POST',
|
|
|
|
|
url: '/stop',
|
|
|
|
|
data: JSON.stringify(request),
|
|
|
|
|
dataType: "json",
|
|
|
|
|
beforeSend: function (data) {
|
2014-09-24 09:40:19 +04:00
|
|
|
|
// $('.bottom-window-group .output').text('');
|
2014-09-24 08:07:20 +04:00
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
2014-09-24 11:24:37 +04:00
|
|
|
|
$(".toolbars .ico-stop").removeClass("ico-stop")
|
|
|
|
|
.addClass("ico-buildrun").attr("title", config.label.build_n_run);
|
2014-09-24 08:07:20 +04:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
2014-09-16 13:32:55 +04:00
|
|
|
|
// 构建 & 运行.
|
2014-09-24 08:07:20 +04:00
|
|
|
|
run: function () {
|
|
|
|
|
if ($(".toolbars .ico-stop").length === 1) {
|
|
|
|
|
wide.stop();
|
|
|
|
|
return false;
|
2014-09-24 11:24:37 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-17 06:04:41 +04:00
|
|
|
|
var request = newWideRequest();
|
2014-09-26 11:39:13 +04:00
|
|
|
|
request.file = editors.getCurrentPath();
|
2014-09-17 06:04:41 +04:00
|
|
|
|
request.code = wide.curEditor.getValue();
|
2014-08-29 13:24:08 +04:00
|
|
|
|
|
2014-08-18 17:45:43 +04:00
|
|
|
|
$.ajax({
|
|
|
|
|
type: 'POST',
|
2014-08-22 07:57:05 +04:00
|
|
|
|
url: '/build',
|
2014-08-18 17:45:43 +04:00
|
|
|
|
data: JSON.stringify(request),
|
|
|
|
|
dataType: "json",
|
2014-09-24 08:07:20 +04:00
|
|
|
|
beforeSend: function (data) {
|
2014-09-17 06:10:26 +04:00
|
|
|
|
$('.bottom-window-group .output').text('');
|
2014-08-18 17:45:43 +04:00
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
success: function (data) {
|
2014-09-24 11:24:37 +04:00
|
|
|
|
$(".toolbars .ico-buildrun").addClass("ico-stop")
|
|
|
|
|
.removeClass("ico-buildrun").attr("title", config.label.stop);
|
2014-09-05 08:18:50 +04:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
goget: function () {
|
2014-09-17 06:04:41 +04:00
|
|
|
|
var request = newWideRequest();
|
2014-09-26 11:39:13 +04:00
|
|
|
|
request.file = editors.getCurrentPath();
|
2014-08-29 13:24:08 +04:00
|
|
|
|
|
2014-09-05 08:18:50 +04:00
|
|
|
|
$.ajax({
|
|
|
|
|
type: 'POST',
|
|
|
|
|
url: '/go/get',
|
|
|
|
|
data: JSON.stringify(request),
|
|
|
|
|
dataType: "json",
|
2014-09-24 08:07:20 +04:00
|
|
|
|
beforeSend: function (data) {
|
2014-09-17 06:10:26 +04:00
|
|
|
|
$('.bottom-window-group .output').text('');
|
2014-09-09 13:01:22 +04:00
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
success: function (data) {
|
2014-09-09 13:01:22 +04:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
goinstall: function () {
|
2014-09-17 06:04:41 +04:00
|
|
|
|
var request = newWideRequest();
|
2014-09-26 11:39:13 +04:00
|
|
|
|
request.file = editors.getCurrentPath();
|
2014-09-17 06:04:41 +04:00
|
|
|
|
request.code = wide.curEditor.getValue();
|
2014-09-09 13:01:22 +04:00
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: 'POST',
|
|
|
|
|
url: '/go/install',
|
|
|
|
|
data: JSON.stringify(request),
|
|
|
|
|
dataType: "json",
|
2014-09-24 08:07:20 +04:00
|
|
|
|
beforeSend: function (data) {
|
2014-09-17 06:10:26 +04:00
|
|
|
|
$('.bottom-window-group .output').text('');
|
2014-09-05 08:18:50 +04:00
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
success: function (data) {
|
2014-08-18 17:45:43 +04:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
2014-09-24 08:07:20 +04:00
|
|
|
|
fmt: function () {
|
2014-09-26 11:39:13 +04:00
|
|
|
|
var path = editors.getCurrentPath();
|
2014-09-22 13:44:34 +04:00
|
|
|
|
var mode = wide.curEditor.getOption("mode");
|
2014-09-07 13:31:57 +04:00
|
|
|
|
|
2014-09-17 06:04:41 +04:00
|
|
|
|
var request = newWideRequest();
|
|
|
|
|
request.file = path;
|
|
|
|
|
request.code = wide.curEditor.getValue();
|
|
|
|
|
request.cursorLine = wide.curEditor.getCursor().line;
|
|
|
|
|
request.cursorCh = wide.curEditor.getCursor().ch;
|
2014-09-07 13:31:57 +04:00
|
|
|
|
|
|
|
|
|
switch (mode) {
|
2014-09-20 07:54:33 +04:00
|
|
|
|
case "text/x-go": // 会保存文件
|
2014-09-07 13:31:57 +04:00
|
|
|
|
$.ajax({
|
|
|
|
|
type: 'POST',
|
|
|
|
|
url: '/go/fmt',
|
|
|
|
|
data: JSON.stringify(request),
|
|
|
|
|
dataType: "json",
|
2014-09-24 08:07:20 +04:00
|
|
|
|
success: function (data) {
|
2014-09-07 13:31:57 +04:00
|
|
|
|
if (data.succ) {
|
|
|
|
|
wide.curEditor.setValue(data.code);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
break;
|
2014-09-20 07:54:33 +04:00
|
|
|
|
case "text/html": // 会保存文件
|
2014-09-07 13:31:57 +04:00
|
|
|
|
$.ajax({
|
|
|
|
|
type: 'POST',
|
|
|
|
|
url: '/html/fmt',
|
|
|
|
|
data: JSON.stringify(request),
|
|
|
|
|
dataType: "json",
|
2014-09-24 08:07:20 +04:00
|
|
|
|
success: function (data) {
|
2014-09-07 13:31:57 +04:00
|
|
|
|
if (data.succ) {
|
|
|
|
|
wide.curEditor.setValue(data.code);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2014-09-07 14:13:55 +04:00
|
|
|
|
break;
|
|
|
|
|
case "application/json":
|
|
|
|
|
try {
|
|
|
|
|
// 在客户端浏览器中进行 JSON 格式化
|
|
|
|
|
var json = JSON.parse(wide.curEditor.getValue());
|
|
|
|
|
wide.curEditor.setValue(JSON.stringify(json, "", " "));
|
2014-09-09 11:33:12 +04:00
|
|
|
|
|
2014-09-20 07:54:33 +04:00
|
|
|
|
wide._save();
|
2014-09-07 14:13:55 +04:00
|
|
|
|
} catch (e) {
|
|
|
|
|
delete e;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-07 13:31:57 +04:00
|
|
|
|
break;
|
|
|
|
|
default :
|
2014-09-16 18:39:22 +04:00
|
|
|
|
// TODO: XML 格式化处理
|
2014-09-20 07:54:33 +04:00
|
|
|
|
// 所有文件格式化后都需要进行保存
|
|
|
|
|
wide._save();
|
2014-09-07 13:31:57 +04:00
|
|
|
|
break;
|
|
|
|
|
}
|
2014-08-18 17:45:43 +04:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2014-09-24 08:07:20 +04:00
|
|
|
|
$(document).ready(function () {
|
2014-08-18 17:45:43 +04:00
|
|
|
|
wide.init();
|
|
|
|
|
tree.init();
|
2014-09-10 14:08:35 +04:00
|
|
|
|
menu.init();
|
2014-09-15 12:06:49 +04:00
|
|
|
|
hotkeys.init();
|
2014-09-19 13:58:29 +04:00
|
|
|
|
notification.init();
|
2014-09-23 17:03:44 +04:00
|
|
|
|
session.init();
|
2014-09-26 11:39:13 +04:00
|
|
|
|
editors.init();
|
|
|
|
|
windows.init();
|
2014-08-18 17:45:43 +04:00
|
|
|
|
});
|