diff --git a/public/js/app/note-min.js b/public/js/app/note-min.js index af4892c..ada2ce0 100644 --- a/public/js/app/note-min.js +++ b/public/js/app/note-min.js @@ -1 +1 @@ -Note.curNoteId="";Note.interval="";Note.itemIsBlog='
';Note.itemTplNoImg='
  • ';Note.itemTplNoImg+=Note.itemIsBlog+'

    ?

    ? ?

    ?

  • ';Note.itemTpl='
  • ';Note.itemTpl+=Note.itemIsBlog+'

    ?

    ? ?

    ?

  • ';Note.newItemTpl='
  • ';Note.newItemTpl+=Note.itemIsBlog+'

    ?

    ? ?
    ?

  • ';Note.noteItemListO=$("#noteItemList");Note.cacheByNotebookId={all:{}};Note.notebookIds={};Note.isReadOnly=false;Note.intervalTime=6e5;Note.startInterval=function(){Note.interval=setInterval(function(){log("自动保存开始...");changedNote=Note.curChangedSaveIt(false)},Note.intervalTime)};Note.stopInterval=function(){clearInterval(Note.interval);setTimeout(function(){Note.startInterval()},Note.intervalTime)};Note.addNoteCache=function(note){Note.cache[note.NoteId]=note;Note.clearCacheByNotebookId(note.NotebookId)};Note.setNoteCache=function(content,clear){if(!Note.cache[content.NoteId]){Note.cache[content.NoteId]=content}else{$.extend(Note.cache[content.NoteId],content)}if(clear==undefined){clear=true}if(clear){Note.clearCacheByNotebookId(content.NotebookId)}};Note.getCurNote=function(){var self=this;if(self.curNoteId==""){return null}return self.cache[self.curNoteId]};Note.getNote=function(noteId){var self=this;return self.cache[noteId]};Note.clearCacheByNotebookId=function(notebookId){if(notebookId){Note.cacheByNotebookId[notebookId]={};Note.cacheByNotebookId["all"]={};Note.notebookIds[notebookId]=true}};Note.notebookHasNotes=function(notebookId){var notes=Note.getNotesByNotebookId(notebookId);return!isEmpty(notes)};Note.getNotesByNotebookId=function(notebookId,sortBy,isAsc){if(!sortBy){sortBy="UpdatedTime"}if(isAsc=="undefined"){isAsc=false}if(!notebookId){notebookId="all"}if(!Note.cacheByNotebookId[notebookId]){return[]}if(Note.cacheByNotebookId[notebookId][sortBy]){return Note.cacheByNotebookId[notebookId][sortBy]}else{}var notes=[];var sortBys=[];for(var i in Note.cache){if(!i){continue}var note=Note.cache[i];if(note.IsTrash||note.IsShared){continue}if(notebookId=="all"||note.NotebookId==notebookId){notes.push(note)}}notes.sort(function(a,b){var t1=a[sortBy];var t2=b[sortBy];if(isAsc){if(t1t2){return 1}}else{if(t1t2){return-1}}return 0});Note.cacheByNotebookId[notebookId][sortBy]=notes;return notes};Note.renderNotesAndFirstOneContent=function(ret){if(!isArray(ret)){return}Note.renderNotes(ret);if(!isEmpty(ret[0])){Note.changeNoteForPjax(ret[0].NoteId,true,false)}else{}};Note.curHasChanged=function(force){if(force==undefined){force=true}var cacheNote=Note.cache[Note.curNoteId]||{};var title=$("#noteTitle").val();var tags=Tag.getTags();var contents=getEditorContent(cacheNote.IsMarkdown);var content,preview;var contentText;if(isArray(contents)){content=contents[0];preview=contents[1];contentText=content;if(content&&previewIsEmpty(preview)&&Converter){preview=Converter.makeHtml(content)}if(!content){preview=""}cacheNote.Preview=preview}else{content=contents;try{contentText=$(content).text()}catch(e){}}var hasChanged={hasChanged:false,IsNew:cacheNote.IsNew,IsMarkdown:cacheNote.IsMarkdown,FromUserId:cacheNote.FromUserId,NoteId:cacheNote.NoteId,NotebookId:cacheNote.NotebookId};if(hasChanged.IsNew){$.extend(hasChanged,cacheNote)}if(cacheNote.Title!=title){hasChanged.hasChanged=true;hasChanged.Title=title;if(!hasChanged.Title){}}if(!arrayEqual(cacheNote.Tags,tags)){hasChanged.hasChanged=true;hasChanged.Tags=tags}if(force&&cacheNote.Content!=content||!force&&(!cacheNote.IsMarkdown&&$(cacheNote.Content).text()!=contentText||cacheNote.IsMarkdown&&cacheNote.Content!=contentText)){hasChanged.hasChanged=true;hasChanged.Content=content;var c=preview||content;if(!cacheNote.HasSelfDefined||!cacheNote.IsBlog){hasChanged.Desc=Note.genDesc(c);hasChanged.ImgSrc=Note.getImgSrc(c);hasChanged.Abstract=Note.genAbstract(c)}}else{log("text相同");log(cacheNote.Content==content)}hasChanged["UserId"]=cacheNote["UserId"]||"";return hasChanged};Note.genDesc=function(content){if(!content){return""}content=content.replace(/
    /g,"
    ");content=content.replace(/<\/p>/g,"

    ");content=content.replace(/<\/div>/g," ");content=$("
    ").html(content).text();content=content.replace(//g,">");if(content.length<300){return content}return content.substring(0,300)};Note.genAbstract=function(content,len){if(!content){return""}if(len==undefined){len=1e3}if(content.length"&&isCode){n=n-1;isCode=false}else if(temp==";"&&isHTML){isHTML=false}if(!isCode&&!isHTML){n=n+1}result+=temp;if(n>=maxLen){break}}var d=document.createElement("div");d.innerHTML=result;return d.innerHTML};Note.getImgSrc=function(content){if(!content){return""}var imgs=$(content).find("img");for(var i in imgs){var src=imgs.eq(i).attr("src");if(src){return src}}return""};Note.curChangedSaveIt=function(force){if(!Note.curNoteId||Note.isReadOnly){return}var hasChanged=Note.curHasChanged(force);Note.renderChangedNote(hasChanged);if(hasChanged.hasChanged||hasChanged.IsNew){delete hasChanged.hasChanged;Note.setNoteCache(hasChanged,false);Note.setNoteCache({NoteId:hasChanged.NoteId,UpdatedTime:(new Date).format("yyyy-MM-ddThh:mm:ss.S")},false);showMsg(getMsg("saving"));ajaxPost("/note/updateNoteOrContent",hasChanged,function(ret){if(hasChanged.IsNew){ret.IsNew=false;Note.setNoteCache(ret,false);Pjax.changeNote(ret)}showMsg(getMsg("saveSuccess"),1e3)});return hasChanged}return false};Note.selectTarget=function(target){$(".item").removeClass("item-active");$(target).addClass("item-active")};Note.showContentLoading=function(){$("#noteMaskForLoading").css("z-index",99999)};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 scrollTop=$p.scrollTop();pTop+=scrollTop;if(pTop>=scrollTop&&pTop<=pHeight+scrollTop){}else{var top=pTop;log("定位到特定note, 在可视范围内");if(!LEA.isMobile&&!Mobile.isMobile()){$("#noteItemList").scrollTop(top);$("#noteItemList").slimScroll({scrollTo:top+"px",height:"100%",onlyScrollBar:true})}else{}}};Note.changeNoteForPjax=function(noteId,mustPush,needTargetNotebook){var me=this;var note=me.getNote(noteId);if(!note){return}var isShare=note.Perm!=undefined;if(needTargetNotebook==undefined){needTargetNotebook=true}me.changeNote(noteId,isShare,true,function(note){if(mustPush==undefined){mustPush=true}if(mustPush){Pjax.changeNote(note)}if(needTargetNotebook){Note.directToNote(noteId)}});if(needTargetNotebook){if(isShare){if($("#myShareNotebooks").hasClass("closed")){$("#myShareNotebooks .folderHeader").trigger("click")}}else{if($("#myNotebooks").hasClass("closed")){$("#myNotebooks .folderHeader").trigger("click")}}Notebook.expandNotebookTo(note.NotebookId)}};Note.contentAjax=null;Note.contentAjaxSeq=1;Note.changeNote=function(selectNoteId,isShare,needSaveChanged,callback){var self=this;Note.stopInterval();var target=$(tt('[noteId="?"]',selectNoteId));Note.selectTarget(target);if(needSaveChanged==undefined){needSaveChanged=true}if(needSaveChanged){var changedNote=Note.curChangedSaveIt()}Note.curNoteId="";var cacheNote=Note.cache[selectNoteId];if(!isShare){if(cacheNote.Perm!=undefined){isShare=true}}var hasPerm=!isShare||Share.hasUpdatePerm(selectNoteId);if(hasPerm){Note.hideReadOnly();Note.renderNote(cacheNote);switchEditor(cacheNote.IsMarkdown)}else{Note.renderNoteReadOnly(cacheNote)}Attach.renderNoteAttachNum(selectNoteId,true);Note.contentAjaxSeq++;var seq=Note.contentAjaxSeq;function setContent(ret){Note.contentAjax=null;if(seq!=Note.contentAjaxSeq){return}Note.setNoteCache(ret,false);ret=Note.cache[selectNoteId];if(hasPerm){Note.renderNoteContent(ret)}else{Note.renderNoteContentReadOnly(ret)}self.hideContentLoading();callback&&callback(ret)}if(cacheNote.Content){setContent(cacheNote);return}var url="/note/getNoteContent";var param={noteId:selectNoteId};if(isShare){url="/share/getShareNoteContent";param.sharedUserId=cacheNote.UserId}self.showContentLoading();if(Note.contentAjax!=null){Note.contentAjax.abort()}Note.contentAjax=ajaxGet(url,param,setContent)};Note.renderChangedNote=function(changedNote){if(!changedNote){return}var $leftNoteNav=$(tt('[noteId="?"]',changedNote.NoteId));if(changedNote.Title){$leftNoteNav.find(".item-title").text(changedNote.Title)}if(changedNote.Desc){$leftNoteNav.find(".desc").html(changedNote.Desc)}if(changedNote.ImgSrc){$thumb=$leftNoteNav.find(".item-thumb");if($thumb.length>0){$thumb.find("img").attr("src",changedNote.ImgSrc)}else{$leftNoteNav.append(tt('
    ',changedNote.ImgSrc));$leftNoteNav.addClass("item-image")}$leftNoteNav.find(".item-desc").removeAttr("style")}else if(changedNote.ImgSrc==""){$leftNoteNav.find(".item-thumb").remove();$leftNoteNav.removeClass("item-image")}};Note.clearNoteInfo=function(){Note.curNoteId="";Tag.clearTags();$("#noteTitle").val("");setEditorContent("");$("#noteRead").hide()};Note.clearNoteList=function(){Note.noteItemListO.html("")};Note.clearAll=function(){Note.curNoteId="";Note.clearNoteInfo();Note.clearNoteList()};Note.renderNote=function(note){if(!note){return}$("#noteTitle").val(note.Title);Tag.renderTags(note.Tags)};Note.renderNoteContent=function(content){setEditorContent(content.Content,content.IsMarkdown,content.Preview);Note.curNoteId=content.NoteId};Note.showEditorMask=function(){$("#editorMask").css("z-index",10).show();if(Notebook.curNotebookIsTrashOrAll()){$("#editorMaskBtns").hide();$("#editorMaskBtnsEmpty").show()}else{$("#editorMaskBtns").show();$("#editorMaskBtnsEmpty").hide()}};Note.hideEditorMask=function(){$("#editorMask").css("z-index",-10).hide()};Note.renderNotesC=0;Note.renderNotes=function(notes,forNewNote,isShared){var renderNotesC=++Note.renderNotesC;if(!LEA.isMobile&&!Mobile.isMobile()){$("#noteItemList").slimScroll({scrollTo:"0px",height:"100%",onlyScrollBar:true})}if(!notes||typeof notes!="object"||notes.length<=0){if(!forNewNote){Note.showEditorMask()}return}Note.hideEditorMask();if(forNewNote==undefined){forNewNote=false}if(!forNewNote){Note.noteItemListO.html("")}var len=notes.length;var c=Math.ceil(len/20);Note._renderNotes(notes,forNewNote,isShared,1);for(var i=0;i/g,">")};Note._renderNotes=function(notes,forNewNote,isShared,tang){var baseClasses="item-my";if(isShared){baseClasses="item-shared"}var len=notes.length;for(var i=(tang-1)*20;i'+getMsg("close")+"");options={};options.show=true;$("#leanoteDialog").modal(options);ajaxGet("/noteContentHistory/listHistories",{noteId:Note.curNoteId},function(re){if(!isArray(re)){$content.html(getMsg("noHistories"));return}var str="

    "+getMsg("historiesNum")+'

    ';note=Note.cache[Note.curNoteId];var s="div";if(note.IsMarkdown){s="pre"}for(i in re){var content=re[i];content.Ab=Note.genAbstract(content.Content,200);str+=tt('",i,+i+1,s,content.Ab,s,goNowToDatetime(content.UpdatedTime))}str+="
    #??
    '+getMsg("datetime")+': ?
    ";$content.html(str);$("#historyList .all").click(function(){$p=$(this).parent().parent();var seq=$p.attr("seq");var $c=$p.find(".each-content");var info=re[seq];if(!info.unfold){$(this).text(getMsg("fold"));$c.html(info.Content);info.unfold=true}else{$(this).text(getMsg("unfold"));$c.html(info.Ab);info.unfold=false}});$("#historyList .back").click(function(){$p=$(this).parent().parent();var seq=$p.attr("seq");if(confirm(getMsg("confirmBackup"))){Note.curChangedSaveIt();note=Note.cache[Note.curNoteId];setEditorContent(re[seq].Content,note.IsMarkdown);hideDialog()}})})};Note.exportPDF=function(target){var noteId=$(target).attr("noteId");ajaxGet("/note/exportPdf",{noteId:noteId},function(ret){})};Note.html2Image=function(target){var noteId=$(target).attr("noteId");showDialog("html2ImageDialog",{title:"分享到社区",postShow:function(){ajaxGet("/note/html2Image",{noteId:noteId},function(ret){if(typeof ret=="object"&&ret.Ok){$("#leanoteDialog .weibo span").html("生成成功, 右键图片保存到本地.");$("#leanoteDialog .weibo img").attr("src",ret.Id+"?"+(new Date).getTime());$("#leanoteDialog .btn-share").removeClass("disabled");var note=Note.cache[noteId];var pic=UrlPrefix+ret.Id;var title=encodeURI(note.Title+" ("+UserInfo.Username+"分享. 来自leanote.com)");var windowParam="width=700, height=580, top=180, left=320, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no";$("#leanoteDialog .sendWeiboBtn").click(function(){var url="http://service.weibo.com/share/share.php?title="+title;url+="&pic="+pic;window.open(url,"分享到新浪微博",windowParam)});$("#leanoteDialog .sendTxWeiboBtn").click(function(){var _appkey="801542571";var url="http://share.v.t.qq.com/index.php?c=share&a=index&appkey="+_appkey+"&title="+title+"&url=&pic="+pic;window.open(url,"分享到腾讯微博",windowParam)});$("#leanoteDialog .sendQQBtn").click(function(){var url="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url="+UrlPrefix+"&title="+title+"&pics="+pic;window.open(url,"分享QQ空间",windowParam)});$("#leanoteDialog .sendRRBtn").click(function(){var url="http://widget.renren.com/dialog/share?resourceUrl="+UrlPrefix+"&srcUrl="+UrlPrefix+"&title="+title+"&pic="+pic;window.open(url,"分享人人网",windowParam)})}else{$("#leanoteDialog .weibo").html("对不起, 我们出错了!")}})}})};Note.showReadOnly=function(){Note.isReadOnly=true;$("#noteRead").show()};Note.hideReadOnly=function(){Note.isReadOnly=false;$("#noteRead").hide()};Note.renderNoteReadOnly=function(note){Note.showReadOnly();$("#noteReadTitle").text(note.Title);Tag.renderReadOnlyTags(note.Tags);$("#noteReadCreatedTime").html(goNowToDatetime(note.CreatedTime));$("#noteReadUpdatedTime").html(goNowToDatetime(note.UpdatedTime))};Note.renderNoteContentReadOnly=function(note){if(note.IsMarkdown){$("#noteReadContent").html('
    '+note.Content+"
    ")}else{$("#noteReadContent").html(note.Content)}};Note.lastSearch=null;Note.lastKey=null;Note.lastSearchTime=new Date;Note.isOver2Seconds=false;Note.isSameSearch=function(key){var now=new Date;var duration=now.getTime()-Note.lastSearchTime.getTime();Note.isOver2Seconds=duration>2e3?true:false;if(!Note.lastKey||Note.lastKey!=key||duration>1e3){Note.lastKey=key;Note.lastSearchTime=now;return false}if(key==Note.lastKey){return true}Note.lastSearchTime=now;Note.lastKey=key;return false};Note.searchNote=function(){var val=$("#searchNoteInput").val();if(!val){Notebook.changeNotebook("0");return}if(Note.isSameSearch(val)){return}if(Note.lastSearch){Note.lastSearch.abort()}Note.curChangedSaveIt();Note.clearAll();showLoading();Note.lastSearch=$.post("/note/searchNote",{key:val},function(notes){hideLoading();if(notes){Note.lastSearch=null;Note.renderNotes(notes);if(!isEmpty(notes)){Note.changeNote(notes[0].NoteId,false)}}else{}})};Note.setNote2Blog=function(target){var noteId=$(target).attr("noteId");var note=Note.cache[noteId];var isBlog=true;if(note.IsBlog!=undefined){isBlog=!note.IsBlog}if(isBlog){$(target).find(".item-blog").show()}else{$(target).find(".item-blog").hide()}ajaxPost("/note/setNote2Blog",{noteId:noteId,isBlog:isBlog},function(ret){if(ret){Note.setNoteCache({NoteId:noteId,IsBlog:isBlog},false)}})};Note.setAllNoteBlogStatus=function(notebookId,isBlog){if(!notebookId){return}var notes=Note.getNotesByNotebookId(notebookId);if(!isArray(notes)){return}var len=notes.length;if(len==0){for(var i in Note.cache){if(Note.cache[i].NotebookId==notebookId){Note.cache[i].IsBlog=isBlog}}}else{for(var i=0;i'+attach.Title+"")}});self.linkAllBtnO.on("click",function(e){e.stopPropagation();var note=Note.getCurNote();if(!note){return}var src=UrlPrefix+"/attach/downloadAll?noteId="+Note.curNoteId;var title=note.Title?note.Title+".tar.gz":"all.tar.gz";if(LEA.isMarkdownEditor()&&MD){MD.insertLink(src,title)}else{tinymce.activeEditor.insertContent(''+title+"")}})},attachListO:$("#attachList"),attachNumO:$("#attachNum"),attachDropdownO:$("#attachDropdown"),downloadAllBtnO:$("#downloadAllBtn"),linkAllBtnO:$("#linkAllBtn"),clearNoteAttachNum:function(){var self=this;self.attachNumO.html("").hide()},renderNoteAttachNum:function(noteId,needHide){var self=this;var note=Note.getNote(noteId);if(note.AttachNum){self.attachNumO.html("("+note.AttachNum+")").show();self.downloadAllBtnO.show();self.linkAllBtnO.show()}else{self.attachNumO.hide();self.downloadAllBtnO.hide();self.linkAllBtnO.hide()}if(needHide){self.attachDropdownO.removeClass("open")}},_renderAttachs:function(attachs){var self=this;var html="";var attachNum=attachs.length;for(var i=0;i'+'
    '+each.Title+"
    "+'
    '+' '+' '+' '+"
    "+"";self.attachsMap[each.AttachId]=each}self.attachListO.html(html);var note=Note.getCurNote();if(note){note.AttachNum=attachNum;self.renderNoteAttachNum(note.NoteId,false)}},renderAttachs:function(noteId){var self=this;if(self.loadedNoteAttachs[noteId]){self._renderAttachs(self.loadedNoteAttachs[noteId]);return}self.attachListO.html('
  • ');ajaxGet("/attach/getAttachs",{noteId:noteId},function(ret){var list=[];if(ret.Ok){list=ret.List;if(!list){list=[]}}self.loadedNoteAttachs[noteId]=list;self._renderAttachs(list)})},addAttach:function(attachInfo){var self=this;if(!self.loadedNoteAttachs[attachInfo.NoteId]){self.loadedNoteAttachs[attachInfo.NoteId]=[]}self.loadedNoteAttachs[attachInfo.NoteId].push(attachInfo);self.renderAttachs(attachInfo.NoteId)},deleteAttach:function(attachId){var self=this;var noteId=Note.curNoteId;var attachs=self.loadedNoteAttachs[noteId];for(var i=0;i

    ?

    ? ?

    ?

    ';Note.itemTpl='
  • ';Note.itemTpl+=Note.itemIsBlog+'

    ?

    ? ?

    ?

  • ';Note.newItemTpl='
  • ';Note.newItemTpl+=Note.itemIsBlog+'

    ?

    ? ?
    ?

  • ';Note.noteItemListO=$("#noteItemList");Note.cacheByNotebookId={all:{}};Note.notebookIds={};Note.isReadOnly=false;Note.intervalTime=6e5;Note.startInterval=function(){Note.interval=setInterval(function(){log("自动保存开始...");changedNote=Note.curChangedSaveIt(false)},Note.intervalTime)};Note.stopInterval=function(){clearInterval(Note.interval);setTimeout(function(){Note.startInterval()},Note.intervalTime)};Note.addNoteCache=function(note){Note.cache[note.NoteId]=note;Note.clearCacheByNotebookId(note.NotebookId)};Note.setNoteCache=function(content,clear){if(!Note.cache[content.NoteId]){Note.cache[content.NoteId]=content}else{$.extend(Note.cache[content.NoteId],content)}if(clear==undefined){clear=true}if(clear){Note.clearCacheByNotebookId(content.NotebookId)}};Note.getCurNote=function(){var self=this;if(self.curNoteId==""){return null}return self.cache[self.curNoteId]};Note.getNote=function(noteId){var self=this;return self.cache[noteId]};Note.clearCacheByNotebookId=function(notebookId){if(notebookId){Note.cacheByNotebookId[notebookId]={};Note.cacheByNotebookId["all"]={};Note.notebookIds[notebookId]=true}};Note.notebookHasNotes=function(notebookId){var notes=Note.getNotesByNotebookId(notebookId);return!isEmpty(notes)};Note.getNotesByNotebookId=function(notebookId,sortBy,isAsc){if(!sortBy){sortBy="UpdatedTime"}if(isAsc=="undefined"){isAsc=false}if(!notebookId){notebookId="all"}if(!Note.cacheByNotebookId[notebookId]){return[]}if(Note.cacheByNotebookId[notebookId][sortBy]){return Note.cacheByNotebookId[notebookId][sortBy]}else{}var notes=[];var sortBys=[];for(var i in Note.cache){if(!i){continue}var note=Note.cache[i];if(note.IsTrash||note.IsShared){continue}if(notebookId=="all"||note.NotebookId==notebookId){notes.push(note)}}notes.sort(function(a,b){var t1=a[sortBy];var t2=b[sortBy];if(isAsc){if(t1t2){return 1}}else{if(t1t2){return-1}}return 0});Note.cacheByNotebookId[notebookId][sortBy]=notes;return notes};Note.renderNotesAndFirstOneContent=function(ret){if(!isArray(ret)){return}Note.renderNotes(ret);if(!isEmpty(ret[0])){Note.changeNoteForPjax(ret[0].NoteId,true,false)}else{}};Note.curHasChanged=function(force){if(force==undefined){force=true}var cacheNote=Note.cache[Note.curNoteId]||{};var title=$("#noteTitle").val();var tags=Tag.getTags();var contents=getEditorContent(cacheNote.IsMarkdown);var content,preview;var contentText;if(isArray(contents)){content=contents[0];preview=contents[1];contentText=content;if(content&&previewIsEmpty(preview)&&Converter){preview=Converter.makeHtml(content)}if(!content){preview=""}cacheNote.Preview=preview}else{content=contents;try{contentText=$(content).text()}catch(e){}}var hasChanged={hasChanged:false,IsNew:cacheNote.IsNew,IsMarkdown:cacheNote.IsMarkdown,FromUserId:cacheNote.FromUserId,NoteId:cacheNote.NoteId,NotebookId:cacheNote.NotebookId};if(hasChanged.IsNew){$.extend(hasChanged,cacheNote)}if(cacheNote.Title!=title){hasChanged.hasChanged=true;hasChanged.Title=title;if(!hasChanged.Title){}}if(!arrayEqual(cacheNote.Tags,tags)){hasChanged.hasChanged=true;hasChanged.Tags=tags}if(force&&cacheNote.Content!=content||!force&&(!cacheNote.IsMarkdown&&$(cacheNote.Content).text()!=contentText||cacheNote.IsMarkdown&&cacheNote.Content!=contentText)){hasChanged.hasChanged=true;hasChanged.Content=content;var c=preview||content;if(!cacheNote.HasSelfDefined||!cacheNote.IsBlog){hasChanged.Desc=Note.genDesc(c);hasChanged.ImgSrc=Note.getImgSrc(c);hasChanged.Abstract=Note.genAbstract(c)}}else{log("text相同");log(cacheNote.Content==content)}hasChanged["UserId"]=cacheNote["UserId"]||"";return hasChanged};Note.genDesc=function(content){if(!content){return""}content=content.replace(/
    /g,"
    ");content=content.replace(/<\/p>/g,"

    ");content=content.replace(/<\/div>/g," ");content=$("
    ").html(content).text();content=content.replace(//g,">");if(content.length<300){return content}return content.substring(0,300)};Note.genAbstract=function(content,len){if(!content){return""}if(len==undefined){len=1e3}if(content.length"&&isCode){n=n-1;isCode=false}else if(temp==";"&&isHTML){isHTML=false}if(!isCode&&!isHTML){n=n+1}result+=temp;if(n>=maxLen){break}}var d=document.createElement("div");d.innerHTML=result;return d.innerHTML};Note.getImgSrc=function(content){if(!content){return""}var imgs=$(content).find("img");for(var i in imgs){var src=imgs.eq(i).attr("src");if(src){return src}}return""};Note.curChangedSaveIt=function(force){if(!Note.curNoteId||Note.isReadOnly){return}var hasChanged=Note.curHasChanged(force);Note.renderChangedNote(hasChanged);if(hasChanged.hasChanged||hasChanged.IsNew){delete hasChanged.hasChanged;Note.setNoteCache(hasChanged,false);Note.setNoteCache({NoteId:hasChanged.NoteId,UpdatedTime:(new Date).format("yyyy-MM-ddThh:mm:ss.S")},false);showMsg(getMsg("saving"));ajaxPost("/note/updateNoteOrContent",hasChanged,function(ret){if(hasChanged.IsNew){ret.IsNew=false;Note.setNoteCache(ret,false);Pjax.changeNote(ret)}showMsg(getMsg("saveSuccess"),1e3)});return hasChanged}return false};Note.selectTarget=function(target){$(".item").removeClass("item-active");$(target).addClass("item-active")};Note.showContentLoading=function(){$("#noteMaskForLoading").css("z-index",99999)};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 scrollTop=$p.scrollTop();pTop+=scrollTop;if(pTop>=scrollTop&&pTop<=pHeight+scrollTop){}else{var top=pTop;log("定位到特定note, 在可视范围内");if(!LEA.isMobile&&!Mobile.isMobile()){$("#noteItemList").scrollTop(top);$("#noteItemList").slimScroll({scrollTo:top+"px",height:"100%",onlyScrollBar:true})}else{}}};Note.changeNoteForPjax=function(noteId,mustPush,needTargetNotebook){var me=this;var note=me.getNote(noteId);if(!note){return}var isShare=note.Perm!=undefined;if(needTargetNotebook==undefined){needTargetNotebook=true}me.changeNote(noteId,isShare,true,function(note){if(mustPush==undefined){mustPush=true}if(mustPush){Pjax.changeNote(note)}if(needTargetNotebook){Note.directToNote(noteId)}});if(needTargetNotebook){if(isShare){if($("#myShareNotebooks").hasClass("closed")){$("#myShareNotebooks .folderHeader").trigger("click")}}else{if($("#myNotebooks").hasClass("closed")){$("#myNotebooks .folderHeader").trigger("click")}}Notebook.expandNotebookTo(note.NotebookId)}};Note.contentAjax=null;Note.contentAjaxSeq=1;Note.changeNote=function(selectNoteId,isShare,needSaveChanged,callback){var self=this;Note.stopInterval();var target=$(tt('[noteId="?"]',selectNoteId));Note.selectTarget(target);if(needSaveChanged==undefined){needSaveChanged=true}if(needSaveChanged){var changedNote=Note.curChangedSaveIt()}Note.curNoteId="";var cacheNote=Note.cache[selectNoteId];if(!isShare){if(cacheNote.Perm!=undefined){isShare=true}}var hasPerm=!isShare||Share.hasUpdatePerm(selectNoteId);if(hasPerm){Note.hideReadOnly();Note.renderNote(cacheNote);switchEditor(cacheNote.IsMarkdown)}else{Note.renderNoteReadOnly(cacheNote)}Attach.renderNoteAttachNum(selectNoteId,true);Note.contentAjaxSeq++;var seq=Note.contentAjaxSeq;function setContent(ret){Note.contentAjax=null;if(seq!=Note.contentAjaxSeq){return}Note.setNoteCache(ret,false);ret=Note.cache[selectNoteId];if(hasPerm){Note.renderNoteContent(ret)}else{Note.renderNoteContentReadOnly(ret)}self.hideContentLoading();callback&&callback(ret)}if(cacheNote.Content){setContent(cacheNote);return}var url="/note/getNoteContent";var param={noteId:selectNoteId};if(isShare){url="/share/getShareNoteContent";param.sharedUserId=cacheNote.UserId}self.showContentLoading();if(Note.contentAjax!=null){Note.contentAjax.abort()}Note.contentAjax=ajaxGet(url,param,setContent)};Note.renderChangedNote=function(changedNote){if(!changedNote){return}var $leftNoteNav=$(tt('[noteId="?"]',changedNote.NoteId));if(changedNote.Title){$leftNoteNav.find(".item-title").text(changedNote.Title)}if(changedNote.Desc){$leftNoteNav.find(".desc").html(changedNote.Desc)}if(changedNote.ImgSrc){$thumb=$leftNoteNav.find(".item-thumb");if($thumb.length>0){$thumb.find("img").attr("src",changedNote.ImgSrc)}else{$leftNoteNav.append(tt('
    ',changedNote.ImgSrc));$leftNoteNav.addClass("item-image")}$leftNoteNav.find(".item-desc").removeAttr("style")}else if(changedNote.ImgSrc==""){$leftNoteNav.find(".item-thumb").remove();$leftNoteNav.removeClass("item-image")}};Note.clearNoteInfo=function(){Note.curNoteId="";Tag.clearTags();$("#noteTitle").val("");setEditorContent("");$("#noteRead").hide()};Note.clearNoteList=function(){Note.noteItemListO.html("")};Note.clearAll=function(){Note.curNoteId="";Note.clearNoteInfo();Note.clearNoteList()};Note.renderNote=function(note){if(!note){return}$("#noteTitle").val(note.Title);Tag.renderTags(note.Tags)};Note.renderNoteContent=function(content){setEditorContent(content.Content,content.IsMarkdown,content.Preview);Note.curNoteId=content.NoteId};Note.showEditorMask=function(){$("#editorMask").css("z-index",10).show();if(Notebook.curNotebookIsTrashOrAll()){$("#editorMaskBtns").hide();$("#editorMaskBtnsEmpty").show()}else{$("#editorMaskBtns").show();$("#editorMaskBtnsEmpty").hide()}};Note.hideEditorMask=function(){$("#editorMask").css("z-index",-10).hide()};Note.renderNotesC=0;Note.renderNotes=function(notes,forNewNote,isShared){var renderNotesC=++Note.renderNotesC;if(!LEA.isMobile&&!Mobile.isMobile()){$("#noteItemList").slimScroll({scrollTo:"0px",height:"100%",onlyScrollBar:true})}if(!notes||typeof notes!="object"||notes.length<=0){if(!forNewNote){Note.showEditorMask()}return}Note.hideEditorMask();if(forNewNote==undefined){forNewNote=false}if(!forNewNote){Note.noteItemListO.html("")}var len=notes.length;var c=Math.ceil(len/20);Note._renderNotes(notes,forNewNote,isShared,1);for(var i=0;i/g,">")};Note._renderNotes=function(notes,forNewNote,isShared,tang){var baseClasses="item-my";if(isShared){baseClasses="item-shared"}var len=notes.length;for(var i=(tang-1)*20;i'+getMsg("close")+"");options={};options.show=true;$("#leanoteDialog").modal(options);ajaxGet("/noteContentHistory/listHistories",{noteId:Note.curNoteId},function(re){if(!isArray(re)){$content.html(getMsg("noHistories"));return}var str="

    "+getMsg("historiesNum")+'

    ';note=Note.cache[Note.curNoteId];var s="div";if(note.IsMarkdown){s="pre"}for(i in re){var content=re[i];content.Ab=Note.genAbstract(content.Content,200);str+=tt('",i,+i+1,s,content.Ab,s,goNowToDatetime(content.UpdatedTime))}str+="
    #??
    '+getMsg("datetime")+': ?
    ";$content.html(str);$("#historyList .all").click(function(){$p=$(this).parent().parent();var seq=$p.attr("seq");var $c=$p.find(".each-content");var info=re[seq];if(!info.unfold){$(this).text(getMsg("fold"));$c.html(info.Content);info.unfold=true}else{$(this).text(getMsg("unfold"));$c.html(info.Ab);info.unfold=false}});$("#historyList .back").click(function(){$p=$(this).parent().parent();var seq=$p.attr("seq");if(confirm(getMsg("confirmBackup"))){Note.curChangedSaveIt();note=Note.cache[Note.curNoteId];setEditorContent(re[seq].Content,note.IsMarkdown);hideDialog()}})})};Note.exportPDF=function(target){var noteId=$(target).attr("noteId");ajaxGet("/note/exportPdf",{noteId:noteId},function(ret){})};Note.html2Image=function(target){var noteId=$(target).attr("noteId");showDialog("html2ImageDialog",{title:"分享到社区",postShow:function(){ajaxGet("/note/html2Image",{noteId:noteId},function(ret){if(typeof ret=="object"&&ret.Ok){$("#leanoteDialog .weibo span").html("生成成功, 右键图片保存到本地.");$("#leanoteDialog .weibo img").attr("src",ret.Id+"?"+(new Date).getTime());$("#leanoteDialog .btn-share").removeClass("disabled");var note=Note.cache[noteId];var pic=UrlPrefix+ret.Id;var title=encodeURI(note.Title+" ("+UserInfo.Username+"分享. 来自leanote.com)");var windowParam="width=700, height=580, top=180, left=320, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no";$("#leanoteDialog .sendWeiboBtn").click(function(){var url="http://service.weibo.com/share/share.php?title="+title;url+="&pic="+pic;window.open(url,"分享到新浪微博",windowParam)});$("#leanoteDialog .sendTxWeiboBtn").click(function(){var _appkey="801542571";var url="http://share.v.t.qq.com/index.php?c=share&a=index&appkey="+_appkey+"&title="+title+"&url=&pic="+pic;window.open(url,"分享到腾讯微博",windowParam)});$("#leanoteDialog .sendQQBtn").click(function(){var url="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url="+UrlPrefix+"&title="+title+"&pics="+pic;window.open(url,"分享QQ空间",windowParam)});$("#leanoteDialog .sendRRBtn").click(function(){var url="http://widget.renren.com/dialog/share?resourceUrl="+UrlPrefix+"&srcUrl="+UrlPrefix+"&title="+title+"&pic="+pic;window.open(url,"分享人人网",windowParam)})}else{$("#leanoteDialog .weibo").html("对不起, 我们出错了!")}})}})};Note.showReadOnly=function(){Note.isReadOnly=true;$("#noteRead").show()};Note.hideReadOnly=function(){Note.isReadOnly=false;$("#noteRead").hide()};Note.renderNoteReadOnly=function(note){Note.showReadOnly();$("#noteReadTitle").text(note.Title);Tag.renderReadOnlyTags(note.Tags);$("#noteReadCreatedTime").html(goNowToDatetime(note.CreatedTime));$("#noteReadUpdatedTime").html(goNowToDatetime(note.UpdatedTime))};Note.renderNoteContentReadOnly=function(note){if(note.IsMarkdown){$("#noteReadContent").html('
    '+note.Content+"
    ")}else{$("#noteReadContent").html(note.Content)}};Note.lastSearch=null;Note.lastKey=null;Note.lastSearchTime=new Date;Note.isOver2Seconds=false;Note.isSameSearch=function(key){var now=new Date;var duration=now.getTime()-Note.lastSearchTime.getTime();Note.isOver2Seconds=duration>2e3?true:false;if(!Note.lastKey||Note.lastKey!=key||duration>1e3){Note.lastKey=key;Note.lastSearchTime=now;return false}if(key==Note.lastKey){return true}Note.lastSearchTime=now;Note.lastKey=key;return false};Note.searchNote=function(){var val=$("#searchNoteInput").val();if(!val){Notebook.changeNotebook("0");return}if(Note.isSameSearch(val)){return}if(Note.lastSearch){Note.lastSearch.abort()}Note.curChangedSaveIt();Note.clearAll();showLoading();Note.lastSearch=$.post("/note/searchNote",{key:val},function(notes){hideLoading();if(notes){Note.lastSearch=null;Note.renderNotes(notes);if(!isEmpty(notes)){Note.changeNote(notes[0].NoteId,false)}}else{}})};Note.setNote2Blog=function(target){var noteId=$(target).attr("noteId");var note=Note.cache[noteId];var isBlog=true;if(note.IsBlog!=undefined){isBlog=!note.IsBlog}if(isBlog){$(target).find(".item-blog").show()}else{$(target).find(".item-blog").hide()}ajaxPost("/note/setNote2Blog",{noteId:noteId,isBlog:isBlog},function(ret){if(ret){Note.setNoteCache({NoteId:noteId,IsBlog:isBlog},false)}})};Note.setAllNoteBlogStatus=function(notebookId,isBlog){if(!notebookId){return}var notes=Note.getNotesByNotebookId(notebookId);if(!isArray(notes)){return}var len=notes.length;if(len==0){for(var i in Note.cache){if(Note.cache[i].NotebookId==notebookId){Note.cache[i].IsBlog=isBlog}}}else{for(var i=0;i'+attach.Title+"")}});self.linkAllBtnO.on("click",function(e){e.stopPropagation();var note=Note.getCurNote();if(!note){return}var src=UrlPrefix+"/attach/downloadAll?noteId="+Note.curNoteId;var title=note.Title?note.Title+".tar.gz":"all.tar.gz";if(LEA.isMarkdownEditor()&&MD){MD.insertLink(src,title)}else{tinymce.activeEditor.insertContent(''+title+"")}})},attachListO:$("#attachList"),attachNumO:$("#attachNum"),attachDropdownO:$("#attachDropdown"),downloadAllBtnO:$("#downloadAllBtn"),linkAllBtnO:$("#linkAllBtn"),clearNoteAttachNum:function(){var self=this;self.attachNumO.html("").hide()},renderNoteAttachNum:function(noteId,needHide){var self=this;var note=Note.getNote(noteId);if(note.AttachNum){self.attachNumO.html("("+note.AttachNum+")").show();self.downloadAllBtnO.show();self.linkAllBtnO.show()}else{self.attachNumO.hide();self.downloadAllBtnO.hide();self.linkAllBtnO.hide()}if(needHide){self.attachDropdownO.removeClass("open")}},_renderAttachs:function(attachs){var self=this;var html="";var attachNum=attachs.length;for(var i=0;i'+'
    '+Note._toHtmlEntity(each.Title)+"
    "+'
    '+' '+' '+' '+"
    "+"";self.attachsMap[each.AttachId]=each}self.attachListO.html(html);var note=Note.getCurNote();if(note){note.AttachNum=attachNum;self.renderNoteAttachNum(note.NoteId,false)}},renderAttachs:function(noteId){var self=this;if(self.loadedNoteAttachs[noteId]){self._renderAttachs(self.loadedNoteAttachs[noteId]);return}self.attachListO.html('
  • ');ajaxGet("/attach/getAttachs",{noteId:noteId},function(ret){var list=[];if(ret.Ok){list=ret.List;if(!list){list=[]}}self.loadedNoteAttachs[noteId]=list;self._renderAttachs(list)})},addAttach:function(attachInfo){var self=this;if(!self.loadedNoteAttachs[attachInfo.NoteId]){self.loadedNoteAttachs[attachInfo.NoteId]=[]}self.loadedNoteAttachs[attachInfo.NoteId].push(attachInfo);self.renderAttachs(attachInfo.NoteId)},deleteAttach:function(attachId){var self=this;var noteId=Note.curNoteId;var attachs=self.loadedNoteAttachs[noteId];for(var i=0;i t2) { return 1; - } + } } else { if(t1 < t2) { return 1; @@ -160,7 +160,7 @@ Note.getNotesByNotebookId = function(notebookId, sortBy, isAsc) { } return 0; }); - + // 缓存之 Note.cacheByNotebookId[notebookId][sortBy] = notes; return notes; @@ -173,7 +173,7 @@ Note.renderNotesAndFirstOneContent = function(ret) { if(!isArray(ret)) { return; } - + // note 导航 Note.renderNotes(ret); // 渲染第一个 @@ -195,7 +195,7 @@ Note.curHasChanged = function(force) { // 收集当前信息, 与cache比对 var title = $("#noteTitle").val(); var tags = Tag.getTags(); // TODO - + // 如果是markdown返回[content, preview] var contents = getEditorContent(cacheNote.IsMarkdown); var content, preview; @@ -219,7 +219,7 @@ Note.curHasChanged = function(force) { } catch(e) { } } - + var hasChanged = { hasChanged: false, // 总的是否有改变 IsNew: cacheNote.IsNew, // 是否是新添加的 @@ -228,11 +228,11 @@ Note.curHasChanged = function(force) { NoteId: cacheNote.NoteId, NotebookId: cacheNote.NotebookId }; - + if(hasChanged.IsNew) { $.extend(hasChanged, cacheNote); } - + if(cacheNote.Title != title) { hasChanged.hasChanged = true; // 本页使用用小写 hasChanged.Title = title; // 要传到后台的用大写 @@ -240,20 +240,20 @@ Note.curHasChanged = function(force) { // alert(1); } } - + if(!arrayEqual(cacheNote.Tags, tags)) { hasChanged.hasChanged = true; hasChanged.Tags = tags; } - + // 比较text, 因为note Nav会添加dom会导致content改变 if((force && cacheNote.Content != content) || (!force && (/**/(!cacheNote.IsMarkdown && $(cacheNote.Content).text() != contentText) || (cacheNote.IsMarkdown && cacheNote.Content != contentText)) /**/) ) { hasChanged.hasChanged = true; hasChanged.Content = content; - + // 从html中得到... var c = preview || content; - + // 不是博客或没有自定义设置的 if(!cacheNote.HasSelfDefined || !cacheNote.IsBlog) { hasChanged.Desc = Note.genDesc(c); @@ -264,9 +264,9 @@ Note.curHasChanged = function(force) { log("text相同"); log(cacheNote.Content == content); } - + hasChanged["UserId"] = cacheNote["UserId"] || ""; - + return hasChanged; } @@ -276,39 +276,39 @@ Note.genDesc = function(content) { if(!content) { return ""; } - + // 将,

    替换成\n /* var token = "ALEALE"; - content = content.replace(/<\/p>/g, token); + content = content.replace(/<\/p>/g, token); content = content.replace(/<\/div>/g, token); content = content.replace(/<\/?.+?>/g," "); - + pattern = new RegExp(token, "g"); content = content.replace(pattern, "
    "); content = content.replace(/
    ( *)
    /g, "
    "); // 两个
    之间可能有空白 content = content.replace(/
    ( *)
    /g, "
    "); - + // 去掉最开始的

    content = trimLeft(content, " "); content = trimLeft(content, "
    "); content = trimLeft(content, "

    "); content = trimLeft(content, ""); */ - + // 留空格 content = content.replace(/
    /g,"
    "); content = content.replace(/<\/p>/g,"

    "); content = content.replace(/<\/div>/g," "); - + // 避免其它的").html(content).text(); - - + + // pre下text()会将< => < > => > content = content.replace(//g, ">"); - + if(content.length < 300) { return content; } @@ -351,7 +351,7 @@ Note.genAbstract = function(content, len) { break } } - + var d = document.createElement("div"); d.innerHTML = result return d.innerHTML; @@ -380,21 +380,21 @@ Note.curChangedSaveIt = function(force) { if(!Note.curNoteId || Note.isReadOnly) { return; } - + var hasChanged = Note.curHasChanged(force); - + // 把已改变的渲染到左边 item-list Note.renderChangedNote(hasChanged); - + if(hasChanged.hasChanged || hasChanged.IsNew) { delete hasChanged.hasChanged; - + // 先缓存, 把markdown的preview也缓存起来 Note.setNoteCache(hasChanged, false); - + // 设置更新时间 Note.setNoteCache({"NoteId": hasChanged.NoteId, "UpdatedTime": (new Date()).format("yyyy-MM-ddThh:mm:ss.S")}, false); - + // 保存之 showMsg(getMsg("saving")); ajaxPost("/note/updateNoteOrContent", hasChanged, function(ret) { @@ -402,13 +402,13 @@ Note.curChangedSaveIt = function(force) { // 缓存之, 后台得到其它信息 ret.IsNew = false; Note.setNoteCache(ret, false); - + // 新建笔记也要change history Pjax.changeNote(ret); } showMsg(getMsg("saveSuccess"), 1000); }); - + return hasChanged; } return false; @@ -443,7 +443,7 @@ Note.directToNote = function(noteId) { log(noteId); log(pTop + ' ' + pHeight + ' ' + scrollTop); */ - + // 当前的可视范围的元素位置是[scrollTop, pHeight + scrollTop] if(pTop >= scrollTop && pTop <= pHeight + scrollTop) { } else { @@ -479,17 +479,17 @@ Note.changeNoteForPjax = function(noteId, mustPush, needTargetNotebook) { if(mustPush) { Pjax.changeNote(note); } - + // popstate时虽然选中了note, 但位置可能不可见 if(needTargetNotebook) { Note.directToNote(noteId); } }); - + // 第一次render时定位到第一个笔记的notebook 12.06 life // 或通过pop时 // 什么时候需要? 1. 第一次changeNote, 2. pop时, 只有当点击了notebook后才不要 - + // 这里, 万一是共享笔记呢? // 切换到共享中 if(needTargetNotebook) { @@ -512,14 +512,14 @@ Note.contentAjax = null; Note.contentAjaxSeq = 1; Note.changeNote = function(selectNoteId, isShare, needSaveChanged, callback) { var self = this; - + // -1 停止定时器 Note.stopInterval(); - + // 0 var target = $(tt('[noteId="?"]', selectNoteId)) Note.selectTarget(target); - + // 1 之前的note, 判断是否已改变, 改变了就要保存之 // 这里, 在搜索的时候总是保存, 搜索的话, 比较快, 肯定没有变化, 就不要执行该操作 if(needSaveChanged == undefined) { @@ -528,14 +528,14 @@ Note.changeNote = function(selectNoteId, isShare, needSaveChanged, callback) { if(needSaveChanged) { var changedNote = Note.curChangedSaveIt(); } - + // 2. 设空, 防止在内容得到之前又发生保存 Note.curNoteId = ""; - + // 2 得到现在的 // ajax之 var cacheNote = Note.cache[selectNoteId]; - + // 判断是否是共享notes if(!isShare) { if(cacheNote.Perm != undefined) { @@ -543,20 +543,20 @@ Note.changeNote = function(selectNoteId, isShare, needSaveChanged, callback) { } } var hasPerm = !isShare || Share.hasUpdatePerm(selectNoteId); // 不是共享, 或者是共享但有权限 - + // 有权限 if(hasPerm) { Note.hideReadOnly(); Note.renderNote(cacheNote); - + // 这里要切换编辑器 switchEditor(cacheNote.IsMarkdown) } else { Note.renderNoteReadOnly(cacheNote); } - + Attach.renderNoteAttachNum(selectNoteId, true); - + Note.contentAjaxSeq++; var seq = Note.contentAjaxSeq; function setContent(ret) { @@ -573,22 +573,22 @@ Note.changeNote = function(selectNoteId, isShare, needSaveChanged, callback) { Note.renderNoteContentReadOnly(ret); } self.hideContentLoading(); - + callback && callback(ret); } - + if(cacheNote.Content) { setContent(cacheNote); return; } - + var url = "/note/getNoteContent"; var param = {noteId: selectNoteId}; if(isShare) { url = "/share/getShareNoteContent"; param.sharedUserId = cacheNote.UserId // 谁的笔记 } - + self.showContentLoading(); if(Note.contentAjax != null) { Note.contentAjax.abort(); @@ -605,7 +605,7 @@ Note.renderChangedNote = function(changedNote) { if(!changedNote) { return; } - + // 找到左侧相应的note var $leftNoteNav = $(tt('[noteId="?"]', changedNote.NoteId)); if(changedNote.Title) { @@ -630,20 +630,20 @@ Note.renderChangedNote = function(changedNote) { } } -// 清空右侧note信息, 可能是共享的, +// 清空右侧note信息, 可能是共享的, // 此时需要清空只读的, 且切换到note edit模式下 Note.clearNoteInfo = function() { Note.curNoteId = ""; Tag.clearTags(); $("#noteTitle").val(""); setEditorContent(""); - + // markdown editor /* $("#wmd-input").val(""); $("#wmd-preview").html(""); */ - + // 只隐藏即可 $("#noteRead").hide(); } @@ -656,7 +656,7 @@ Note.clearNoteList = function() { Note.clearAll = function() { // 当前的笔记清空掉 Note.curNoteId = ""; - + Note.clearNoteInfo(); Note.clearNoteList(); } @@ -669,7 +669,7 @@ Note.renderNote = function(note) { } // title $("#noteTitle").val(note.Title); - + // 当前正在编辑的 // tags Tag.renderTags(note.Tags); @@ -720,13 +720,13 @@ Note.hideEditorMask = function() { Note.renderNotesC = 0; Note.renderNotes = function(notes, forNewNote, isShared) { var renderNotesC = ++Note.renderNotesC; - + // 手机端不用 // slimScroll使得手机端滚动不流畅 if(!LEA.isMobile && !Mobile.isMobile()) { $("#noteItemList").slimScroll({ scrollTo: '0px', height: "100%", onlyScrollBar: true}); } - + if(!notes || typeof notes != "object" || notes.length <= 0) { // 如果没有, 那么是不是应该hide editor? if(!forNewNote) { @@ -742,26 +742,26 @@ Note.renderNotes = function(notes, forNewNote, isShared) { if(!forNewNote) { Note.noteItemListO.html(""); // 清空 } - + // 20个一次 var len = notes.length; var c = Math.ceil(len/20); - + Note._renderNotes(notes, forNewNote, isShared, 1); - + // 先设置缓存 for(var i = 0; i < len; ++i) { var note = notes[i]; // 不清空 // 之前是addNoteCache, 如果是搜索出的, 会把内容都重置了 Note.setNoteCache(note, false); - + // 如果是共享的笔记本, 缓存也放在Share下 if(isShared) { Share.setCache(note); } } - + for(var i = 1; i < c; ++i) { setTimeout( (function(i) { @@ -784,7 +784,7 @@ Note._renderNotes = function(notes, forNewNote, isShared, tang) { // 第几趟 if(isShared) { baseClasses = "item-shared"; } - + var len = notes.length; for(var i = (tang-1)*20; i < len && i < tang*20; ++i) { var classes = baseClasses; @@ -803,24 +803,24 @@ Note._renderNotes = function(notes, forNewNote, isShared, tang) { // 第几趟 tmp.find(".item-blog").hide(); } Note.noteItemListO.append(tmp); - + /* // 共享的note也放在Note的cache一份 if(isShared) { note.IsShared = true; // 注明是共享的 } - + // 不清空 // 之前是addNoteCache, 如果是搜索出的, 会把内容都重置了 Note.setNoteCache(note, false); - + // 如果是共享的笔记本, 缓存也放在Share下 if(isShared) { Share.setCache(note); } */ } -} +} // 新建一个笔记 // 要切换到当前的notebook下去新建笔记 @@ -830,29 +830,29 @@ Note.newNote = function(notebookId, isShare, fromUserId, isMarkdown) { // 切换编辑器 switchEditor(isMarkdown); Note.hideEditorMask(); - + // 防止从共享read only跳到添加 Note.hideReadOnly(); - + Note.stopInterval(); // 保存当前的笔记 Note.curChangedSaveIt(); - + var note = {NoteId: getObjectId(), Title: "", Tags:[], Content:"", NotebookId: notebookId, IsNew: true, FromUserId: fromUserId, IsMarkdown: isMarkdown}; // 是新的 // 添加到缓存中 Note.addNoteCache(note); - + // 清空附件数 Attach.clearNoteAttachNum(); - + // 是否是为共享的notebook添加笔记, 如果是, 则还要记录fromUserId var newItem = ""; - + var baseClasses = "item-my"; if(isShare) { baseClasses = "item-shared"; } - + var notebook = Notebook.getNotebook(notebookId); var notebookTitle = notebook ? Note._toHtmlEntity(notebook.Title) : ""; var curDate = getCurDate(); @@ -861,21 +861,21 @@ Note.newNote = function(notebookId, isShare, fromUserId, isMarkdown) { } else { newItem = tt(Note.newItemTpl, baseClasses, "", note.NoteId, Note._toHtmlEntity(note.Title), notebookTitle, curDate, ""); } - + // notebook是否是Blog if(!notebook.IsBlog) { newItem = $(newItem); newItem.find(".item-blog").hide(); } - + // 是否在当前notebook下, 不是则切换过去, 并得到该notebook下所有的notes, 追加到后面! if(!Notebook.isCurNotebook(notebookId)) { // 先清空所有 Note.clearAll(); - + // 插入到第一个位置 Note.noteItemListO.prepend(newItem); - + // 改变为当前的notebookId // 会得到该notebookId的其它笔记 if(!isShare) { @@ -887,15 +887,15 @@ Note.newNote = function(notebookId, isShare, fromUserId, isMarkdown) { // 插入到第一个位置 Note.noteItemListO.prepend(newItem); } - + Note.selectTarget($(tt('[noteId="?"]', note.NoteId))); - + $("#noteTitle").focus(); - + Note.renderNote(note); Note.renderNoteContent(note); Note.curNoteId = note.NoteId; - + // 更新数量 Notebook.incrNotebookNumberNotes(notebookId) } @@ -926,7 +926,7 @@ Note.changeToNext = function(target) { return; } } - + Note.changeNote(next.attr("noteId")); } @@ -944,14 +944,14 @@ Note.deleteNote = function(target, contextmenuItem, isShared) { // 清空信息 Note.clearNoteInfo(); } - + noteId = $(target).attr("noteId"); if(!noteId) { return; } // 1 $(target).hide(); - + // 2 var note = Note.cache[noteId]; var url = "/note/deleteNote" @@ -961,19 +961,19 @@ Note.deleteNote = function(target, contextmenuItem, isShared) { // 减少数量 Notebook.minusNotebookNumberNotes(note.NotebookId); } - + ajaxGet(url, {noteId: noteId, userId: note.UserId, isShared: isShared}, function(ret) { if(ret) { Note.changeToNext(target); - + $(target).remove(); - + // 删除缓存 if(note) { Note.clearCacheByNotebookId(note.NotebookId) delete Note.cache[noteId] } - + showMsg("删除成功!", 500); } else { // 弹出信息 popup 不用点确认的 @@ -981,7 +981,7 @@ Note.deleteNote = function(target, contextmenuItem, isShared) { showMsg("删除失败!", 2000); } }); - + } // 显示共享信息 @@ -989,16 +989,16 @@ Note.listNoteShareUserInfo = function(target) { var noteId = $(target).attr("noteId"); showDialogRemote("/share/listNoteShareUserInfo", {noteId: noteId}); } - + // 共享笔记 Note.shareNote = function(target) { var title = $(target).find(".item-title").text(); showDialog("dialogShareNote", {title: getMsg("shareToFriends") + "-" + title}); - + setTimeout(function() { $("#friendsEmail").focus(); }, 500); - + var noteId = $(target).attr("noteId"); shareNoteOrNotebook(noteId, true); } @@ -1013,7 +1013,7 @@ Note.listNoteContentHistories = function() { options = {} options.show = true; $("#leanoteDialog").modal(options); - + ajaxGet("/noteContentHistory/listHistories", {noteId: Note.curNoteId}, function(re) { if(!isArray(re)) {$content.html(getMsg("noHistories")); return} // 组装成一个tab @@ -1034,7 +1034,7 @@ Note.listNoteContentHistories = function() { $p = $(this).parent().parent(); var seq = $p.attr("seq"); var $c = $p.find(".each-content"); - var info = re[seq]; + var info = re[seq]; if(!info.unfold) { // 默认是折叠的 $(this).text(getMsg("fold")); // 折叠 $c.html(info.Content); @@ -1045,7 +1045,7 @@ Note.listNoteContentHistories = function() { info.unfold = false } }); - + // 还原 $("#historyList .back").click(function() { $p = $(this).parent().parent(); @@ -1060,7 +1060,7 @@ Note.listNoteContentHistories = function() { hideDialog(); } }); - + }); } @@ -1124,9 +1124,9 @@ Note.hideReadOnly = function() { Note.renderNoteReadOnly = function(note) { Note.showReadOnly(); $("#noteReadTitle").text(note.Title); - + Tag.renderReadOnlyTags(note.Tags); - + $("#noteReadCreatedTime").html(goNowToDatetime(note.CreatedTime)); $("#noteReadUpdatedTime").html(goNowToDatetime(note.UpdatedTime)); } @@ -1156,11 +1156,11 @@ Note.isSameSearch = function(key) { Note.lastSearchTime = now; return false; } - + if(key == Note.lastKey) { return true; } - + Note.lastSearchTime = now; Note.lastKey = key; return false; @@ -1177,19 +1177,19 @@ Note.searchNote = function() { if(Note.isSameSearch(val)) { return; } - + // 之前有, 还有结束的 if(Note.lastSearch) { Note.lastSearch.abort(); } - - // 步骤与tag的搜索一样 + + // 步骤与tag的搜索一样 // 1 Note.curChangedSaveIt(); - + // 2 先清空所有 Note.clearAll(); - + // 发送请求之 // 先取消上一个 showLoading(); @@ -1204,10 +1204,10 @@ Note.searchNote = function() { // 第二次搜索来到, Note.curChangedSaveIt(); // 导致没有标题了 // 不是这个原因, 下面的Note.changeNote会导致保存 - + // 设空, 防止发生上述情况 // Note.curNoteId = ""; - + Note.renderNotes(notes); if(!isEmpty(notes)) { Note.changeNote(notes[0].NoteId, false/*, true || Note.isOver2Seconds*/); // isShare, needSaveChanged?, 超过2秒就要保存 @@ -1270,17 +1270,17 @@ Note.moveNote = function(target, data) { var noteId = $(target).attr("noteId"); var note = Note.cache[noteId]; var notebookId = data.notebookId; - + if(!note.IsTrash && note.NotebookId == notebookId) { return; } - + // 修改数量 Notebook.incrNotebookNumberNotes(notebookId); if(!note.IsTrash) { Notebook.minusNotebookNumberNotes(note.NotebookId); } - + ajaxGet("/note/moveNote", {noteId: noteId, notebookId: notebookId}, function(ret) { if(ret && ret.NoteId) { if(note.IsTrash) { @@ -1301,12 +1301,12 @@ Note.moveNote = function(target, data) { // 不移动, 那么要改变其notebook title $(target).find(".note-notebook").html(Notebook.getNotebookTitle(notebookId)); } - + // 重新清空cache 之前的和之后的 Note.clearCacheByNotebookId(note.NotebookId); Note.clearCacheByNotebookId(notebookId); } - + // 改变缓存 Note.setNoteCache(ret) } @@ -1314,24 +1314,24 @@ Note.moveNote = function(target, data) { } // 复制 -// data是自动传来的, 是contextmenu数据 +// data是自动传来的, 是contextmenu数据 Note.copyNote = function(target, data, isShared) { var noteId = $(target).attr("noteId"); var note = Note.cache[noteId]; var notebookId = data.notebookId; - + // trash不能复制, 不能复制给自己 if(note.IsTrash || note.NotebookId == notebookId) { return; } - + var url = "/note/copyNote"; var data = {noteId: noteId, notebookId: notebookId}; if(isShared) { url = "/note/copySharedNote"; data.fromUserId = note.UserId; } - + ajaxGet(url, data, function(ret) { if(ret && ret.NoteId) { // 重新清空cache 之后的 @@ -1340,7 +1340,7 @@ Note.copyNote = function(target, data, isShared) { Note.setNoteCache(ret) } }); - + // 增加数量 Notebook.incrNotebookNumberNotes(notebookId) } @@ -1384,16 +1384,16 @@ Note.initContextmenu = function() { // 得到可移动的notebook var notebooks = Notebook.everNotebooks; var mc = self.getContextNotebooks(notebooks); - + var notebooksMove = mc[0]; var notebooksCopy = mc[1]; self.notebooksCopy = mc[2]; - + //--------------------- // context menu //--------------------- var noteListMenu = { - width: 180, + width: 180, items: [ { text: getMsg("shareToFriends"), alias: 'shareToFriends', icon: "", faIcon: "fa-share-square-o", action: Note.listNoteShareUserInfo}, { type: "splitLine" }, @@ -1405,23 +1405,23 @@ Note.initContextmenu = function() { { type: "splitLine" }, { text: getMsg("delete"), icon: "", faIcon: "fa-trash-o", action: Note.deleteNote }, { text: getMsg("move"), alias: "move", faIcon: "fa-arrow-right", - type: "group", - width: 180, + type: "group", + width: 180, items: notebooksMove }, { text: getMsg("copy"), alias: "copy", icon:"", faIcon: "fa-copy", - type: "group", - width: 180, + type: "group", + width: 180, items: notebooksCopy } - ], + ], onShow: applyrule, onContextMenu: beforeContextMenu, - + parent: "#noteItemList", children: ".item-my", } - + function menuAction(target) { // $('#myModal').modal('show') showDialog("dialogUpdateNotebook", {title: "修改笔记本", postShow: function() { @@ -1435,7 +1435,7 @@ Note.initContextmenu = function() { } // 要disable的items var items = []; - + // 如果是trash, 什么都不能做 if(note.IsTrash) { items.push("shareToFriends"); @@ -1450,7 +1450,7 @@ Note.initContextmenu = function() { } else { items.push("set2Blog"); } - + // 移动与复制不能是本notebook下 var notebookTitle = Notebook.getNotebookTitle(note.NotebookId); items.push("move." + notebookTitle); @@ -1461,20 +1461,20 @@ Note.initContextmenu = function() { name: "target..", disable: true, items: items - }); - + }); + } function beforeContextMenu() { return this.id != "target3"; } - + // 这里很慢!! Note.contextmenu = $("#noteItemList .item-my").contextmenu(noteListMenu); } // 附件 // 笔记的附件需要ajax获取 -// 建一张附件表? attachId, noteId, 其它信息 +// 建一张附件表? attachId, noteId, 其它信息 // note里有attach_nums字段记录个数 // [ok] var Attach = { @@ -1483,7 +1483,7 @@ var Attach = { init: function() { var self = this; // 显示attachs - $("#showAttach").click(function(){ + $("#showAttach").click(function(){ self.renderAttachs(Note.curNoteId); }); // 防止点击隐藏 @@ -1519,7 +1519,7 @@ var Attach = { window.open(UrlPrefix + "/attach/downloadAll?noteId=" + Note.curNoteId); // location.href = "/attach/downloadAll?noteId=" + Note.curNoteId; }); - + // make link self.attachListO.on("click", ".link-attach", function(e) { e.stopPropagation(); @@ -1532,7 +1532,7 @@ var Attach = { tinymce.activeEditor.insertContent('' + attach.Title + ''); } }); - + // make all link self.linkAllBtnO.on("click",function(e) { e.stopPropagation(); @@ -1542,7 +1542,7 @@ var Attach = { } var src = UrlPrefix + "/attach/downloadAll?noteId=" + Note.curNoteId var title = note.Title ? note.Title + ".tar.gz" : "all.tar.gz"; - + if(LEA.isMarkdownEditor() && MD) { MD.insertLink(src, title); } else { @@ -1572,7 +1572,7 @@ var Attach = { self.downloadAllBtnO.hide(); self.linkAllBtnO.hide(); } - + // 隐藏掉 if(needHide) { self.attachDropdownO.removeClass("open"); @@ -1595,17 +1595,17 @@ var Attach = { for(var i = 0; i < attachNum; ++i) { var each = attachs[i]; html += '
  • ' + - '
    ' + each.Title + '
    ' + + '
    ' + Note._toHtmlEntity(each.Title) + '
    ' + '
    ' + - ' ' + + ' ' + ' ' + ' ' + - '
    ' + + '' + '
  • '; self.attachsMap[each.AttachId] = each; } self.attachListO.html(html); - + // 设置数量 var note = Note.getCurNote(); if(note) { @@ -1614,7 +1614,7 @@ var Attach = { } }, // 渲染noteId的附件 - // 当点击"附件"时加载, + // 当点击"附件"时加载, // TODO 判断是否已loaded renderAttachs: function(noteId) { var self = this; @@ -1662,7 +1662,7 @@ var Attach = { // self.loadedNoteAttachs[noteId] = attachs; self.renderAttachs(noteId); }, - + // 下载 downloadAttach: function(fileId) { var self = this; @@ -1675,7 +1675,7 @@ var Attach = { $(function() { // 附件初始化 Attach.init(); - + //----------------- // 点击笔记展示之 // 避免iphone, ipad两次点击 @@ -1688,10 +1688,10 @@ $(function() { $("#noteItemList").on("click", ".item", function(event) { event.stopPropagation(); var noteId = $(this).attr("noteId"); - + // 手机端处理 Mobile.changeNote(noteId); - + if(!noteId) { return; } @@ -1701,7 +1701,7 @@ $(function() { Note.changeNoteForPjax(noteId, true, false); } }); - + //------------------ // 新建笔记 // 1. 直接点击新建 OR @@ -1733,7 +1733,7 @@ $(function() { var key = $(this).val(); Notebook.searchNotebookForList(key); }); - + //--------------------------- // 搜索, 按enter才搜索 /* @@ -1749,20 +1749,20 @@ $(function() { return false; } }); - + //-------------------- // Note.initContextmenu(); - + //------------ // 文档历史 $("#contentHistory").click(function() { Note.listNoteContentHistories() }); - + $("#saveBtn").click(function() { Note.curChangedSaveIt(true); }); - + // blog $("#noteItemList").on("click", ".item-blog", function(e) { e.preventDefault(); @@ -1771,7 +1771,7 @@ $(function() { var noteId = $(this).parent().attr('noteId'); window.open("/blog/view/" + noteId); }); - + // note setting $("#noteItemList").on("click", ".item-my .item-setting", function(e) { e.preventDefault(); diff --git a/public/js/app/notebook-min.js b/public/js/app/notebook-min.js index 4872253..1fef680 100644 --- a/public/js/app/notebook-min.js +++ b/public/js/app/notebook-min.js @@ -1 +1 @@ -Notebook.curNotebookId="";Notebook.cache={};Notebook.notebooks=[];Notebook.notebookNavForListNote="";Notebook.notebookNavForNewNote="";Notebook.setCache=function(notebook){var notebookId=notebook.NotebookId;if(!notebookId){return}if(!Notebook.cache[notebookId]){Notebook.cache[notebookId]={}}$.extend(Notebook.cache[notebookId],notebook)};Notebook.getCurNotebookId=function(){return Notebook.curNotebookId};Notebook._updateNotebookNumberNotes=function(notebookId,n){var self=this;var notebook=self.getNotebook(notebookId);if(!notebook){return}notebook.NumberNotes+=n;if(notebook.NumberNotes<0){notebook.NumberNotes=0}$("#numberNotes_"+notebookId).html(notebook.NumberNotes)};Notebook.incrNotebookNumberNotes=function(notebookId){var self=this;self._updateNotebookNumberNotes(notebookId,1)};Notebook.minusNotebookNumberNotes=function(notebookId){var self=this;self._updateNotebookNumberNotes(notebookId,-1)};Notebook.getNotebook=function(notebookId){return Notebook.cache[notebookId]};Notebook.getNotebookTitle=function(notebookId){var notebook=Notebook.cache[notebookId];if(notebook){return notebook.Title}else{return"未知"}};Notebook.getTreeSetting=function(isSearch,isShare){var noSearch=!isSearch;var self=this;function addDiyDom(treeId,treeNode){var spaceWidth=5;var switchObj=$("#"+treeId+" #"+treeNode.tId+"_switch"),icoObj=$("#"+treeId+" #"+treeNode.tId+"_ico");switchObj.remove();icoObj.before(switchObj);if(!isShare){if(!Notebook.isAllNotebookId(treeNode.NotebookId)&&!Notebook.isTrashNotebookId(treeNode.NotebookId)){icoObj.after($(''+(treeNode.NumberNotes||0)+""));icoObj.after($(''))}}else{if(!Share.isDefaultNotebookId(treeNode.NotebookId)){icoObj.after($(''))}}if(treeNode.level>1){var spaceStr="";switchObj.before(spaceStr)}}function beforeDrag(treeId,treeNodes){for(var i=0,l=treeNodes.length;i
    ?
    M
    ',classes,notebook.NotebookId,notebook.Title,notebook.NotebookId);if(!isEmpty(notebook.Subs)){eachForNew+=""}eachForNew+="";navForNewNote+=eachForNew}return navForNewNote};Notebook.everNavForNewNote="";Notebook.everNotebooks=[];Notebook.changeNav=function(){var self=Notebook;var notebooks=Notebook.tree.getNodes();var pureNotebooks=notebooks.slice(1,-1);var html=self.getChangedNotebooks(pureNotebooks);self.everNavForNewNote=html;self.everNotebooks=pureNotebooks;$("#notebookNavForNewNote").html(html);var t1=(new Date).getTime();Note.initContextmenu();Share.initContextmenu(Note.notebooksCopy);var t2=(new Date).getTime();log(t2-t1)};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){var userNotebooks=shareNotebooks[i];user2ShareNotebooks[userNotebooks.UserId]=userNotebooks}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;var header=tt('
    ',username,username);var body='
      ';for(var j in userNotebooks.ShareNotebooks){var notebook=userNotebooks.ShareNotebooks[j];body+=tt('
    • ?
    • ',notebook.NotebookId,notebook.Title)}body+="
    ";$shareNotebooks.append(header+body+"
    ")}};Notebook.selectNotebook=function(target){$(".notebook-item").removeClass("curSelectedNode");$(target).addClass("curSelectedNode")};Notebook.changeNotebookNavForNewNote=function(notebookId,title){if(!notebookId){var notebook=Notebook.notebooks[0];notebookId=notebook.NotebookId;title=notebook.Title}if(!title){var notebook=Notebook.cache[0];title=notebook.Title}if(!Notebook.isAllNotebookId(notebookId)&&!Notebook.isTrashNotebookId(notebookId)){$("#curNotebookForNewNote").html(title).attr("notebookId",notebookId)}else if(!$("#curNotebookForNewNote").attr("notebookId")){if(Notebook.notebooks.length>2){var notebook=Notebook.notebooks[1];notebookId=notebook.NotebookId;title=notebook.Title;Notebook.changeNotebookNavForNewNote(notebookId,title)}}};Notebook.toggleToMyNav=function(userId,notebookId){$("#sharedNotebookNavForListNav").hide();$("#myNotebookNavForListNav").show();$("#newMyNote").show();$("#newSharedNote").hide();$("#tagSearch").hide()};Notebook.changeNotebookNav=function(notebookId){Notebook.curNotebookId=notebookId;Notebook.toggleToMyNav();Notebook.selectNotebook($(tt('#notebook [notebookId="?"]',notebookId)));var notebook=Notebook.cache[notebookId];if(!notebook){return}$("#curNotebookForListNote").html(notebook.Title);Notebook.changeNotebookNavForNewNote(notebookId,notebook.Title)};Notebook.isAllNotebookId=function(notebookId){return notebookId==Notebook.allNotebookId};Notebook.isTrashNotebookId=function(notebookId){return notebookId==Notebook.trashNotebookId};Notebook.curActiveNotebookIsAll=function(){return Notebook.isAllNotebookId($("#notebookList .active").attr("notebookId"))};Notebook.changeNotebook=function(notebookId,callback){var me=this;Notebook.changeNotebookNav(notebookId);Notebook.curNotebookId=notebookId;Note.curChangedSaveIt();Note.clearAll();var url="/note/listNotes/";var param={notebookId:notebookId};if(Notebook.isTrashNotebookId(notebookId)){url="/note/listTrashNotes";param={}}else if(Notebook.isAllNotebookId(notebookId)){param={};cacheNotes=Note.getNotesByNotebookId();if(!isEmpty(cacheNotes)){if(callback){callback(cacheNotes)}else{Note.renderNotesAndFirstOneContent(cacheNotes)}return}}else{cacheNotes=Note.getNotesByNotebookId(notebookId);if(!isEmpty(cacheNotes)){if(callback){callback(cacheNotes)}else{Note.renderNotesAndFirstOneContent(cacheNotes)}return}}me.showNoteAndEditorLoading();ajaxGet(url,param,function(cacheNotes){if(callback){callback(cacheNotes)}else{Note.renderNotesAndFirstOneContent(cacheNotes)}me.hideNoteAndEditorLoading()})};Notebook.showNoteAndEditorLoading=function(){$("#noteAndEditorMask").show()};Notebook.hideNoteAndEditorLoading=function(){$("#noteAndEditorMask").hide()};Notebook.isCurNotebook=function(notebookId){return $(tt('#notebookList [notebookId="?"], #shareNotebooks [notebookId="?"]',notebookId,notebookId)).attr("class")=="active"};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};ajaxGet(url,param,function(ret){Note.renderNotes(ret,true)})};Notebook.listNotebookShareUserInfo=function(target){var notebookId=$(target).attr("notebookId");showDialogRemote("/share/listNotebookShareUserInfo",{notebookId:notebookId})};Notebook.shareNotebooks=function(target){var title=$(target).text();showDialog("dialogShareNote",{title:"分享笔记本给好友-"+title});setTimeout(function(){$("#friendsEmail").focus()},500);var notebookId=$(target).attr("notebookId");shareNoteOrNotebook(notebookId,false)};Notebook.setNotebook2Blog=function(target){var notebookId=$(target).attr("notebookId");var notebook=Notebook.cache[notebookId];var isBlog=true;if(notebook.IsBlog!=undefined){isBlog=!notebook.IsBlog}if(Notebook.curNotebookId==notebookId){if(isBlog){$("#noteList .item-blog").show()}else{$("#noteList .item-blog").hide()}}else if(Notebook.curNotebookId==Notebook.allNotebookId){$("#noteItemList .item").each(function(){var noteId=$(this).attr("noteId");var note=Note.cache[noteId];if(note.NotebookId==notebookId){if(isBlog)$(this).find(".item-blog").show();else $(this).find(".item-blog").hide()}})}ajaxPost("/notebook/setNotebook2Blog",{notebookId:notebookId,isBlog:isBlog},function(ret){if(ret){Note.setAllNoteBlogStatus(notebookId,isBlog);Notebook.setCache({NotebookId:notebookId,IsBlog:isBlog})}})};Notebook.updateNotebookTitle=function(target){var self=Notebook;var notebookId=$(target).attr("notebookId");if(self.tree2){self.tree2.editName(self.tree2.getNodeByTId(notebookId))}else{self.tree.editName(self.tree.getNodeByTId(notebookId))}};Notebook.doUpdateNotebookTitle=function(notebookId,newTitle){var self=Notebook;ajaxPost("/notebook/updateNotebookTitle",{notebookId:notebookId,title:newTitle},function(ret){Notebook.cache[notebookId].Title=newTitle;Notebook.changeNav();if(self.tree2){var notebook=self.tree.getNodeByTId(notebookId);notebook.Title=newTitle;self.tree.updateNode(notebook)}})};Notebook.addNotebookSeq=1;Notebook.addNotebook=function(){var self=Notebook;if($("#myNotebooks").hasClass("closed")){$("#myNotebooks .folderHeader").trigger("click")}self.tree.addNodes(null,{Title:"",NotebookId:getObjectId(),IsNew:true},true,true)};Notebook.doAddNotebook=function(notebookId,title,parentNotebookId){var self=Notebook;ajaxPost("/notebook/addNotebook",{notebookId:notebookId,title:title,parentNotebookId:parentNotebookId},function(ret){if(ret.NotebookId){Notebook.cache[ret.NotebookId]=ret;var notebook=self.tree.getNodeByTId(notebookId);$.extend(notebook,ret);notebook.IsNew=false;Notebook.changeNotebook(notebookId);Notebook.changeNav()}})};Notebook.addChildNotebook=function(target){var self=Notebook;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)};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){self.tree.removeNode(self.tree.getNodeByTId(notebookId));if(self.tree2){self.tree2.removeNode(self.tree2.getNodeByTId(notebookId))}delete Notebook.cache[notebookId];Notebook.changeNav()}else{alert(ret.Msg)}})};$(function(){$("#minNotebookList").on("click","li",function(){var notebookId=$(this).find("a").attr("notebookId");Notebook.changeNotebook(notebookId)});var notebookListMenu={width:180,items:[{text:getMsg("shareToFriends"),alias:"shareToFriends",icon:"",faIcon:"fa-share-square-o",action:Notebook.listNotebookShareUserInfo},{type:"splitLine"},{text:getMsg("publicAsBlog"),alias:"set2Blog",faIcon:"fa-bold",action:Notebook.setNotebook2Blog},{text:getMsg("cancelPublic"),alias:"unset2Blog",faIcon:"fa-undo",action:Notebook.setNotebook2Blog},{type:"splitLine"},{text:getMsg("addChildNotebook"),faIcon:"fa-sitemap",action:Notebook.addChildNotebook},{text:getMsg("rename"),faIcon:"fa-pencil",action:Notebook.updateNotebookTitle},{text:getMsg("delete"),icon:"",alias:"delete",faIcon:"fa-trash-o",action:Notebook.deleteNotebook}],onShow:applyrule,onContextMenu:beforeContextMenu,parent:"#notebookList ",children:"li a"};var notebookListMenu2={width:180,items:[{text:getMsg("shareToFriends"),alias:"shareToFriends",icon:"",faIcon:"fa-share-square-o",action:Notebook.listNotebookShareUserInfo},{type:"splitLine"},{text:getMsg("publicAsBlog"),alias:"set2Blog",faIcon:"fa-bold",action:Notebook.setNotebook2Blog},{text:getMsg("cancelPublic"),alias:"unset2Blog",faIcon:"fa-undo",action:Notebook.setNotebook2Blog},{type:"splitLine"},{text:getMsg("rename"),icon:"",action:Notebook.updateNotebookTitle},{text:getMsg("delete"),icon:"",alias:"delete",faIcon:"fa-trash-o",action:Notebook.deleteNotebook}],onShow:applyrule,onContextMenu:beforeContextMenu,parent:"#notebookListForSearch ",children:"li a"};function applyrule(menu){var notebookId=$(this).attr("notebookId");var notebook=Notebook.cache[notebookId];if(!notebook){return}var items=[];if(!notebook.IsBlog){items.push("unset2Blog")}else{items.push("set2Blog")}if(Note.notebookHasNotes(notebookId)){items.push("delete")}menu.applyrule({name:"target2",disable:true,items:items})}function beforeContextMenu(){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()});$("#notebookList").on("click",".notebook-setting",function(e){e.preventDefault();e.stopPropagation();var $p=$(this).parent();Notebook.contextmenu.showMenu(e,$p)});$("#notebookListForSearch").on("click",".notebook-setting",function(e){e.preventDefault();e.stopPropagation();var $p=$(this).parent();Notebook.contextmenuSearch.showMenu(e,$p)})}); \ No newline at end of file +Notebook.curNotebookId="";Notebook.cache={};Notebook.notebooks=[];Notebook.notebookNavForListNote="";Notebook.notebookNavForNewNote="";Notebook.setCache=function(notebook){var notebookId=notebook.NotebookId;if(!notebookId){return}if(!Notebook.cache[notebookId]){Notebook.cache[notebookId]={}}$.extend(Notebook.cache[notebookId],notebook)};Notebook.getCurNotebookId=function(){return Notebook.curNotebookId};Notebook._updateNotebookNumberNotes=function(notebookId,n){var self=this;var notebook=self.getNotebook(notebookId);if(!notebook){return}notebook.NumberNotes+=n;if(notebook.NumberNotes<0){notebook.NumberNotes=0}$("#numberNotes_"+notebookId).html(notebook.NumberNotes)};Notebook.incrNotebookNumberNotes=function(notebookId){var self=this;self._updateNotebookNumberNotes(notebookId,1)};Notebook.minusNotebookNumberNotes=function(notebookId){var self=this;self._updateNotebookNumberNotes(notebookId,-1)};Notebook.getNotebook=function(notebookId){return Notebook.cache[notebookId]};Notebook.getNotebookTitle=function(notebookId){var notebook=Notebook.cache[notebookId];if(notebook){return Note._toHtmlEntity(notebook.Title)}else{return"未知"}};Notebook.getTreeSetting=function(isSearch,isShare){var noSearch=!isSearch;var self=this;function addDiyDom(treeId,treeNode){var spaceWidth=5;var switchObj=$("#"+treeId+" #"+treeNode.tId+"_switch"),icoObj=$("#"+treeId+" #"+treeNode.tId+"_ico");switchObj.remove();icoObj.before(switchObj);if(!isShare){if(!Notebook.isAllNotebookId(treeNode.NotebookId)&&!Notebook.isTrashNotebookId(treeNode.NotebookId)){icoObj.after($(''+(treeNode.NumberNotes||0)+""));icoObj.after($(''))}}else{if(!Share.isDefaultNotebookId(treeNode.NotebookId)){icoObj.after($(''))}}if(treeNode.level>1){var spaceStr="";switchObj.before(spaceStr)}}function beforeDrag(treeId,treeNodes){for(var i=0,l=treeNodes.length;i
    ?
    M
    ',classes,notebook.NotebookId,Note._toHtmlEntity(notebook.Title),notebook.NotebookId);if(!isEmpty(notebook.Subs)){eachForNew+=""}eachForNew+="";navForNewNote+=eachForNew}return navForNewNote};Notebook.everNavForNewNote="";Notebook.everNotebooks=[];Notebook.changeNav=function(){var self=Notebook;var notebooks=Notebook.tree.getNodes();var pureNotebooks=notebooks.slice(1,-1);var html=self.getChangedNotebooks(pureNotebooks);self.everNavForNewNote=html;self.everNotebooks=pureNotebooks;$("#notebookNavForNewNote").html(html);var t1=(new Date).getTime();Note.initContextmenu();Share.initContextmenu(Note.notebooksCopy);var t2=(new Date).getTime();log(t2-t1)};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){var userNotebooks=shareNotebooks[i];user2ShareNotebooks[userNotebooks.UserId]=userNotebooks}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;var header=tt('
    ',username,username);var body='
      ';for(var j in userNotebooks.ShareNotebooks){var notebook=userNotebooks.ShareNotebooks[j];body+=tt('
    • ?
    • ',notebook.NotebookId,Note._toHtmlEntity(notebook.Title))}body+="
    ";$shareNotebooks.append(header+body+"
    ")}};Notebook.selectNotebook=function(target){$(".notebook-item").removeClass("curSelectedNode");$(target).addClass("curSelectedNode")};Notebook.changeNotebookNavForNewNote=function(notebookId,title){if(!notebookId){var notebook=Notebook.notebooks[0];notebookId=notebook.NotebookId;title=notebook.Title}if(!title){var notebook=Notebook.cache[0];title=notebook.Title}if(!Notebook.isAllNotebookId(notebookId)&&!Notebook.isTrashNotebookId(notebookId)){$("#curNotebookForNewNote").text(title).attr("notebookId",notebookId)}else if(!$("#curNotebookForNewNote").attr("notebookId")){if(Notebook.notebooks.length>2){var notebook=Notebook.notebooks[1];notebookId=notebook.NotebookId;title=notebook.Title;Notebook.changeNotebookNavForNewNote(notebookId,title)}}};Notebook.toggleToMyNav=function(userId,notebookId){$("#sharedNotebookNavForListNav").hide();$("#myNotebookNavForListNav").show();$("#newMyNote").show();$("#newSharedNote").hide();$("#tagSearch").hide()};Notebook.changeNotebookNav=function(notebookId){Notebook.curNotebookId=notebookId;Notebook.toggleToMyNav();Notebook.selectNotebook($(tt('#notebook [notebookId="?"]',notebookId)));var notebook=Notebook.cache[notebookId];if(!notebook){return}$("#curNotebookForListNote").text(notebook.Title);Notebook.changeNotebookNavForNewNote(notebookId,notebook.Title)};Notebook.isAllNotebookId=function(notebookId){return notebookId==Notebook.allNotebookId};Notebook.isTrashNotebookId=function(notebookId){return notebookId==Notebook.trashNotebookId};Notebook.curActiveNotebookIsAll=function(){return Notebook.isAllNotebookId($("#notebookList .active").attr("notebookId"))};Notebook.changeNotebook=function(notebookId,callback){var me=this;Notebook.changeNotebookNav(notebookId);Notebook.curNotebookId=notebookId;Note.curChangedSaveIt();Note.clearAll();var url="/note/listNotes/";var param={notebookId:notebookId};if(Notebook.isTrashNotebookId(notebookId)){url="/note/listTrashNotes";param={}}else if(Notebook.isAllNotebookId(notebookId)){param={};cacheNotes=Note.getNotesByNotebookId();if(!isEmpty(cacheNotes)){if(callback){callback(cacheNotes)}else{Note.renderNotesAndFirstOneContent(cacheNotes)}return}}else{cacheNotes=Note.getNotesByNotebookId(notebookId);if(!isEmpty(cacheNotes)){if(callback){callback(cacheNotes)}else{Note.renderNotesAndFirstOneContent(cacheNotes)}return}}me.showNoteAndEditorLoading();ajaxGet(url,param,function(cacheNotes){if(callback){callback(cacheNotes)}else{Note.renderNotesAndFirstOneContent(cacheNotes)}me.hideNoteAndEditorLoading()})};Notebook.showNoteAndEditorLoading=function(){$("#noteAndEditorMask").show()};Notebook.hideNoteAndEditorLoading=function(){$("#noteAndEditorMask").hide()};Notebook.isCurNotebook=function(notebookId){return $(tt('#notebookList [notebookId="?"], #shareNotebooks [notebookId="?"]',notebookId,notebookId)).attr("class")=="active"};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};ajaxGet(url,param,function(ret){Note.renderNotes(ret,true)})};Notebook.listNotebookShareUserInfo=function(target){var notebookId=$(target).attr("notebookId");showDialogRemote("/share/listNotebookShareUserInfo",{notebookId:notebookId})};Notebook.shareNotebooks=function(target){var title=$(target).text();showDialog("dialogShareNote",{title:"分享笔记本给好友-"+title});setTimeout(function(){$("#friendsEmail").focus()},500);var notebookId=$(target).attr("notebookId");shareNoteOrNotebook(notebookId,false)};Notebook.setNotebook2Blog=function(target){var notebookId=$(target).attr("notebookId");var notebook=Notebook.cache[notebookId];var isBlog=true;if(notebook.IsBlog!=undefined){isBlog=!notebook.IsBlog}if(Notebook.curNotebookId==notebookId){if(isBlog){$("#noteList .item-blog").show()}else{$("#noteList .item-blog").hide()}}else if(Notebook.curNotebookId==Notebook.allNotebookId){$("#noteItemList .item").each(function(){var noteId=$(this).attr("noteId");var note=Note.cache[noteId];if(note.NotebookId==notebookId){if(isBlog)$(this).find(".item-blog").show();else $(this).find(".item-blog").hide()}})}ajaxPost("/notebook/setNotebook2Blog",{notebookId:notebookId,isBlog:isBlog},function(ret){if(ret){Note.setAllNoteBlogStatus(notebookId,isBlog);Notebook.setCache({NotebookId:notebookId,IsBlog:isBlog})}})};Notebook.updateNotebookTitle=function(target){var self=Notebook;var notebookId=$(target).attr("notebookId");if(self.tree2){self.tree2.editName(self.tree2.getNodeByTId(notebookId))}else{self.tree.editName(self.tree.getNodeByTId(notebookId))}};Notebook.doUpdateNotebookTitle=function(notebookId,newTitle){var self=Notebook;ajaxPost("/notebook/updateNotebookTitle",{notebookId:notebookId,title:newTitle},function(ret){Notebook.cache[notebookId].Title=newTitle;Notebook.changeNav();if(self.tree2){var notebook=self.tree.getNodeByTId(notebookId);notebook.Title=newTitle;self.tree.updateNode(notebook)}})};Notebook.addNotebookSeq=1;Notebook.addNotebook=function(){var self=Notebook;if($("#myNotebooks").hasClass("closed")){$("#myNotebooks .folderHeader").trigger("click")}self.tree.addNodes(null,{Title:"",NotebookId:getObjectId(),IsNew:true},true,true)};Notebook.doAddNotebook=function(notebookId,title,parentNotebookId){var self=Notebook;ajaxPost("/notebook/addNotebook",{notebookId:notebookId,title:title,parentNotebookId:parentNotebookId},function(ret){if(ret.NotebookId){Notebook.cache[ret.NotebookId]=ret;var notebook=self.tree.getNodeByTId(notebookId);$.extend(notebook,ret);notebook.IsNew=false;Notebook.changeNotebook(notebookId);Notebook.changeNav()}})};Notebook.addChildNotebook=function(target){var self=Notebook;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)};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){self.tree.removeNode(self.tree.getNodeByTId(notebookId));if(self.tree2){self.tree2.removeNode(self.tree2.getNodeByTId(notebookId))}delete Notebook.cache[notebookId];Notebook.changeNav()}else{alert(ret.Msg)}})};$(function(){$("#minNotebookList").on("click","li",function(){var notebookId=$(this).find("a").attr("notebookId");Notebook.changeNotebook(notebookId)});var notebookListMenu={width:180,items:[{text:getMsg("shareToFriends"),alias:"shareToFriends",icon:"",faIcon:"fa-share-square-o",action:Notebook.listNotebookShareUserInfo},{type:"splitLine"},{text:getMsg("publicAsBlog"),alias:"set2Blog",faIcon:"fa-bold",action:Notebook.setNotebook2Blog},{text:getMsg("cancelPublic"),alias:"unset2Blog",faIcon:"fa-undo",action:Notebook.setNotebook2Blog},{type:"splitLine"},{text:getMsg("addChildNotebook"),faIcon:"fa-sitemap",action:Notebook.addChildNotebook},{text:getMsg("rename"),faIcon:"fa-pencil",action:Notebook.updateNotebookTitle},{text:getMsg("delete"),icon:"",alias:"delete",faIcon:"fa-trash-o",action:Notebook.deleteNotebook}],onShow:applyrule,onContextMenu:beforeContextMenu,parent:"#notebookList ",children:"li a"};var notebookListMenu2={width:180,items:[{text:getMsg("shareToFriends"),alias:"shareToFriends",icon:"",faIcon:"fa-share-square-o",action:Notebook.listNotebookShareUserInfo},{type:"splitLine"},{text:getMsg("publicAsBlog"),alias:"set2Blog",faIcon:"fa-bold",action:Notebook.setNotebook2Blog},{text:getMsg("cancelPublic"),alias:"unset2Blog",faIcon:"fa-undo",action:Notebook.setNotebook2Blog},{type:"splitLine"},{text:getMsg("rename"),icon:"",action:Notebook.updateNotebookTitle},{text:getMsg("delete"),icon:"",alias:"delete",faIcon:"fa-trash-o",action:Notebook.deleteNotebook}],onShow:applyrule,onContextMenu:beforeContextMenu,parent:"#notebookListForSearch ",children:"li a"};function applyrule(menu){var notebookId=$(this).attr("notebookId");var notebook=Notebook.cache[notebookId];if(!notebook){return}var items=[];if(!notebook.IsBlog){items.push("unset2Blog")}else{items.push("set2Blog")}if(Note.notebookHasNotes(notebookId)){items.push("delete")}menu.applyrule({name:"target2",disable:true,items:items})}function beforeContextMenu(){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()});$("#notebookList").on("click",".notebook-setting",function(e){e.preventDefault();e.stopPropagation();var $p=$(this).parent();Notebook.contextmenu.showMenu(e,$p)});$("#notebookListForSearch").on("click",".notebook-setting",function(e){e.preventDefault();e.stopPropagation();var $p=$(this).parent();Notebook.contextmenuSearch.showMenu(e,$p)})}); \ No newline at end of file diff --git a/public/js/app/notebook.js b/public/js/app/notebook.js index e5f2e73..a7390b6 100644 --- a/public/js/app/notebook.js +++ b/public/js/app/notebook.js @@ -1,7 +1,7 @@ Notebook.curNotebookId = ""; Notebook.cache = {}; // notebookId => {}; Notebook.notebooks = []; // 按次序 -//
  • CSS
  • +//
  • CSS
  • Notebook.notebookNavForListNote = ""; // html 为了note list上面和新建时的ul Notebook.notebookNavForNewNote = ""; // html 为了note list上面和新建时的ul @@ -54,7 +54,7 @@ Notebook.getNotebook = function(notebookId) { Notebook.getNotebookTitle = function(notebookId) { var notebook = Notebook.cache[notebookId]; if(notebook) { - return notebook.Title; + return Note._toHtmlEntity(notebook.Title); } else { return "未知"; } @@ -68,10 +68,10 @@ Notebook.getNotebookTitle = function(notebookId) {
  • August 13, 2013
  • */ - -Notebook.getTreeSetting = function(isSearch, isShare){ + +Notebook.getTreeSetting = function(isSearch, isShare){ var noSearch = !isSearch; - + var self = this; // 添加自定义dom function addDiyDom(treeId, treeNode) { @@ -116,15 +116,15 @@ Notebook.getTreeSetting = function(isSearch, isShare){ var parentNode; var treeObj = self.tree; var ajaxData = {curNotebookId: treeNode.NotebookId}; - + // 成为子节点, 那么只需要得到targetNode下所有的子结点即可 if(moveType == "inner") { parentNode = targetNode; } else { parentNode = targetNode.getParentNode(); } - - // 在targetNode之前或之后, + + // 在targetNode之前或之后, // 那么: 1) 需要将该parentNode下所有的node重新排序即可; 2) treeNodes[0]为parentNode的子 if(!parentNode) { var nodes = treeObj.getNodes(); // 得到所有nodes @@ -136,7 +136,7 @@ Notebook.getTreeSetting = function(isSearch, isShare){ } var nodes = treeObj.getNodesByFilter(filter, false, parentNode); } - + ajaxData.siblings = []; for(var i in nodes) { var notebookId = nodes[i].NotebookId; @@ -144,15 +144,15 @@ Notebook.getTreeSetting = function(isSearch, isShare){ ajaxData.siblings.push(notebookId); } } - + ajaxPost("/notebook/dragNotebooks", {data: JSON.stringify(ajaxData)}); - + // 这里慢! setTimeout(function() { Notebook.changeNav(); }, 100); } - + if(!isShare) { var onClick = function(e, treeId, treeNode) { var notebookId = treeNode.NotebookId; @@ -172,7 +172,7 @@ Notebook.getTreeSetting = function(isSearch, isShare){ }; var onDblClick = null; } - + var setting = { view: { showLine: false, @@ -216,12 +216,12 @@ Notebook.getTreeSetting = function(isSearch, isShare){ if(treeNode.Title == newName) { return true; } - + // 如果是新添加的 if(treeNode.IsNew) { var parentNode = treeNode.getParentNode(); var parentNotebookId = parentNode ? parentNode.NotebookId : ""; - + self.doAddNotebook(treeNode.NotebookId, newName, parentNotebookId); } else { self.doUpdateNotebookTitle(treeNode.NotebookId, newName); @@ -230,11 +230,11 @@ Notebook.getTreeSetting = function(isSearch, isShare){ } } }; - + // 搜索不能拖拽 if(isSearch) { } - + return setting; } Notebook.allNotebookId = "0"; @@ -248,13 +248,13 @@ Notebook.renderNotebooks = function(notebooks) { if(!notebooks || typeof notebooks != "object" || notebooks.length < 0) { notebooks = []; } - + notebooks = [{NotebookId: Notebook.allNotebookId, Title: getMsg("all"), drop:false, drag: false}].concat(notebooks); notebooks.push({NotebookId: Notebook.trashNotebookId, Title: getMsg("trash"), drop:false, drag: false}); Notebook.notebooks = notebooks; // 缓存之 - + self.tree = $.fn.zTree.init($("#notebookList"), self.getTreeSetting(), notebooks); - + // 展开/折叠图标 var $notebookList = $("#notebookList"); $notebookList.hover(function () { @@ -264,16 +264,16 @@ Notebook.renderNotebooks = function(notebooks) { }, function() { $(this).removeClass("showIcon"); }); - + // 缓存所有notebooks信息 if(!isEmpty(notebooks)) { Notebook.curNotebookId = notebooks[0].NotebookId; self.cacheAllNotebooks(notebooks); } - + // 渲染nav Notebook.renderNav(); - + // 渲染第一个notebook作为当前 Notebook.changeNotebookNavForNewNote(notebooks[0].NotebookId); } @@ -294,7 +294,7 @@ Notebook.expandNotebookTo = function(notebookId, userId) { var me = this; var selected = false; var tree = me.tree; - + // 共享的 if(userId) { tree = Share.trees[userId]; @@ -325,7 +325,7 @@ Notebook.expandNotebookTo = function(notebookId, userId) { } -// RenderNotebooks调用, +// RenderNotebooks调用, // nav 为了新建, 快速选择, 移动笔记 // 这些在添加,修改,删除notebooks都要变动!!! Notebook.renderNav = function(nav) { @@ -365,7 +365,7 @@ Notebook.searchNotebookForList = function(key) { if(key) { $search.show(); $notebookList.hide(); - + var notebooks = self.tree.getNodesByParamFuzzy("Title", key); log('search'); log(notebooks); @@ -390,25 +390,25 @@ Notebook.searchNotebookForList = function(key) { Notebook.getChangedNotebooks = function(notebooks) { var self = this; var navForNewNote = ""; - + var len = notebooks.length; for(var i = 0; i < len; ++i) { var notebook = notebooks[i]; - + var classes = ""; if(!isEmpty(notebook.Subs)) { classes = "dropdown-submenu"; } - var eachForNew = tt(''; - + navForNewNote += eachForNew; } return navForNewNote; @@ -421,12 +421,12 @@ Notebook.changeNav = function() { var notebooks = Notebook.tree.getNodes(); var pureNotebooks = notebooks.slice(1, -1); // 不含新和垃圾 var html = self.getChangedNotebooks(pureNotebooks); - + self.everNavForNewNote = html; self.everNotebooks = pureNotebooks; - + $("#notebookNavForNewNote").html(html); - + // 移动, 复制重新来, 因为nav变了, 移动至-----的notebook导航也变了 // 这里速度很慢 var t1 = (new Date()).getTime(); @@ -437,13 +437,13 @@ Notebook.changeNav = function() { } /** - * 我的共享notebooks + * 我的共享notebooks
    @@ -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);