@@ -460,11 +460,11 @@ Notebook.renderShareNotebooks = function(sharedUserInfos, shareNotebooks) {
if(isEmpty(sharedUserInfos)) {
return;
}
-
+
if(!shareNotebooks || typeof shareNotebooks != "object" || shareNotebooks.length < 0) {
return;
}
-
+
var $shareNotebooks = $("#shareNotebooks");
var user2ShareNotebooks = {};
for(var i in shareNotebooks) {
@@ -474,7 +474,7 @@ Notebook.renderShareNotebooks = function(sharedUserInfos, shareNotebooks) {
for(var i in sharedUserInfos) {
var userInfo = sharedUserInfos[i];
var userNotebooks = user2ShareNotebooks[userInfo.UserId] || {ShareNotebooks:[]};
-
+
userNotebooks.ShareNotebooks = [{NotebookId: "-2", Title: "默认共享"}].concat(userNotebooks.ShareNotebooks)
var username = userInfo.Username || userInfo.Email;
@@ -482,10 +482,10 @@ Notebook.renderShareNotebooks = function(sharedUserInfos, shareNotebooks) {
var body = '
';
for(var j in userNotebooks.ShareNotebooks) {
var notebook = userNotebooks.ShareNotebooks[j];
- body += tt('- ?
', notebook.NotebookId, notebook.Title)
+ body += tt('- ?
', notebook.NotebookId, Note._toHtmlEntity(notebook.Title))
}
body += "
";
-
+
$shareNotebooks.append(header + body + "
")
}
}
@@ -509,9 +509,9 @@ Notebook.changeNotebookNavForNewNote = function(notebookId, title) {
var notebook = Notebook.cache[0];
title = notebook.Title;
}
-
+
if(!Notebook.isAllNotebookId(notebookId) && !Notebook.isTrashNotebookId(notebookId)) {
- $("#curNotebookForNewNote").html(title).attr("notebookId", notebookId);
+ $("#curNotebookForNewNote").text(title).attr("notebookId", notebookId);
} else if(!$("#curNotebookForNewNote").attr("notebookId")) {
// 但又没有一个笔记, 默认选第一个吧
// 这里很可能会死循环, 万一用户没有其它笔记呢?
@@ -527,36 +527,36 @@ Notebook.changeNotebookNavForNewNote = function(notebookId, title) {
// 改变导航, 两处
// 单击左侧, 单击新建下拉时调用
-// 1 选中左侧导航,
+// 1 选中左侧导航,
// 2 notelist上面 >
// 3 新建笔记 - js >
// 转成我的nav <-> 共享
Notebook.toggleToMyNav = function(userId, notebookId) {
$("#sharedNotebookNavForListNav").hide();
$("#myNotebookNavForListNav").show();
-
+
$("#newMyNote").show();
$("#newSharedNote").hide();
-
+
// 搜索tag隐藏
$("#tagSearch").hide();
}
Notebook.changeNotebookNav = function(notebookId) {
Notebook.curNotebookId = notebookId;
Notebook.toggleToMyNav();
-
+
// 1 改变当前的notebook
Notebook.selectNotebook($(tt('#notebook [notebookId="?"]', notebookId)));
-
+
var notebook = Notebook.cache[notebookId];
-
+
if(!notebook) {
return;
}
-
+
// 2
- $("#curNotebookForListNote").html(notebook.Title);
-
+ $("#curNotebookForListNote").text(notebook.Title);
+
// 3
Notebook.changeNotebookNavForNewNote(notebookId, notebook.Title);
}
@@ -582,18 +582,18 @@ Notebook.curActiveNotebookIsAll = function() {
Notebook.changeNotebook = function(notebookId, callback) {
var me = this;
Notebook.changeNotebookNav(notebookId);
-
+
Notebook.curNotebookId = notebookId;
-
+
// 1
Note.curChangedSaveIt();
-
+
// 2 先清空所有
Note.clearAll();
-
+
var url = "/note/listNotes/";
var param = {notebookId: notebookId};
-
+
// 废纸篓
if(Notebook.isTrashNotebookId(notebookId)) {
url = "/note/listTrashNotes";
@@ -621,11 +621,11 @@ Notebook.changeNotebook = function(notebookId, callback) {
return;
}
}
-
+
// 2 得到笔记本
// 这里可以缓存起来, note按notebookId缓存
me.showNoteAndEditorLoading();
- ajaxGet(url, param, function(cacheNotes) {
+ ajaxGet(url, param, function(cacheNotes) {
if(callback) {
callback(cacheNotes);
} else {
@@ -657,13 +657,13 @@ Notebook.changeNotebookForNewNote = function(notebookId) {
if(Notebook.isTrashNotebookId(notebookId) || Notebook.isAllNotebookId(notebookId)) {
return;
}
-
+
Notebook.changeNotebookNav(notebookId, true);
Notebook.curNotebookId = notebookId;
-
+
var url = "/note/listNotes/";
var param = {notebookId: notebookId};
-
+
// 2 得到笔记本
// 这里可以缓存起来, note按notebookId缓存
ajaxGet(url, param, function(ret) {
@@ -686,7 +686,7 @@ Notebook.shareNotebooks= function(target) {
$("#friendsEmail").focus();
}, 500);
var notebookId = $(target).attr("notebookId");
-
+
shareNoteOrNotebook(notebookId, false);
}
@@ -699,7 +699,7 @@ Notebook.setNotebook2Blog = function(target) {
if(notebook.IsBlog != undefined) {
isBlog = !notebook.IsBlog;
}
-
+
// 那么, 如果当前是该notebook下, 重新渲染之
if(Notebook.curNotebookId == notebookId) {
if(isBlog) {
@@ -707,7 +707,7 @@ Notebook.setNotebook2Blog = function(target) {
} else {
$("#noteList .item-blog").hide();
}
-
+
// 如果当前在所有笔记本下
} else if(Notebook.curNotebookId == Notebook.allNotebookId){
$("#noteItemList .item").each(function(){
@@ -734,7 +734,7 @@ Notebook.setNotebook2Blog = function(target) {
Notebook.updateNotebookTitle = function(target) {
var self = Notebook;
var notebookId = $(target).attr("notebookId");
-
+
if(self.tree2) {
self.tree2.editName(self.tree2.getNodeByTId(notebookId));
} else {
@@ -748,7 +748,7 @@ Notebook.doUpdateNotebookTitle = function(notebookId, newTitle) {
Notebook.cache[notebookId].Title = newTitle;
// 改变nav
Notebook.changeNav();
-
+
// 同步
if(self.tree2) {
var notebook = self.tree.getNodeByTId(notebookId);
@@ -768,7 +768,7 @@ Notebook.addNotebook = function() {
if($("#myNotebooks").hasClass("closed")) {
$("#myNotebooks .folderHeader").trigger("click");
}
-
+
// 添加并修改
self.tree.addNodes(null, {Title: "", NotebookId: getObjectId(), IsNew: true}, true, true);
}
@@ -782,10 +782,10 @@ Notebook.doAddNotebook = function(notebookId, title, parentNotebookId) {
var notebook = self.tree.getNodeByTId(notebookId);
$.extend(notebook, ret);
notebook.IsNew = false;
-
+
// 选中之
Notebook.changeNotebook(notebookId);
-
+
// 改变nav
Notebook.changeNav();
}
@@ -799,9 +799,9 @@ Notebook.addChildNotebook = function(target) {
if($("#myNotebooks").hasClass("closed")) {
$("#myNotebooks .folderHeader").trigger("click");
}
-
+
var notebookId = $(target).attr("notebookId");
-
+
// 添加并修改
self.tree.addNodes(self.tree.getNodeByTId(notebookId), {Title: "", NotebookId: getObjectId(), IsNew: true}, false, true);
}
@@ -810,12 +810,12 @@ Notebook.addChildNotebook = function(target) {
// 删除
Notebook.deleteNotebook = function(target) {
var self = Notebook;
-
+
var notebookId = $(target).attr("notebookId");
if(!notebookId) {
return;
}
-
+
ajaxGet("/notebook/deleteNotebook", {notebookId: notebookId}, function(ret) {
if(ret.Ok) {
/*
@@ -826,7 +826,7 @@ Notebook.deleteNotebook = function(target) {
self.tree2.removeNode(self.tree2.getNodeByTId(notebookId));
}
delete Notebook.cache[notebookId];
-
+
// 改变nav
Notebook.changeNav();
} else {
@@ -849,17 +849,17 @@ $(function() {
var notebookId = $(this).find("a").attr("notebookId");
Notebook.changeNotebook(notebookId);
});
-
+
// 修改笔记本标题, blur后修改标题之
/*
enterBlur("#notebookList", "input#editNotebookTitle");
$("#notebookList").on("blur", "input#editNotebookTitle", Notebook.doUpdateNotebookTitle);
*/
-
+
//-------------------
// 右键菜单
var notebookListMenu = {
- width: 180,
+ width: 180,
items: [
{ text: getMsg("shareToFriends"), alias: 'shareToFriends', icon: "", faIcon: "fa-share-square-o", action: Notebook.listNotebookShareUserInfo},
{ type: "splitLine" },
@@ -875,10 +875,10 @@ $(function() {
parent: "#notebookList ",
children: "li a"
}
-
+
// for search
var notebookListMenu2 = {
- width: 180,
+ width: 180,
items: [
{ text: getMsg("shareToFriends"), alias: 'shareToFriends', icon: "", faIcon: "fa-share-square-o", action: Notebook.listNotebookShareUserInfo},
{ type: "splitLine" },
@@ -893,7 +893,7 @@ $(function() {
parent: "#notebookListForSearch ",
children: "li a"
}
-
+
function applyrule(menu) {
var notebookId = $(this).attr("notebookId");
var notebook = Notebook.cache[notebookId];
@@ -923,17 +923,17 @@ $(function() {
var notebookId = $(this).attr("notebookId");
return !Notebook.isTrashNotebookId(notebookId) && !Notebook.isAllNotebookId(notebookId);
}
-
+
Notebook.contextmenu = $("#notebookList li a").contextmenu(notebookListMenu);
-
+
Notebook.contextmenuSearch = $("#notebookListForSearch li a").contextmenu(notebookListMenu2);
-
+
// 添加笔记本
$("#addNotebookPlus").click(function(e) {
e.stopPropagation();
Notebook.addNotebook();
});
-
+
// notebook setting
$("#notebookList").on("click", ".notebook-setting", function(e) {
e.preventDefault();
diff --git a/public/js/app/tag-min.js b/public/js/app/tag-min.js
index 0b50a63..a12e773 100644
--- a/public/js/app/tag-min.js
+++ b/public/js/app/tag-min.js
@@ -1 +1 @@
-Tag.classes={"蓝色":"label label-blue","红色":"label label-red","绿色":"label label-green","黄色":"label label-yellow",blue:"label label-blue",red:"label label-red",green:"label label-green",yellow:"label label-yellow"};Tag.mapCn2En={"蓝色":"blue","红色":"red","绿色":"green","黄色":"yellow"};Tag.mapEn2Cn={blue:"蓝色",red:"红色",green:"绿色",yellow:"黄色"};Tag.t=$("#tags");Tag.getTags=function(){var tags=[];Tag.t.children().each(function(){var text=$(this).text();text=text.substring(0,text.length-1);text=Tag.mapCn2En[text]||text;tags.push(text)});return tags};Tag.clearTags=function(){Tag.t.html("")};Tag.renderTags=function(tags){Tag.t.html("");if(isEmpty(tags)){return}for(var i=0;i
?',classes,text);$("#noteReadTags").append(tag)}};Tag.appendTag=function(tag){var isColor=false;var classes,text;if(typeof tag=="object"){classes=tag.classes;text=tag.text;if(!text){return}}else{tag=$.trim(tag);text=tag;if(!text){return}var classes=Tag.classes[text];if(classes){isColor=true}else{classes="label label-default"}}if(LEA.locale=="zh"){text=Tag.mapEn2Cn[text]||text}tag=tt('?X',classes,text);$("#tags").children().each(function(){if(isColor){var tagHtml=$("").append($(this).clone()).html();if(tagHtml==tag){$(this).remove()}}else if(text+"X"==$(this).text()){$(this).remove()}});$("#tags").append(tag);hideTagList();if(!isColor){reRenderTags()}};function reRenderTags(){var defautClasses=["label label-default","label label-info"];var i=0;$("#tags").children().each(function(){var thisClasses=$(this).attr("class");if(thisClasses=="label label-default"||thisClasses=="label label-info"){$(this).removeClass(thisClasses).addClass(defautClasses[i%2]);i++}})}Tag.renderTagNav=function(tags){tags=tags||[];for(var i in tags){var tag=tags[i];if(tag=="red"||tag=="blue"||tag=="yellow"||tag=="green"){continue}var text=Tag.mapEn2Cn[tag]||tag;var classes=Tag.classes[tag]||"label label-default";$("#tagNav").append(tt(' ?',text,classes,text))}};$(function(){$("#addTagTrigger").click(function(){$(this).hide();$("#addTagInput").show().focus().val("")});$("#addTagInput").click(function(event){showTagList(event)});$("#addTagInput").blur(function(){var val=$(this).val();if(val){Tag.appendTag(val,true)}return;$("#addTagTrigger").show();$("#addTagInput").hide()});$("#addTagInput").keydown(function(e){if(e.keyCode==13){hideTagList();if($("#addTagInput").val()){$(this).trigger("blur");$("#addTagTrigger").trigger("click")}else{$(this).trigger("blur")}}});$("#tagColor li").click(function(event){var a;if($(this).attr("role")){a=$(this).find("span")}else{a=$(this)}Tag.appendTag({classes:a.attr("class"),text:a.text()})});$("#tags").on("click","i",function(){$(this).parent().remove();reRenderTags()});function searchTag(){var tag=$.trim($(this).data("tag"));Note.curChangedSaveIt();Note.clearAll();$("#tagSearch").html($(this).html()).show();showLoading();ajaxGet("/note/searchNoteByTags",{tags:[tag]},function(notes){hideLoading();if(notes){Note.renderNotes(notes);if(!isEmpty(notes)){Note.changeNote(notes[0].NoteId)}}})}$("#myTag .folderBody").on("click","li",searchTag);$("#minTagNav").on("click","li",searchTag)});
\ No newline at end of file
+Tag.classes={"蓝色":"label label-blue","红色":"label label-red","绿色":"label label-green","黄色":"label label-yellow",blue:"label label-blue",red:"label label-red",green:"label label-green",yellow:"label label-yellow"};Tag.mapCn2En={"蓝色":"blue","红色":"red","绿色":"green","黄色":"yellow"};Tag.mapEn2Cn={blue:"蓝色",red:"红色",green:"绿色",yellow:"黄色"};Tag.t=$("#tags");Tag.getTags=function(){var tags=[];Tag.t.children().each(function(){var text=$(this).text();text=text.substring(0,text.length-1);text=Tag.mapCn2En[text]||text;tags.push(text)});return tags};Tag.clearTags=function(){Tag.t.html("")};Tag.renderTags=function(tags){Tag.t.html("");if(isEmpty(tags)){return}for(var i=0;i?',classes,text);$("#noteReadTags").append(tag)}};Tag.appendTag=function(tag){var isColor=false;var classes,text;if(typeof tag=="object"){classes=tag.classes;text=tag.text;if(!text){return}}else{tag=$.trim(tag);text=tag;if(!text){return}var classes=Tag.classes[text];if(classes){isColor=true}else{classes="label label-default"}}if(LEA.locale=="zh"){text=Tag.mapEn2Cn[text]||text}tag=tt('?X',classes,Note._toHtmlEntity(text));$("#tags").children().each(function(){if(isColor){var tagHtml=$("").append($(this).clone()).html();if(tagHtml==tag){$(this).remove()}}else if(text+"X"==$(this).text()){$(this).remove()}});$("#tags").append(tag);hideTagList();if(!isColor){reRenderTags()}};function reRenderTags(){var defautClasses=["label label-default","label label-info"];var i=0;$("#tags").children().each(function(){var thisClasses=$(this).attr("class");if(thisClasses=="label label-default"||thisClasses=="label label-info"){$(this).removeClass(thisClasses).addClass(defautClasses[i%2]);i++}})}Tag.renderTagNav=function(tags){tags=tags||[];for(var i in tags){var tag=tags[i];if(tag=="red"||tag=="blue"||tag=="yellow"||tag=="green"){continue}var text=Note._toHtmlEntity(Tag.mapEn2Cn[tag]||tag);var classes=Tag.classes[tag]||"label label-default";$("#tagNav").append(tt(' ?',text,classes,text))}};$(function(){$("#addTagTrigger").click(function(){$(this).hide();$("#addTagInput").show().focus().val("")});$("#addTagInput").click(function(event){showTagList(event)});$("#addTagInput").blur(function(){var val=$(this).val();if(val){Tag.appendTag(val,true)}return;$("#addTagTrigger").show();$("#addTagInput").hide()});$("#addTagInput").keydown(function(e){if(e.keyCode==13){hideTagList();if($("#addTagInput").val()){$(this).trigger("blur");$("#addTagTrigger").trigger("click")}else{$(this).trigger("blur")}}});$("#tagColor li").click(function(event){var a;if($(this).attr("role")){a=$(this).find("span")}else{a=$(this)}Tag.appendTag({classes:a.attr("class"),text:a.text()})});$("#tags").on("click","i",function(){$(this).parent().remove();reRenderTags()});function searchTag(){var tag=$.trim($(this).data("tag"));Note.curChangedSaveIt();Note.clearAll();$("#tagSearch").html($(this).html()).show();showLoading();ajaxGet("/note/searchNoteByTags",{tags:[tag]},function(notes){hideLoading();if(notes){Note.renderNotes(notes);if(!isEmpty(notes)){Note.changeNote(notes[0].NoteId)}}})}$("#myTag .folderBody").on("click","li",searchTag);$("#minTagNav").on("click","li",searchTag)});
\ No newline at end of file
diff --git a/public/js/app/tag.js b/public/js/app/tag.js
index 0a8c27f..f18352f 100644
--- a/public/js/app/tag.js
+++ b/public/js/app/tag.js
@@ -89,7 +89,7 @@ Tag.renderReadOnlyTags = function(tags) {
if(isEmpty(tags)) {
$("#noteReadTags").html(getMsg("noTag"));
}
-
+
var i = true;
function getNextDefaultClasses() {
if (i) {
@@ -100,7 +100,7 @@ Tag.renderReadOnlyTags = function(tags) {
return "label label-info";
}
}
-
+
for(var i in tags) {
var text = tags[i];
text = Tag.mapEn2Cn[text] || text;
@@ -109,7 +109,7 @@ Tag.renderReadOnlyTags = function(tags) {
classes = getNextDefaultClasses();
}
tag = tt('?', classes, text);
-
+
$("#noteReadTags").append(tag);
}
}
@@ -120,7 +120,7 @@ Tag.renderReadOnlyTags = function(tags) {
Tag.appendTag = function(tag) {
var isColor = false;
var classes, text;
-
+
if (typeof tag == "object") {
classes = tag.classes;
text = tag.text;
@@ -140,11 +140,11 @@ Tag.appendTag = function(tag) {
classes = "label label-default";
}
}
-
+
if(LEA.locale == "zh") {
text = Tag.mapEn2Cn[text] || text;
}
- tag = tt('?X', classes, text);
+ tag = tt('?X', classes, Note._toHtmlEntity(text));
// 避免重复
$("#tags").children().each(function() {
@@ -192,9 +192,9 @@ Tag.renderTagNav = function(tags) {
if(tag == "red" || tag == "blue" || tag == "yellow" || tag == "green") {
continue;
}
- var text = Tag.mapEn2Cn[tag] || tag;
+ var text = Note._toHtmlEntity(Tag.mapEn2Cn[tag] || tag);
var classes = Tag.classes[tag] || "label label-default";
- $("#tagNav").append(tt(' ?', text, classes, text));
+ $("#tagNav").append(tt(' ?', text, classes, text));
}
}
@@ -206,11 +206,11 @@ $(function() {
$(this).hide();
$("#addTagInput").show().focus().val("");
});
-
+
$("#addTagInput").click(function(event) {
showTagList(event);
});
-
+
$("#addTagInput").blur(function() {
var val = $(this).val();
if(val) {
@@ -258,27 +258,27 @@ $(function() {
// event.stopPropagation();
});
*/
-
+
$("#tags").on("click", "i", function() {
$(this).parent().remove();
reRenderTags();
});
-
+
//-------------
// nav 标签搜索
function searchTag() {
var tag = $.trim($(this).data("tag"));
// tag = Tag.mapCn2En[tag] || tag;
-
+
// 学习changeNotebook
-
+
// 1
Note.curChangedSaveIt();
-
+
// 2 先清空所有
// 也会把curNoteId清空
Note.clearAll();
-
+
$("#tagSearch").html($(this).html()).show();
showLoading();
ajaxGet("/note/searchNoteByTags", {tags: [tag]}, function(notes) {
@@ -287,7 +287,7 @@ $(function() {
// 和note搜索一样
// 设空, 防止发生上述情况
// Note.curNoteId = "";
-
+
Note.renderNotes(notes);
if(!isEmpty(notes)) {
Note.changeNote(notes[0].NoteId);