This commit is contained in:
Liang Ding 2014-09-20 11:54:33 +08:00
parent 4b7fee14f4
commit 7d24c3adfa
9 changed files with 99 additions and 64 deletions

View File

@ -168,6 +168,11 @@ func NewFile(w http.ResponseWriter, r *http.Request) {
fileType := args["fileType"].(string)
if !createFile(path, fileType) {
if "f" == fileType {
extension := filepath.Ext(path)
data["mode"] = getEditorMode(extension)
}
data["succ"] = false
}
}

View File

@ -22,6 +22,7 @@
"goinstall": "go install",
"build_n_run": "构建 & 运行",
"full_screen": "全屏",
"unread_notification": "未读通知",
"notification_2": "没有检查到 gocode这将会导致 [自动完成] 失效",
"notification_3": "没有检查到 ide_stub这将会导致 [跳转到声明]、[查找使用] 失效"
}

View File

@ -77,9 +77,6 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
session.NotificationWS[sid] = &wsChan
ret := map[string]interface{}{"output": "Notification initialized", "cmd": "init-notification"}
wsChan.Conn.WriteJSON(&ret)
glog.V(4).Infof("Open a new [Notification] with session [%s], %d", sid, len(session.NotificationWS))
// 添加用户事件处理器
@ -100,14 +97,5 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
glog.Error("Notification WS ERROR: " + err.Error())
return
}
ret = map[string]interface{}{"output": "", "cmd": "notification-output"}
if err := wsChan.Conn.WriteJSON(&ret); err != nil {
glog.Error("Notification WS ERROR: " + err.Error())
return
}
wsChan.Time = time.Now()
}
}

View File

@ -234,7 +234,7 @@ ul {
}
/* end editor */
/* start output */
/* start bottom-window-group */
.bottom-window-group .tabs {
background-color: #CAD3E3;
border-top: 1px solid #8E97A7;
@ -245,13 +245,39 @@ ul {
cursor: pointer;
}
.bottom-window-group .tabs-panel {
height: 133px;
}
.bottom-window-group textarea {
border-width: 0;
color: #555555;
height: 130px;
width: 100%;
}
/* end output */
.bottom-window-group .notification,
.bottom-window-group .search,
.bottom-window-group .output {
height: 133px;
overflow: auto;
}
.bottom-window-group .notification > table {
width: 100%;
}
.bottom-window-group .notification td {
border-bottom: 1px solid #DDD;
line-height: 20px;
}
.bottom-window-group .notification .type,
.bottom-window-group .notification .severity {
width: 50px;
padding: 0 5px;
}
/* end bottom-window-group */
/* start footer */
.notification-count {

View File

@ -267,6 +267,9 @@ var editors = {
"Ctrl-S": function () {
wide.saveFile();
},
"Shift-Ctrl-S": function () {
wide.saveAllFiles();
},
"Shift-Alt-F": function () {
wide.fmt();
},

View File

@ -16,12 +16,16 @@ var notification = {
};
notificationWS.onmessage = function (e) {
var data = JSON.parse(e.data);
if ('init-notification' !== data.cmd) {
var data = JSON.parse(e.data),
$notification = $('.bottom-window-group .notification > table'),
notificationHTML = '';
notificationHTML += '<tr><td class="severity">' + data.severity
+ '</td><td class="message">' + data.message
+ '</td><td class="type">' + data.type + '</td></tr>';
$notification.append(notificationHTML);
$(".notification-count").show();
$('.bottom-window-group .notification').text(
$('.bottom-window-group .notification').text() + data.output);
}
};
notificationWS.onclose = function (e) {

View File

@ -121,7 +121,8 @@ var tree = {
tree.fileTree.addNodes(wide.curNode, [{
"name": name,
"iconSkin": iconSkin,
"path": request.path
"path": request.path,
"mode": data.mode
}]);
}
});

View File

@ -102,7 +102,7 @@ var wide = {
});
},
saveFile: function() {
_save: function () {
var request = newWideRequest();
request.file = $(".edit-header .current span:eq(0)").attr("title");
request.code = wide.curEditor.getValue();
@ -116,8 +116,13 @@ var wide = {
}
});
},
saveFile: function () {
// 格式化后会对文件进行保存
this.fmt();
},
saveAllFiles: function () {
// TODO: save all files
console.log("TODO: ssave all files");
},
closeFile: function () {
// TODO: close file
@ -192,7 +197,7 @@ var wide = {
request.cursorCh = wide.curEditor.getCursor().ch;
switch (mode) {
case "text/x-go":
case "text/x-go": // 会保存文件
$.ajax({
type: 'POST',
url: '/go/fmt',
@ -206,7 +211,7 @@ var wide = {
});
break;
case "text/html":
case "text/html": // 会保存文件
$.ajax({
type: 'POST',
url: '/html/fmt',
@ -226,7 +231,7 @@ var wide = {
var json = JSON.parse(wide.curEditor.getValue());
wide.curEditor.setValue(JSON.stringify(json, "", " "));
this.save();
wide._save();
} catch (e) {
delete e;
}
@ -234,6 +239,8 @@ var wide = {
break;
default :
// TODO: XML 格式化处理
// 所有文件格式化后都需要进行保存
wide._save();
break;
}
}

View File

@ -153,7 +153,7 @@
<div class="search" tabindex="-1"></div>
</div>
<div class="fn-none" data-index="notification">
<textarea class="notification"></textarea>
<div tabindex="-1" class="notification"><table cellpadding="0" cellspacing="0"></table></div>
</div>
</div>
</div>
@ -163,7 +163,7 @@
<div class="footer">
<span>|</span>
<span id="footer-cursor" style="float: right;"></span>
<span class="notification-count" title="you have unread notification">N</span>
<span class="notification-count" title="{{.i18n.unread_notification}}">Noty</span>
</div>
<script type="text/javascript">