mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-15 23:55:50 +00:00
save/recover state
This commit is contained in:
17
node_modules/common.js
generated
vendored
17
node_modules/common.js
generated
vendored
@@ -124,6 +124,23 @@ var Common = {
|
||||
ret.nameNotExt = ret.name;
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
// 2014-01-06T18:29:48.802+08:00
|
||||
goNowToDate: function (goNow) {
|
||||
if(!goNow) {
|
||||
return new Date();
|
||||
}
|
||||
// new Date();
|
||||
if(typeof goNow == 'object') {
|
||||
alert(3);
|
||||
return date;
|
||||
}
|
||||
var str = goNow.substr(0, 10) + " " + goNow.substr(11, 8);
|
||||
try {
|
||||
return new Date(str);
|
||||
} catch(e) {
|
||||
return new Date();
|
||||
}
|
||||
}
|
||||
};
|
||||
module.exports = Common;
|
||||
|
7
node_modules/evt.js
generated
vendored
7
node_modules/evt.js
generated
vendored
@@ -26,6 +26,9 @@ var Evt = {
|
||||
getAttachLocalUrl: function(fileId) {
|
||||
return this.localUrl + '/api/file/getAttach?fileId=' + fileId;
|
||||
},
|
||||
getAllAttachLocalUrl: function(noteId) {
|
||||
return this.localUrl + '/api/file/getAllAttachs?noteId=' + noteId;
|
||||
},
|
||||
// 项目绝对地址
|
||||
getBasePath: function() {
|
||||
var me = this;
|
||||
@@ -39,8 +42,8 @@ var Evt = {
|
||||
},
|
||||
setDataBasePath: function(dataBasePath) {
|
||||
var me = this;
|
||||
console.log('...........')
|
||||
console.log(dataBasePath);
|
||||
// console.log('...........')
|
||||
// console.log(dataBasePath);
|
||||
me.dataBasePath = dataBasePath;
|
||||
}
|
||||
};
|
||||
|
23
node_modules/note.js
generated
vendored
23
node_modules/note.js
generated
vendored
@@ -365,8 +365,9 @@ var Note = {
|
||||
var reg2 = new RegExp(Evt.leanoteUrl + '/api/file/getAttach', 'g');
|
||||
content = content.replace(reg2, Evt.localUrl + '/api/file/getAttach');
|
||||
|
||||
var reg3 = new RegExp(Evt.leanoteUrl + '/api/file/getAllAttach', 'g');
|
||||
content = content.replace(reg3, Evt.localUrl + '/api/file/getAllAttach');
|
||||
// api/file/getAllAttachs?noteId=xxxxxxxxx, 这里的noteId是服务器上的noteId啊
|
||||
var reg3 = new RegExp(Evt.leanoteUrl + '/api/file/getAllAttachs', 'g');
|
||||
content = content.replace(reg3, Evt.localUrl + '/api/file/getAllAttachs');
|
||||
|
||||
return content;
|
||||
},
|
||||
@@ -384,8 +385,8 @@ var Note = {
|
||||
var reg2 = new RegExp(Evt.localUrl + '/api/file/getAttach', 'g');
|
||||
content = content.replace(reg2, Evt.leanoteUrl + '/api/file/getAttach');
|
||||
|
||||
var reg3 = new RegExp(Evt.localUrl + '/api/file/getAllAttach', 'g');
|
||||
content = content.replace(reg3, Evt.leanoteUrl + '/api/file/getAllAttach');
|
||||
var reg3 = new RegExp(Evt.localUrl + '/api/file/getAllAttachs', 'g');
|
||||
content = content.replace(reg3, Evt.leanoteUrl + '/api/file/getAllAttachs');
|
||||
|
||||
return content;
|
||||
},
|
||||
@@ -546,6 +547,10 @@ var Note = {
|
||||
note.NoteId = Common.objectId();
|
||||
note.LocalIsDelete = false;
|
||||
|
||||
console.error('add note' + note.Title + Common.goNowToDate(note.CreatedTime));
|
||||
note.CreatedTime = Common.goNowToDate(note.CreatedTime);
|
||||
note.UpdatedTime = Common.goNowToDate(note.UpdatedTime);
|
||||
|
||||
// 附件操作
|
||||
var files = note.Files || [];
|
||||
var attachs = [];
|
||||
@@ -567,6 +572,9 @@ var Note = {
|
||||
console.log(err);
|
||||
callback && callback(false);
|
||||
} else {
|
||||
// console.log("?????????")
|
||||
// console.log(note);
|
||||
// console.log(note.CreatedTime);
|
||||
callback && callback(newDoc);
|
||||
|
||||
// 下载内容, 图片, 附件
|
||||
@@ -660,6 +668,10 @@ var Note = {
|
||||
console.log(everNote.NoteId);
|
||||
console.log(everNote);
|
||||
|
||||
// 不要服务器上的
|
||||
delete note['UpdatedTime'];
|
||||
delete note['CreatedTime'];
|
||||
|
||||
Notes.update({NoteId: note.NoteId}, {$set: note}, {}, function (err, cnt) { // Callback is optional
|
||||
console.log('re:');
|
||||
console.log(err);
|
||||
@@ -740,6 +752,8 @@ var Note = {
|
||||
console.log(everAttachs);
|
||||
|
||||
delete note['Files'];
|
||||
delete note['UpdatedTime'];
|
||||
delete note['CreatedTime'];
|
||||
|
||||
Notes.update({NoteId: note.NoteId}, {$set: note}, function(err, n) {
|
||||
if(err || !n) {
|
||||
@@ -991,7 +1005,6 @@ var Note = {
|
||||
});
|
||||
|
||||
})(i);
|
||||
|
||||
}
|
||||
|
||||
// 服务器没有, 但是是发送更新的, 所以需要作为添加以后再send changes
|
||||
|
4
node_modules/notebook.js
generated
vendored
4
node_modules/notebook.js
generated
vendored
@@ -278,6 +278,10 @@ var Notebook = {
|
||||
} else {
|
||||
// 否则, 就用服务器上的
|
||||
}
|
||||
|
||||
notebook.CreatedTime = Common.goNowToDate(notebook.CreatedTime);
|
||||
notebook.UpdatedTime = Common.goNowToDate(notebook.UpdatedTime);
|
||||
|
||||
NB.insert(notebook, function (err, newDoc) { // Callback is optional
|
||||
if(err) {
|
||||
console.log(err);
|
||||
|
20
node_modules/user.js
generated
vendored
20
node_modules/user.js
generated
vendored
@@ -227,6 +227,26 @@ User = {
|
||||
db.g.update({_id: '1'}, {$set: data}, {upsert: true}, function() {
|
||||
callback && callback();
|
||||
});
|
||||
},
|
||||
/**
|
||||
* [saveCurState description]
|
||||
* @param {[type]} state [description]
|
||||
* @return {[type]} [description]
|
||||
User.saveCurState({
|
||||
StarredOpened: StarredOpened,
|
||||
NotebookOpened: NotebookOpened,
|
||||
TagOpened: TagOpened,
|
||||
CurNoteId: CurNoteId,
|
||||
CurIsStarred: CurIsStarred,
|
||||
CurNotebookId: CurNotebookId,
|
||||
CurTag: CurTag
|
||||
}, callback);
|
||||
*/
|
||||
saveCurState: function(state, callback) {
|
||||
state = state || {};
|
||||
db.g.update({_id: '1'}, {$set: state}, {upsert: true}, function() {
|
||||
callback && callback();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -106,7 +106,7 @@ function log(o) {
|
||||
<a class="tool-max"></a>
|
||||
</div>
|
||||
|
||||
<div class="folderNote closed" id="myShareNotebooks">
|
||||
<div class="folderNote closed" id="myStarredNotes">
|
||||
<div class="folderHeader">
|
||||
<i class="fa fa-star-o fa-left"></i>
|
||||
<span>
|
||||
@@ -346,14 +346,19 @@ function log(o) {
|
||||
<i class="fa fa-upload"></i>
|
||||
<span>Choose Files</span>
|
||||
</a>
|
||||
<!--
|
||||
<a class="btn btn-default" id="downloadAllBtn">
|
||||
<i class="fa fa-download"></i>
|
||||
<span>Download All</span>
|
||||
</a>
|
||||
-->
|
||||
<!--
|
||||
因为noteId与serverNoteId的原因, 暂不支持
|
||||
<a class="btn btn-default" id="linkAllBtn">
|
||||
<i class="fa fa-link"></i>
|
||||
<span>Link All</span>
|
||||
</a>
|
||||
-->
|
||||
</div>
|
||||
<div id="attachUploadMsg">
|
||||
</div>
|
||||
|
@@ -6,8 +6,8 @@
|
||||
"window": {
|
||||
"toolbar": true,
|
||||
|
||||
"frame": false,
|
||||
"transparent": true,
|
||||
"frame": true,
|
||||
"transparent": false,
|
||||
|
||||
"min_width": 400,
|
||||
"min_height": 200,
|
||||
|
@@ -201,7 +201,31 @@ Note.renderNotesAndFirstOneContent = function(ret) {
|
||||
Note.changeNoteForPjax(ret[0].NoteId, true, false);
|
||||
} else {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 渲染并定位到特定的
|
||||
Note.renderNotesAndTargetNote = function(ret, noteId) {
|
||||
// 错误的ret是一个Object
|
||||
if(!isArray(ret)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// note 导航
|
||||
Note.renderNotes(ret);
|
||||
// 渲染特定的
|
||||
if(!isEmpty(ret[0])) {
|
||||
if(noteId) {
|
||||
// Note.changeNoteForPjax(noteId, true, false);
|
||||
Note.changeNoteForPjax(noteId, true, false);
|
||||
if(!Note.directToNote(noteId)) {
|
||||
// 找不到啊
|
||||
Note.changeNoteForPjax(ret[0].NoteId, true, false);
|
||||
}
|
||||
} else {
|
||||
Note.changeNoteForPjax(ret[0].NoteId, true, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 当前的note是否改变过了?
|
||||
// 返回已改变的信息
|
||||
@@ -428,7 +452,7 @@ Note.curChangedSaveIt = function(force, callback) {
|
||||
Note.setNoteCache(hasChanged, false);
|
||||
|
||||
// 设置更新时间
|
||||
Note.setNoteCache({"NoteId": hasChanged.NoteId, "UpdatedTime": (new Date()).format("yyyy-MM-ddThh:mm:ss.S")}, false);
|
||||
Note.setNoteCache({"NoteId": hasChanged.NoteId, "UpdatedTime": new Date()}, false);
|
||||
|
||||
// 表示有未完成的保存
|
||||
/*
|
||||
@@ -445,7 +469,7 @@ Note.curChangedSaveIt = function(force, callback) {
|
||||
|
||||
me.saveInProcess[hasChanged.NoteId] = true;
|
||||
|
||||
console.error('保存当前的笔记: ' + hasChanged.NoteId);
|
||||
// console.error('保存当前的笔记: ' + hasChanged.NoteId);
|
||||
|
||||
NoteService.updateNoteOrContent(hasChanged, function(ret) {
|
||||
me.saveInProcess[hasChanged.NoteId] = false;
|
||||
@@ -524,13 +548,19 @@ Note.hideContentLoading = function() {
|
||||
$("#noteMaskForLoading").css("z-index", -1);
|
||||
};
|
||||
|
||||
// 定位到笔记
|
||||
Note.directToNote = function(noteId) {
|
||||
var $p = $("#noteItemList");
|
||||
var pHeight = $p.height();
|
||||
// 相对于父亲的位置
|
||||
var pTop = $("[noteId='" + noteId + "']").position().top;
|
||||
var $t = $("[noteId='" + noteId + "']");
|
||||
if($t.length == 0) {
|
||||
return false;
|
||||
}
|
||||
// position方法返回的是元素的在页面内的绝对位置信息,top和left
|
||||
var pTop = $t.position().top;
|
||||
var scrollTop = $p.scrollTop();
|
||||
pTop += scrollTop;
|
||||
pTop += scrollTop + 66; // 66是上面的title, search
|
||||
/*
|
||||
log("..");
|
||||
log(noteId);
|
||||
@@ -539,16 +569,13 @@ Note.directToNote = function(noteId) {
|
||||
|
||||
// 当前的可视范围的元素位置是[scrollTop, pHeight + scrollTop]
|
||||
if(pTop >= scrollTop && pTop <= pHeight + scrollTop) {
|
||||
// alert(pTop + ' ' + scrollTop + ' ' + pHeight)
|
||||
} else {
|
||||
var top = pTop;
|
||||
log("定位到特定note, 在可视范围内");
|
||||
// 手机不用slimScroll
|
||||
if(!LEA.isMobile && !Mobile.isMobile()) {
|
||||
$("#noteItemList").scrollTop(top);
|
||||
// $("#noteItemList").slimScroll({ scrollTo: top + 'px', height: "100%", onlyScrollBar: true});
|
||||
} else {
|
||||
}
|
||||
console.log("定位到特定note, 在可视范围内");
|
||||
$("#noteItemList").scrollTop(top - 66);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
// mustPush表示是否将状态push到state中, 默认为true
|
||||
@@ -997,7 +1024,16 @@ Note.newNote = function(notebookId, isShare, fromUserId, isMarkdown) {
|
||||
// 保存当前的笔记
|
||||
Note.curChangedSaveIt();
|
||||
|
||||
var note = {NoteId: getObjectId(), Title: "", Tags:[], Content:"", NotebookId: notebookId, IsNew: true, FromUserId: fromUserId, IsMarkdown: isMarkdown}; // 是新的
|
||||
var note = {NoteId: getObjectId(),
|
||||
Title: "H",
|
||||
Tags:[], Content:"",
|
||||
NotebookId: notebookId,
|
||||
IsNew: true,
|
||||
FromUserId: fromUserId,
|
||||
IsMarkdown: isMarkdown,
|
||||
CreatedTime: new Date(),
|
||||
UpdatedTime: new Date()}; // 是新的
|
||||
|
||||
// 添加到缓存中
|
||||
Note.addNoteCache(note);
|
||||
|
||||
@@ -1429,6 +1465,29 @@ Note.isSameSearch = function(key) {
|
||||
|
||||
// 搜索笔记
|
||||
Note.searchSeq = 0;
|
||||
|
||||
// for recoverState
|
||||
Note.searchNoteSys = function(val, noteId) {
|
||||
$("#searchNoteInput").val(val);
|
||||
var me = this;
|
||||
NoteService.searchNote(val, function(notes) {
|
||||
if(notes) {
|
||||
Note.searchKey = val;
|
||||
Notebook.changeCurNotebookTitle('Search results', false, notes.length, false, true);
|
||||
Note.renderNotes(notes);
|
||||
// markdown一旦setContent就focus, 导致搜索失去焦点
|
||||
setTimeout(function() {
|
||||
$("#searchNoteInput").focus();
|
||||
})
|
||||
if(!isEmpty(notes)) {
|
||||
Note.renderNotesAndTargetNote(notes, noteId);
|
||||
}
|
||||
} else {
|
||||
// abort的
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Note.searchNote = function() {
|
||||
var val = $("#searchNoteInput").val();
|
||||
if(!val) {
|
||||
@@ -1462,7 +1521,8 @@ Note.searchNote = function() {
|
||||
NoteService.searchNote(val, function(notes) {
|
||||
hideLoading();
|
||||
if(t == Note.searchSeq && notes) {
|
||||
Notebook.changeCurNotebookTitle('Search results', false, notes.length);
|
||||
Note.searchKey = val;
|
||||
Notebook.changeCurNotebookTitle('Search results', false, notes.length, false, true);
|
||||
Note.renderNotes(notes);
|
||||
// markdown一旦setContent就focus, 导致搜索失去焦点
|
||||
setTimeout(function() {
|
||||
@@ -2158,6 +2218,8 @@ var Attach = {
|
||||
var attachId = $(this).closest('li').data("id");
|
||||
var attach = self.attachsMap[attachId];
|
||||
var src = EvtService.getAttachLocalUrl(attachId); // + "/attach/download?attachId=" + attachId;
|
||||
// http://leanote.com/attach/download?attachId=54f7481638f4112ff000170f
|
||||
|
||||
if(LEA.isMarkdownEditor() && MD) {
|
||||
MD.insertLink(src, attach.Title);
|
||||
} else {
|
||||
@@ -2167,12 +2229,15 @@ var Attach = {
|
||||
|
||||
// make all link
|
||||
self.linkAllBtnO.on("click",function(e) {
|
||||
// 暂不支持
|
||||
return;
|
||||
e.stopPropagation();
|
||||
var note = Note.getCurNote();
|
||||
if(!note) {
|
||||
return;
|
||||
}
|
||||
var src = UrlPrefix + "/attach/downloadAll?noteId=" + Note.curNoteId
|
||||
var src = EvtService.getAllAttachLocalUrl(note.NoteId); // UrlPrefix + "/attach/downloadAll?noteId=" + Note.curNoteId
|
||||
// src = 'http://leanote.com/attach/downloadAll?noteId=' + note.NoteId;
|
||||
var title = note.Title ? note.Title + ".tar.gz" : "all.tar.gz";
|
||||
|
||||
if(LEA.isMarkdownEditor() && MD) {
|
||||
|
@@ -638,7 +638,7 @@ Notebook.curActiveNotebookIsAll = function() {
|
||||
// 3. 使用Note.RederNotes()
|
||||
// callback Pjax, 当popstate时调用
|
||||
Notebook.changeNotebookSeq = 1;
|
||||
Notebook.changeNotebook = function(notebookId, callback) {
|
||||
Notebook.changeNotebook = function(notebookId, callback, needRendNoteId) {
|
||||
var me = this;
|
||||
Notebook.changeNotebookNav(notebookId);
|
||||
|
||||
@@ -666,7 +666,7 @@ Notebook.changeNotebook = function(notebookId, callback) {
|
||||
if(callback) {
|
||||
callback(cacheNotes);
|
||||
} else {
|
||||
Note.renderNotesAndFirstOneContent(cacheNotes);
|
||||
Note.renderNotesAndTargetNote(cacheNotes, needRendNoteId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -680,7 +680,7 @@ Notebook.changeNotebook = function(notebookId, callback) {
|
||||
if(callback) {
|
||||
callback(cacheNotes);
|
||||
} else {
|
||||
Note.renderNotesAndFirstOneContent(cacheNotes);
|
||||
Note.renderNotesAndTargetNote(cacheNotes, needRendNoteId);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
@@ -705,7 +705,7 @@ Notebook.changeNotebook = function(notebookId, callback) {
|
||||
if(callback) {
|
||||
callback(cacheNotes);
|
||||
} else {
|
||||
Note.renderNotesAndFirstOneContent(cacheNotes);
|
||||
Note.renderNotesAndTargetNote(cacheNotes, needRendNoteId);
|
||||
}
|
||||
me.hideNoteAndEditorLoading();
|
||||
};
|
||||
@@ -719,10 +719,12 @@ Notebook.changeNotebook = function(notebookId, callback) {
|
||||
};
|
||||
|
||||
// 改变标签, isStarred是否是星笔记本
|
||||
Notebook.changeCurNotebookTitle = function(title, isStarred, subTitle) {
|
||||
Notebook.changeCurNotebookTitle = function(title, isStarred, subTitle, isTag, isSearch) {
|
||||
var me = this;
|
||||
$("#curNotebookForListNote").html(title);
|
||||
me.isStarred = isStarred;
|
||||
me.isTag = isTag;
|
||||
me.isSearch = isSearch;
|
||||
};
|
||||
|
||||
// 笔记列表与编辑器的mask loading
|
||||
|
@@ -1315,19 +1315,120 @@ function incrSync() {
|
||||
SyncService.incrSync();
|
||||
}
|
||||
|
||||
// 历史, 恢复原貌
|
||||
var State = {
|
||||
// 保存当前状态
|
||||
// 什么时候调用? 关闭程序, 改变note时
|
||||
saveCurState: function(callback) {
|
||||
// 左侧, 开闭状态
|
||||
var StarredOpened = false;
|
||||
var NotebookOpened = false;
|
||||
var TagOpened = false;
|
||||
var $leftOpen = $('.folderNote.opened');
|
||||
if($leftOpen.length == 1) {
|
||||
var id = $leftOpen.attr('id');
|
||||
if(id == 'myStarredNotes') {
|
||||
StarredOpened = true;
|
||||
} else if(id == 'myNotebooks') {
|
||||
NotebookOpened = true;
|
||||
} else if(id == 'myTag') {
|
||||
TagOpened = true;
|
||||
}
|
||||
}
|
||||
// 当前笔记
|
||||
var CurNoteId = Note.curNoteId; // 当前打开的笔记
|
||||
var CurIsStarred = false; // 当前是在星下
|
||||
var CurNotebookId = ''; // 定位到某个笔记本
|
||||
var CurTag = ''; // 搜索tag
|
||||
if(Notebook.isSearch) {
|
||||
var CurSearchKey = Note.searchKey;
|
||||
}
|
||||
if(Notebook.isStarred) {
|
||||
CurIsStarred = true;
|
||||
} else if(Notebook.isTag) {
|
||||
CurTag = Tag.curTag;
|
||||
}
|
||||
CurNotebookId = Notebook.curNotebookId;
|
||||
|
||||
var state = {
|
||||
StarredOpened: StarredOpened,
|
||||
NotebookOpened: NotebookOpened,
|
||||
TagOpened: TagOpened,
|
||||
|
||||
CurNoteId: CurNoteId,
|
||||
CurIsStarred: CurIsStarred,
|
||||
CurNotebookId: CurNotebookId,
|
||||
CurTag: CurTag,
|
||||
CurSearchKey: CurSearchKey
|
||||
};
|
||||
console.log(state);
|
||||
UserService.saveCurState(state, callback);
|
||||
},
|
||||
|
||||
// 恢复状态
|
||||
recoverState: function(state) {
|
||||
console.log(state);
|
||||
// 1. 左侧哪个open
|
||||
if(!state.NotebookOpened) {
|
||||
$('.folderNote.opened').removeClass('opened').addClass('closed');
|
||||
if(state.StarredOpened) {
|
||||
$('#myStarredNotes').removeClass('closed').addClass('opened');
|
||||
} else if(state.TagOpened) {
|
||||
$('#myTag').removeClass('closed').addClass('opened');
|
||||
}
|
||||
}
|
||||
// 2.
|
||||
// 当前是starred notes
|
||||
var notebookId = state.CurNotebookId;
|
||||
if(state.CurIsStarred) {
|
||||
Note.renderStarNote($('#myStarredNotes li[data-id="' + state.CurNoteId + '"]'));
|
||||
}
|
||||
// 搜索标签
|
||||
else if(state.CurTag) {
|
||||
Tag.searchTag(state.CurTag, state.CurNoteId);
|
||||
}
|
||||
// 搜索笔记
|
||||
else if(state.CurSearchKey) {
|
||||
Note.searchNoteSys(state.CurSearchKey, state.CurNoteId);
|
||||
}
|
||||
// 笔记本了
|
||||
else {
|
||||
Notebook.expandNotebookTo(notebookId);
|
||||
Notebook.changeNotebook(notebookId, false, state.CurNoteId);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// note.html调用
|
||||
// 实始化页面
|
||||
// 判断是否登录
|
||||
function initPage() {
|
||||
win.on('close', function() {
|
||||
State.saveCurState(function() {
|
||||
win.close(true);
|
||||
});
|
||||
});
|
||||
|
||||
// 注入前端变量#
|
||||
WebService.set(Notebook, Note, Attach, Tag);
|
||||
|
||||
// 在显示notebooks, stars, tags后才recoverState
|
||||
var i = 0;
|
||||
function ok() {
|
||||
i++;
|
||||
if(i == 3) {
|
||||
State.recoverState(UserInfo);
|
||||
}
|
||||
}
|
||||
|
||||
function _init() {
|
||||
$(function() {
|
||||
// 获取笔记本
|
||||
Service.notebookService.getNotebooks(function(notebooks) {
|
||||
log(notebooks);
|
||||
Notebook.renderNotebooks(notebooks);
|
||||
ok();
|
||||
});
|
||||
|
||||
// 获得笔记
|
||||
@@ -1340,6 +1441,7 @@ function initPage() {
|
||||
// 获取star笔记
|
||||
NoteService.getStarNotes(function(notes) {
|
||||
Note.renderStars(notes);
|
||||
ok();
|
||||
});
|
||||
|
||||
// 指定笔记, 也要保存最新笔记
|
||||
@@ -1352,6 +1454,7 @@ function initPage() {
|
||||
// 标签
|
||||
TagService.getTags(function(tags) {
|
||||
Tag.renderTagNav(tags);
|
||||
ok();
|
||||
});
|
||||
|
||||
// init notebook后才调用
|
||||
@@ -1506,6 +1609,7 @@ function userMenu() {
|
||||
changeTheme(UserInfo.Theme);
|
||||
}
|
||||
|
||||
|
||||
$(function() {
|
||||
initUploadImage();
|
||||
userMenu();
|
||||
|
@@ -79,10 +79,7 @@ $(function() {
|
||||
|
||||
// bind close event
|
||||
// 保存当前打开的笔记
|
||||
win.on('close', function() {
|
||||
// TODO
|
||||
win.close(true);
|
||||
});
|
||||
|
||||
win.on('focus', function() {
|
||||
console.log('window is focused ');
|
||||
});
|
||||
|
@@ -281,6 +281,40 @@ Tag.addTagNav = function(newTag) {
|
||||
me.renderTagNav(me.tags);
|
||||
};
|
||||
|
||||
Tag.searchTag = function(tag, noteId) {
|
||||
// var $li = $(this).closest('li');
|
||||
// var tag = $.trim($li.data("tag"));
|
||||
// tag = Tag.mapCn2En[tag] || tag;
|
||||
|
||||
// 学习changeNotebook
|
||||
|
||||
// 1
|
||||
Note.curChangedSaveIt();
|
||||
|
||||
// 2 先清空所有
|
||||
// 也会把curNoteId清空
|
||||
Note.clearAll();
|
||||
|
||||
// $("#tagSearch").html($li.html()).show();
|
||||
|
||||
Notebook.changeCurNotebookTitle(tag, false, '', true);
|
||||
Tag.curTag = tag;
|
||||
// $('#curNotebookForListNote').find('i, em').remove();
|
||||
// $("#tagSearch .tag-delete").remove();
|
||||
|
||||
NoteService.searchNoteByTag(tag, function(notes) {
|
||||
hideLoading();
|
||||
if(notes) {
|
||||
// 和note搜索一样
|
||||
// 设空, 防止发生上述情况
|
||||
// Note.curNoteId = "";
|
||||
Note.renderNotes(notes);
|
||||
Note.renderNotesAndTargetNote(notes, noteId);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// 事件
|
||||
$(function() {
|
||||
// tag
|
||||
@@ -365,6 +399,10 @@ $(function() {
|
||||
function searchTag() {
|
||||
var $li = $(this).closest('li');
|
||||
var tag = $.trim($li.data("tag"));
|
||||
|
||||
Tag.searchTag(tag);
|
||||
/*
|
||||
|
||||
// tag = Tag.mapCn2En[tag] || tag;
|
||||
|
||||
// 学习changeNotebook
|
||||
@@ -379,7 +417,8 @@ $(function() {
|
||||
// $("#tagSearch").html($li.html()).show();
|
||||
|
||||
var h = $li.html();
|
||||
Notebook.changeCurNotebookTitle(h);
|
||||
Notebook.changeCurNotebookTitle(h, false, '', true);
|
||||
Tag.curTag = h;
|
||||
$('#curNotebookForListNote').find('i, em').remove();
|
||||
// $("#tagSearch .tag-delete").remove();
|
||||
|
||||
@@ -396,7 +435,9 @@ $(function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
$("#myTag .folderBody").on("click", "li .label", searchTag);
|
||||
// $("#minTagNav").on("click", "li", searchTag);
|
||||
|
||||
|
15
test.js
15
test.js
@@ -6,6 +6,7 @@ var Api = require('api');
|
||||
var User = require('user');
|
||||
var Server = require('server');
|
||||
var Evt = require('evt');
|
||||
var Common = require('common');
|
||||
|
||||
/*
|
||||
Notebook.addNotebook("1", "life");
|
||||
@@ -20,7 +21,7 @@ Api.addNotebook({
|
||||
// Api.uploadImage();
|
||||
User.userId = '54bdc65599c37b0da9000002';
|
||||
User.userId = '54d7620d99c37b030600002c';
|
||||
User.userId = '54f08a1699c37b877b0001ee';
|
||||
User.userId = '54f6e72899c37b6e20000044';
|
||||
|
||||
// 54d7624205fcd105da00005
|
||||
|
||||
@@ -37,12 +38,11 @@ User.init(function() {
|
||||
*/
|
||||
|
||||
|
||||
Note.getNoteByServerNoteId('54f1a1f899c37b4faf000001', function(note) {
|
||||
console.log(note);
|
||||
});
|
||||
// Note.getNoteByServerNoteId('54f1a1f899c37b4faf000001', function(note) {
|
||||
// console.log(note);
|
||||
// });
|
||||
|
||||
Note.getDirtyNotes(function(ret) {
|
||||
console.log('getDirtyNotes: ');
|
||||
Note.getNotes('', function(ret) {
|
||||
console.log(ret);
|
||||
});
|
||||
});
|
||||
@@ -112,5 +112,6 @@ console.log(reg);
|
||||
while(s = reg.exec(a)) {
|
||||
console.log(s);
|
||||
}
|
||||
*/
|
||||
|
||||
*/
|
||||
console.log(Common.goNowToDate('2014-01-06T18:29:48.802+08:00'));
|
Reference in New Issue
Block a user