This commit is contained in:
Liang Ding 2014-09-17 10:04:41 +08:00
parent f7cc9ac140
commit d19698a42e
5 changed files with 141 additions and 134 deletions

View File

@ -27,6 +27,8 @@
<ul>
<li>Ctrl+1焦点切换到文件树</li>
<li>Ctrl+4焦点切换到输出窗口</li>
<li>Ctrl+5焦点切换到搜索窗口</li>
<li>Ctrl+6焦点切换到通知窗口</li>
</ul>
<h2>运行</h2>

View File

@ -79,12 +79,11 @@ var editors = {
--start;
}
var request = {
path: $(".edit-header .current > span:eq(0)").attr("title"),
code: editor.getValue(),
cursorLine: cur.line,
cursorCh: cur.ch
};
var request = newWideRequest();
request.path = $(".edit-header .current > span:eq(0)").attr("title");
request.code = editor.getValue();
request.cursorLine = cur.line;
request.cursorCh = cur.ch;
var autocompleteHints = [];
@ -134,12 +133,11 @@ var editors = {
CodeMirror.commands.jumpToDecl = function (cm) {
var cur = wide.curEditor.getCursor();
var request = {
path: $(".edit-header .current > span:eq(0)").attr("title"),
code: wide.curEditor.getValue(),
cursorLine: cur.line,
cursorCh: cur.ch
};
var request = newWideRequest();
request.path = $(".edit-header .current > span:eq(0)").attr("title");
request.code = wide.curEditor.getValue();
request.cursorLine = cur.line;
request.cursorCh = cur.ch;
$.ajax({
type: 'POST',
@ -154,9 +152,8 @@ var editors = {
var cursorLine = data.cursorLine;
var cursorCh = data.cursorCh;
var request = {
path: data.path
};
var request = newWideRequest();
request.path = data.path;
$.ajax({
type: 'POST',
@ -186,12 +183,11 @@ var editors = {
CodeMirror.commands.findUsages = function (cm) {
var cur = wide.curEditor.getCursor();
var request = {
file: wide.curNode.path,
code: wide.curEditor.getValue(),
cursorLine: cur.line,
cursorCh: cur.ch
};
var request = newWideRequest();
request.file = wide.curNode.path;
request.code = wide.curEditor.getValue();
request.cursorLine = cur.line;
request.cursorCh = cur.ch;
$.ajax({
type: 'POST',

View File

@ -69,10 +69,10 @@ var tree = {
return false;
}
var request = {
path: wide.curNode.path + '\\' + name,
fileType: "f"
};
var request = newWideRequest();
request.path = wide.curNode.path + '\\' + name;
request.fileType = "f";
$.ajax({
type: 'POST',
url: '/file/new',
@ -133,10 +133,10 @@ var tree = {
return false;
}
var request = {
path: wide.curNode.path + '\\' + name,
fileType: "d"
};
var request = newWideRequest();
request.path = wide.curNode.path + '\\' + name;
request.fileType = "d";
$.ajax({
type: 'POST',
url: '/file/new',
@ -161,9 +161,10 @@ var tree = {
if (!confirm("Remove it?")) {
return;
}
var request = {
path: wide.curNode.path
};
var request = newWideRequest();
request.path = wide.curNode.path;
$.ajax({
type: 'POST',
url: '/file/remove',
@ -197,9 +198,12 @@ var tree = {
});
},
init: function () {
var request = newWideRequest();
$.ajax({
type: 'GET',
type: 'POST',
url: '/files',
data: JSON.stringify(request),
dataType: "json",
success: function (data) {
if (data.succ) {
@ -256,9 +260,9 @@ var tree = {
wide.curNode = treeNode;
if ("ico-ztree-dir " !== treeNode.iconSkin) { // 如果单击了文件
var request = {
path: treeNode.path
};
var request = newWideRequest();
request.path = treeNode.path;
$.ajax({
type: 'POST',
url: '/file',

View File

@ -12,9 +12,8 @@ outputWS.onmessage = function(e) {
}
if ('run' === data.nextCmd) {
var request = {
executable: data.executable
};
var request = newWideRequest();
request.executable = data.executable;
$.ajax({
type: 'POST',
@ -100,10 +99,10 @@ var wide = {
},
saveFile: function () {
var request = {
file: $(".edit-header .current span:eq(0)").attr("title"),
code: wide.curEditor.getValue()
};
var request = newWideRequest();
request.file = $(".edit-header .current span:eq(0)").attr("title");
request.code = wide.curEditor.getValue();
$.ajax({
type: 'POST',
url: '/file/save',
@ -127,10 +126,9 @@ var wide = {
},
// 构建 & 运行.
run: function () {
var request = {
file: $(".edit-header .current span:eq(0)").attr("title"),
code: wide.curEditor.getValue()
};
var request = newWideRequest();
request.file = $(".edit-header .current span:eq(0)").attr("title");
request.code = wide.curEditor.getValue();
// TODO: 修改 [构建&运行] 图标状态为不可用状态
@ -147,9 +145,8 @@ var wide = {
});
},
goget: function () {
var request = {
file: $(".edit-header .current span:eq(0)").attr("title")
};
var request = newWideRequest();
request.file = $(".edit-header .current span:eq(0)").attr("title");
$.ajax({
type: 'POST',
@ -164,10 +161,9 @@ var wide = {
});
},
goinstall: function () {
var request = {
file: $(".edit-header .current span:eq(0)").attr("title"),
code: wide.curEditor.getValue()
};
var request = newWideRequest();
request.file = $(".edit-header .current span:eq(0)").attr("title");
request.code = wide.curEditor.getValue();
$.ajax({
type: 'POST',
@ -185,12 +181,11 @@ var wide = {
var path = $(".edit-header .current span:eq(0)").attr("title");
var mode = wide.curNode.mode;
var request = {
file: path,
code: wide.curEditor.getValue(),
cursorLine: wide.curEditor.getCursor().line,
cursorCh: wide.curEditor.getCursor().ch
};
var request = newWideRequest();
request.file = path;
request.code = wide.curEditor.getValue();
request.cursorLine = wide.curEditor.getCursor().line;
request.cursorCh = wide.curEditor.getCursor().ch;
switch (mode) {
case "text/x-go":

View File

@ -172,7 +172,17 @@
output: {{.conf.OutputChannel}}
},
wideSessionId: {{.session.Id}}
};</script>
};
// 发往 Wide 的所有 AJAX 请求需要使用该函数创建请求参数.
function newWideRequest() {
var ret = {
sid: config.wideSessionId
}
return ret;
}
</script>
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/reconnecting-websocket.js"></script>
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/ztree/jquery.ztree.all-3.5.min.js"></script>