This commit is contained in:
Liang Ding 2015-03-11 13:52:14 +08:00
parent 39f4a358c7
commit 1be7dc89e0
1 changed files with 15 additions and 15 deletions

View File

@ -18,7 +18,7 @@ var session = {
init: function () { init: function () {
this._initWS(); this._initWS();
// 定时30 秒)保存会话内容. // save session content per 30 seconds
setInterval(function () { setInterval(function () {
var request = newWideRequest(), var request = newWideRequest(),
filse = [], filse = [],
@ -35,9 +35,9 @@ var session = {
fileTree = tree.getOpenPaths(); fileTree = tree.getOpenPaths();
request.currentFile = currentFile; // 当前编辑器 request.currentFile = currentFile; // current editor file
request.fileTree = fileTree; // 文件树展开状态 request.fileTree = fileTree; // file tree expansion state
request.files = filse; // 编辑器打开状态 request.files = filse; // editor tabs
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
@ -66,7 +66,7 @@ var session = {
// expand tree // expand tree
for (var j = 0, jj = fileTree.length; j < jj; j++) { for (var j = 0, jj = fileTree.length; j < jj; j++) {
if (nodes[i].path === fileTree[j]) { if (nodes[i].path === fileTree[j]) {
// 当父节点都展开时,才展开该节点 // expand this node only if its parents are open
var parents = tree.getAllParents(tree.fileTree.getNodeByTId(nodes[i].tId)), var parents = tree.getAllParents(tree.fileTree.getNodeByTId(nodes[i].tId)),
isOpen = true; isOpen = true;
for (var l = 0, max = parents.length; l < max; l++) { for (var l = 0, max = parents.length; l < max; l++) {
@ -77,7 +77,7 @@ var session = {
if (isOpen) { if (isOpen) {
tree.fileTree.expandNode(nodes[i], true, false, true); tree.fileTree.expandNode(nodes[i], true, false, true);
} else { } else {
// 设置状态 // flag it is open
nodes[i].open = true; nodes[i].open = true;
} }
break; break;
@ -101,7 +101,7 @@ var session = {
} }
} }
// 处理编辑器打开顺序 // handle the open sequence of editors
for (var m = 0, mm = files.length; m < mm; m++) { for (var m = 0, mm = files.length; m < mm; m++) {
for (var n = 0, nn = nodesToOpen.length; n < nn; n++) { for (var n = 0, nn = nodesToOpen.length; n < nn; n++) {
if (nodesToOpen[n].path === files[m]) { if (nodesToOpen[n].path === files[m]) {
@ -111,7 +111,7 @@ var session = {
} }
} }
// 设置当前编辑器 // set the current editor
editors.tabs.setCurrent(id); editors.tabs.setCurrent(id);
for (var c = 0, max = editors.data.length; c < max; c++) { for (var c = 0, max = editors.data.length; c < max; c++) {
if (id === editors.data[c].id) { if (id === editors.data[c].id) {
@ -130,13 +130,13 @@ var session = {
var dateFormat = function (time, fmt) { var dateFormat = function (time, fmt) {
var date = new Date(time); var date = new Date(time);
var dateObj = { var dateObj = {
"M+": date.getMonth() + 1, //月份 "M+": date.getMonth() + 1,
"d+": date.getDate(), //日 "d+": date.getDate(),
"h+": date.getHours(), //小时 "h+": date.getHours(),
"m+": date.getMinutes(), //分 "m+": date.getMinutes(),
"s+": date.getSeconds(), //秒 "s+": date.getSeconds(),
"q+": Math.floor((date.getMonth() + 3) / 3), //季度 "q+": Math.floor((date.getMonth() + 3) / 3),
"S": date.getMilliseconds() //毫秒 "S": date.getMilliseconds()
}; };
if (/(y+)/.test(fmt)) if (/(y+)/.test(fmt))
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length)); fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));