This commit is contained in:
Liang Ding 2015-09-27 14:29:26 +08:00
parent f4693a6eee
commit ac579ab769
5 changed files with 22 additions and 37 deletions

View File

@ -13,7 +13,7 @@
"Keymap": "wide",
"Created": 1414080000000000000,
"Updated": 1414080000000000000,
"Lived": 1443322949749873692,
"Lived": 1414080000000000000,
"Editor": {
"FontFamily": "Consolas, 'Courier New', monospace",
"FontSize": "13px",
@ -22,12 +22,8 @@
"TabSize": "4"
},
"LatestSessionContent": {
"FileTree": [
"/Users/Vanessa/Work/GoGoGo/src"
],
"Files": [
"/Users/Vanessa/Work/GoGoGo/src/1.css"
],
"FileTree": [],
"Files": [],
"CurrentFile": "",
"FileTreeLayout": null,
"EditorLayout": null,

View File

@ -452,8 +452,8 @@ func (sessions *wSessions) new(httpSession *sessions.Session, sid string) *WideS
select {
case event := <-watcher.Events:
path := event.Name
dir := filepath.Dir(path)
path := filepath.ToSlash(event.Name)
dir := filepath.ToSlash(filepath.Dir(path))
ch = SessionWS[sid]
if nil == ch {
@ -467,14 +467,23 @@ func (sessions *wSessions) new(httpSession *sessions.Session, sid string) *WideS
logger.Warn(err, path)
}
cmd := map[string]interface{}{"path": path, "dir": dir, "cmd": "create-file"}
fileType := "f"
if util.File.IsDir(path) {
fileType = "d"
}
cmd := map[string]interface{}{"path": path, "dir": dir,
"cmd": "create-file", "type": fileType}
ch.WriteJSON(&cmd)
} else if event.Op&fsnotify.Remove == fsnotify.Remove {
cmd := map[string]interface{}{"path": path, "dir": dir, "cmd": "remove-file"}
cmd := map[string]interface{}{"path": path, "dir": dir,
"cmd": "remove-file", "type": ""}
ch.WriteJSON(&cmd)
} else if event.Op&fsnotify.Rename == fsnotify.Rename {
cmd := map[string]interface{}{"path": path, "dir": dir, "cmd": "rename-file"}
cmd := map[string]interface{}{"path": path, "dir": dir,
"cmd": "rename-file", "type": ""}
ch.WriteJSON(&cmd)
}
case err := <-watcher.Errors:

View File

@ -170,7 +170,7 @@ var session = {
mode = CodeMirror.findModeByFileName(name),
iconSkin = wide.getClassBySuffix(name.split(".")[1]);
if (data.type && data.type === 'file') {
if (data.type && data.type === 'f') {
tree.fileTree.addNodes(dirNode, [{
"name": name,
"iconSkin": iconSkin,
@ -193,7 +193,8 @@ var session = {
break;
case 'remove-file':
var dirNode = tree.fileTree.getNodeByTId(tree.getTIdByPath(data.dir));
case 'rename-file':
var dirNode = tree.fileTree.getNodeByTId(tree.getTIdByPath(data.path));
tree.fileTree.removeNode(dirNode);
break;
}

View File

@ -525,7 +525,7 @@ var tree = {
request = newWideRequest();
request.oldPath = wide.curNode.path;
request.newPath = wide.curNode.path.substring(0, wide.curNode.path.lastIndexOf("/")) + name;
request.newPath = wide.curNode.path.substring(0, wide.curNode.path.lastIndexOf("/") +1) + name;
$.ajax({
type: 'POST',

View File

@ -180,20 +180,8 @@ var wide = {
$(".bottom-window-group .notification").focus();
return false;
}
var mode = CodeMirror.findModeByFileName(name);
$("#dialogNewFilePrompt").dialog("close");
var iconSkin = wide.getClassBySuffix(name.split(".")[1]);
tree.fileTree.addNodes(wide.curNode, [{
"name": name,
"iconSkin": iconSkin,
"path": request.path,
"mode": mode,
"removable": true,
"creatable": true
}]);
}
});
}
@ -232,15 +220,6 @@ var wide = {
}
$("#dialogNewDirPrompt").dialog("close");
tree.fileTree.addNodes(wide.curNode, [{
"name": name,
"iconSkin": "ico-ztree-dir ",
"path": request.path,
"removable": true,
"creatable": true,
"isParent": true
}]);
}
});
}