From b135f9717f0f210160c95b7d8ba94f33b9cff8a3 Mon Sep 17 00:00:00 2001
From: lealife
Date: Fri, 25 Dec 2015 11:45:46 +0800
Subject: [PATCH] fix gen desc
---
public/js/app/note.js | 39 ++++++++++-----------------------------
1 file changed, 10 insertions(+), 29 deletions(-)
diff --git a/public/js/app/note.js b/public/js/app/note.js
index 2b28e94..078ff49 100644
--- a/public/js/app/note.js
+++ b/public/js/app/note.js
@@ -311,38 +311,18 @@ Note.genDesc = function(content) {
return "";
}
- // 将,
替换成\n
- /*
- var token = "ALEALE";
- 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();
-
-
+ content = content.replace(/
/g," ");
+ content = content.replace(/<\/p>/g," ");
+ content = content.replace(/<\/div>/g," ");
+
+ // 将html tags全部删除
+ content = content.replace(/<\/?[^>]+(>|$)/g, "");
+ content = $.trim(content);
// pre下text()会将< => < > => >
content = content.replace(//g, ">");
-
+
if(content.length < 300) {
return content;
}
@@ -727,7 +707,7 @@ Note.renderChangedNote = function(changedNote) {
$leftNoteNav.find(".item-title").html(trimTitle(changedNote.Title));
}
if(changedNote.Desc) {
- $leftNoteNav.find(".desc").html(changedNote.Desc);
+ $leftNoteNav.find(".desc").html(trimTitle(changedNote.Desc));
}
if(changedNote.ImgSrc) {
$thumb = $leftNoteNav.find(".item-thumb");
@@ -2470,6 +2450,7 @@ $(function() {
Note.curChangedSaveIt(true);
});
+
// blog
Note.$itemList.on("click", ".item-blog", function(e) {
e.preventDefault();