Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo
Commits
2afdf994
Commit
2afdf994
authored
Dec 18, 2015
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #12052
parent
ece81052
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
108 additions
and
63 deletions
+108
-63
src/main/java/org/b3log/solo/SoloServletListener.java
src/main/java/org/b3log/solo/SoloServletListener.java
+2
-7
src/main/java/org/b3log/solo/event/comment/ArticleCommentReplyNotifier.java
...b3log/solo/event/comment/ArticleCommentReplyNotifier.java
+1
-1
src/main/java/org/b3log/solo/event/comment/PageCommentReplyNotifier.java
...rg/b3log/solo/event/comment/PageCommentReplyNotifier.java
+1
-1
src/main/java/org/b3log/solo/processor/CommentProcessor.java
src/main/java/org/b3log/solo/processor/CommentProcessor.java
+5
-3
src/main/java/org/b3log/solo/processor/util/Filler.java
src/main/java/org/b3log/solo/processor/util/Filler.java
+4
-6
src/main/java/org/b3log/solo/service/CommentMgmtService.java
src/main/java/org/b3log/solo/service/CommentMgmtService.java
+35
-14
src/main/java/org/b3log/solo/service/CommentQueryService.java
...main/java/org/b3log/solo/service/CommentQueryService.java
+21
-22
src/main/java/org/b3log/solo/service/InitService.java
src/main/java/org/b3log/solo/service/InitService.java
+2
-3
src/main/java/org/b3log/solo/service/UpgradeService.java
src/main/java/org/b3log/solo/service/UpgradeService.java
+28
-1
src/main/resources/lang_zh_CN.properties
src/main/resources/lang_zh_CN.properties
+2
-2
src/main/webapp/js/page.js
src/main/webapp/js/page.js
+5
-1
src/main/webapp/js/page.min.js
src/main/webapp/js/page.min.js
+1
-1
src/main/webapp/skins/yilia/macro-comments.ftl
src/main/webapp/skins/yilia/macro-comments.ftl
+1
-1
No files found.
src/main/java/org/b3log/solo/SoloServletListener.java
View file @
2afdf994
...
...
@@ -56,7 +56,7 @@ import org.json.JSONObject;
* Solo Servlet listener.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.7.0.1
1, Dec 13
, 2015
* @version 1.7.0.1
2, Dec 17
, 2015
* @since 0.3.1
*/
public
final
class
SoloServletListener
extends
AbstractServletListener
{
...
...
@@ -76,11 +76,6 @@ public final class SoloServletListener extends AbstractServletListener {
*/
public
static
final
int
JSON_PRINT_INDENT_FACTOR
=
4
;
/**
* Enter escape.
*/
public
static
final
String
ENTER_ESC
=
"_esc_enter_88250_"
;
/**
* B3log Rhythm address.
*/
...
...
src/main/java/org/b3log/solo/event/comment/ArticleCommentReplyNotifier.java
View file @
2afdf994
...
...
@@ -102,7 +102,7 @@ public final class ArticleCommentReplyNotifier extends AbstractEventListener<JSO
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_BLOG_TITLE
);
final
String
adminEmail
=
preference
.
getString
(
Option
.
ID_C_ADMIN_EMAIL
);
final
String
commentContent
=
comment
.
getString
(
Comment
.
COMMENT_CONTENT
)
.
replaceAll
(
SoloServletListener
.
ENTER_ESC
,
"<br/>"
)
;
final
String
commentContent
=
comment
.
getString
(
Comment
.
COMMENT_CONTENT
);
final
String
commentSharpURL
=
comment
.
getString
(
Comment
.
COMMENT_SHARP_URL
);
final
Message
message
=
new
Message
();
...
...
src/main/java/org/b3log/solo/event/comment/PageCommentReplyNotifier.java
View file @
2afdf994
...
...
@@ -97,7 +97,7 @@ public final class PageCommentReplyNotifier extends AbstractEventListener<JSONOb
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_BLOG_TITLE
);
final
String
adminEmail
=
preference
.
getString
(
Option
.
ID_C_ADMIN_EMAIL
);
final
String
commentContent
=
comment
.
getString
(
Comment
.
COMMENT_CONTENT
)
.
replaceAll
(
SoloServletListener
.
ENTER_ESC
,
"<br/>"
)
;
final
String
commentContent
=
comment
.
getString
(
Comment
.
COMMENT_CONTENT
);
final
String
commentSharpURL
=
comment
.
getString
(
Comment
.
COMMENT_SHARP_URL
);
final
Message
message
=
new
Message
();
...
...
src/main/java/org/b3log/solo/processor/CommentProcessor.java
View file @
2afdf994
...
...
@@ -48,7 +48,7 @@ import org.json.JSONObject;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author ArmstrongCN
* @version 1.
1.1.12, Apr 10, 2014
* @version 1.
2.1.12, Dec 17, 2015
* @since 0.3.1
*/
@RequestProcessor
...
...
@@ -107,7 +107,8 @@ public class CommentProcessor {
* "commentEmail": "",
* "commentURL": "",
* "commentContent": "",
* "commentOriginalCommentId": "" // optional, if exists this key, the comment is an reply
* "commentOriginalCommentId": "", // optional, if exists this key, the comment is an reply
* "commentContent": "" // HTML
* }
* </pre>
* @throws ServletException servlet exception
...
...
@@ -188,7 +189,8 @@ public class CommentProcessor {
* "commentDate": "", // yyyy/MM/dd hh:mm:ss
* "commentSharpURL": "",
* "commentThumbnailURL": "",
* "commentOriginalCommentName": "" // if exists this key, the comment is an reply
* "commentOriginalCommentName": "", // if exists this key, the comment is an reply
* "commentContent": "" // HTML
* }
* </pre>
*
...
...
src/main/java/org/b3log/solo/processor/util/Filler.java
View file @
2afdf994
...
...
@@ -25,7 +25,6 @@ import java.util.Map;
import
javax.inject.Inject
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang.StringEscapeUtils
;
import
org.apache.commons.lang.time.DateFormatUtils
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Latkes
;
...
...
@@ -71,7 +70,7 @@ import org.json.JSONObject;
* Filler utilities.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.5.11.1
2, Nov 20
, 2015
* @version 1.5.11.1
3, Dec 17
, 2015
* @since 0.3.1
*/
@Service
...
...
@@ -527,11 +526,10 @@ public class Filler {
final
List
<
JSONObject
>
recentComments
=
commentRepository
.
getRecentComments
(
recentCommentDisplayCnt
);
for
(
final
JSONObject
comment
:
recentComments
)
{
final
String
content
=
comment
.
getString
(
Comment
.
COMMENT_CONTENT
).
replaceAll
(
SoloServletListener
.
ENTER_ESC
,
" "
);
final
String
content
=
comment
.
getString
(
Comment
.
COMMENT_CONTENT
);
comment
.
put
(
Comment
.
COMMENT_CONTENT
,
content
);
comment
.
put
(
Comment
.
COMMENT_NAME
,
StringEscapeUtils
.
escapeHtml
(
comment
.
getString
(
Comment
.
COMMENT_NAME
)
));
comment
.
put
(
Comment
.
COMMENT_URL
,
StringEscapeUtils
.
escapeHtml
(
comment
.
getString
(
Comment
.
COMMENT_URL
)
));
comment
.
put
(
Comment
.
COMMENT_NAME
,
comment
.
getString
(
Comment
.
COMMENT_NAME
));
comment
.
put
(
Comment
.
COMMENT_URL
,
comment
.
getString
(
Comment
.
COMMENT_URL
));
comment
.
remove
(
Comment
.
COMMENT_EMAIL
);
// Erases email for security reason
}
...
...
src/main/java/org/b3log/solo/service/CommentMgmtService.java
View file @
2afdf994
...
...
@@ -20,7 +20,6 @@ import java.net.URL;
import
java.util.Date
;
import
javax.inject.Inject
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang.StringEscapeUtils
;
import
org.apache.commons.lang.time.DateFormatUtils
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Latkes
;
...
...
@@ -46,15 +45,18 @@ import org.b3log.solo.repository.CommentRepository;
import
org.b3log.solo.repository.PageRepository
;
import
org.b3log.solo.repository.UserRepository
;
import
org.b3log.solo.util.Comments
;
import
org.b3log.solo.util.Markdowns
;
import
org.b3log.solo.util.Thumbnails
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.jsoup.Jsoup
;
import
org.jsoup.safety.Whitelist
;
/**
* Comment management service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.
1.0.8, Nov 20
, 2015
* @version 1.
2.0.8, Dec 17
, 2015
* @since 0.3.5
*/
@Service
...
...
@@ -178,7 +180,7 @@ public class CommentMgmtService {
throws
IOException
,
JSONException
{
final
String
commentEmail
=
comment
.
getString
(
Comment
.
COMMENT_EMAIL
);
final
String
commentId
=
comment
.
getString
(
Keys
.
OBJECT_ID
);
final
String
commentContent
=
comment
.
getString
(
Comment
.
COMMENT_CONTENT
)
.
replaceAll
(
SoloServletListener
.
ENTER_ESC
,
"<br/>"
)
;
final
String
commentContent
=
comment
.
getString
(
Comment
.
COMMENT_CONTENT
);
final
String
adminEmail
=
preference
.
getString
(
Option
.
ID_C_ADMIN_EMAIL
);
...
...
@@ -256,6 +258,10 @@ public class CommentMgmtService {
/**
* Checks the specified comment adding request.
*
* <p>
* XSS process (name, content) in this method.
* </p>
*
* @param requestJSONObject the specified comment adding request, for example, <pre>
* {
* "type": "", // "article"/"page"
...
...
@@ -308,7 +314,7 @@ public class CommentMgmtService {
}
}
final
String
commentName
=
requestJSONObject
.
getString
(
Comment
.
COMMENT_NAME
);
String
commentName
=
requestJSONObject
.
getString
(
Comment
.
COMMENT_NAME
);
if
(
MAX_COMMENT_NAME_LENGTH
<
commentName
.
length
()
||
MIN_COMMENT_NAME_LENGTH
>
commentName
.
length
())
{
LOGGER
.
log
(
Level
.
WARN
,
"Comment name is too long[{0}]"
,
commentName
);
...
...
@@ -335,8 +341,7 @@ public class CommentMgmtService {
return
ret
;
}
final
String
commentContent
=
requestJSONObject
.
optString
(
Comment
.
COMMENT_CONTENT
).
replaceAll
(
"\\n"
,
SoloServletListener
.
ENTER_ESC
);
String
commentContent
=
requestJSONObject
.
optString
(
Comment
.
COMMENT_CONTENT
).
replaceAll
(
"\\n"
,
"<br/>"
);
if
(
MAX_COMMENT_CONTENT_LENGTH
<
commentContent
.
length
()
||
MIN_COMMENT_CONTENT_LENGTH
>
commentContent
.
length
())
{
LOGGER
.
log
(
Level
.
WARN
,
"Comment conent length is invalid[{0}]"
,
commentContent
.
length
());
...
...
@@ -347,6 +352,16 @@ public class CommentMgmtService {
ret
.
put
(
Keys
.
STATUS_CODE
,
true
);
// XSS process
commentName
=
Jsoup
.
clean
(
commentName
,
Whitelist
.
none
());
requestJSONObject
.
put
(
Comment
.
COMMENT_NAME
,
commentName
);
commentContent
=
commentContent
.
replaceAll
(
"\\n"
,
"<br/>\n"
);
commentContent
=
Markdowns
.
toHTML
(
commentContent
);
commentContent
=
Jsoup
.
clean
(
commentContent
,
Whitelist
.
relaxed
());
requestJSONObject
.
put
(
Comment
.
COMMENT_CONTENT
,
commentContent
);
return
ret
;
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
WARN
,
"Checks add comment request["
+
requestJSONObject
.
toString
()
+
"] failed"
,
e
);
...
...
@@ -378,7 +393,9 @@ public class CommentMgmtService {
* "commentDate": "", // format: yyyy-MM-dd hh:mm:ss
* "commentOriginalCommentName": "" // optional, corresponding to argument "commentOriginalCommentId"
* "commentThumbnailURL": "",
* "commentSharpURL": ""
* "commentSharpURL": "",
* "commentContent": "", // processed XSS HTML
* "commentName": "" // processed XSS
* }
* </pre>
*
...
...
@@ -395,9 +412,8 @@ public class CommentMgmtService {
final
String
commentName
=
requestJSONObject
.
getString
(
Comment
.
COMMENT_NAME
);
final
String
commentEmail
=
requestJSONObject
.
getString
(
Comment
.
COMMENT_EMAIL
).
trim
().
toLowerCase
();
final
String
commentURL
=
requestJSONObject
.
optString
(
Comment
.
COMMENT_URL
);
String
commentContent
=
requestJSONObject
.
getString
(
Comment
.
COMMENT_CONTENT
).
replaceAll
(
"\\n"
,
SoloServletListener
.
ENTER_ESC
);
final
String
commentContent
=
requestJSONObject
.
getString
(
Comment
.
COMMENT_CONTENT
);
commentContent
=
StringEscapeUtils
.
escapeHtml
(
commentContent
);
final
String
originalCommentId
=
requestJSONObject
.
optString
(
Comment
.
COMMENT_ORIGINAL_COMMENT_ID
);
// Step 1: Add comment
final
JSONObject
comment
=
new
JSONObject
();
...
...
@@ -440,6 +456,9 @@ public class CommentMgmtService {
// Save comment sharp URL
final
String
commentSharpURL
=
Comments
.
getCommentSharpURLForPage
(
page
,
commentId
);
ret
.
put
(
Comment
.
COMMENT_NAME
,
commentName
);
ret
.
put
(
Comment
.
COMMENT_CONTENT
,
commentContent
);
ret
.
put
(
Comment
.
COMMENT_SHARP_URL
,
commentSharpURL
);
comment
.
put
(
Comment
.
COMMENT_SHARP_URL
,
commentSharpURL
);
comment
.
put
(
Keys
.
OBJECT_ID
,
commentId
);
...
...
@@ -494,7 +513,9 @@ public class CommentMgmtService {
* "commentDate": "", // format: yyyy-MM-dd hh:mm:ss
* "commentOriginalCommentName": "" // optional, corresponding to argument "commentOriginalCommentId"
* "commentThumbnailURL": "",
* "commentSharpURL": ""
* "commentSharpURL": "",
* "commentContent": "", // processed XSS HTML
* "commentName": "" // processed XSS
* }
* </pre>
*
...
...
@@ -511,10 +532,8 @@ public class CommentMgmtService {
final
String
commentName
=
requestJSONObject
.
getString
(
Comment
.
COMMENT_NAME
);
final
String
commentEmail
=
requestJSONObject
.
getString
(
Comment
.
COMMENT_EMAIL
).
trim
().
toLowerCase
();
final
String
commentURL
=
requestJSONObject
.
optString
(
Comment
.
COMMENT_URL
);
String
commentContent
=
requestJSONObject
.
getString
(
Comment
.
COMMENT_CONTENT
).
replaceAll
(
"\\n"
,
SoloServletListener
.
ENTER_ESC
);
final
String
contentNoEsc
=
commentContent
;
final
String
commentContent
=
requestJSONObject
.
getString
(
Comment
.
COMMENT_CONTENT
);
commentContent
=
StringEscapeUtils
.
escapeHtml
(
commentContent
);
final
String
originalCommentId
=
requestJSONObject
.
optString
(
Comment
.
COMMENT_ORIGINAL_COMMENT_ID
);
// Step 1: Add comment
final
JSONObject
comment
=
new
JSONObject
();
...
...
@@ -536,6 +555,9 @@ public class CommentMgmtService {
comment
.
put
(
Comment
.
COMMENT_DATE
,
date
);
ret
.
put
(
Comment
.
COMMENT_DATE
,
DateFormatUtils
.
format
(
date
,
"yyyy-MM-dd hh:mm:ss"
));
ret
.
put
(
Comment
.
COMMENT_NAME
,
commentName
);
ret
.
put
(
Comment
.
COMMENT_CONTENT
,
commentContent
);
if
(!
Strings
.
isEmptyOrNull
(
originalCommentId
))
{
originalComment
=
commentRepository
.
get
(
originalCommentId
);
if
(
null
!=
originalComment
)
{
...
...
@@ -579,7 +601,6 @@ public class CommentMgmtService {
final
JSONObject
eventData
=
new
JSONObject
();
eventData
.
put
(
Comment
.
COMMENT
,
comment
);
comment
.
put
(
Comment
.
COMMENT_CONTENT
,
contentNoEsc
);
eventData
.
put
(
Article
.
ARTICLE
,
article
);
eventManager
.
fireEventSynchronously
(
new
Event
<
JSONObject
>(
EventTypes
.
ADD_COMMENT_TO_ARTICLE
,
eventData
));
...
...
src/main/java/org/b3log/solo/service/CommentQueryService.java
View file @
2afdf994
...
...
@@ -15,13 +15,11 @@
*/
package
org
.
b3log
.
solo
.
service
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
javax.inject.Inject
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.commons.lang.StringEscapeUtils
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
...
...
@@ -33,7 +31,6 @@ import org.b3log.latke.service.ServiceException;
import
org.b3log.latke.service.annotation.Service
;
import
org.b3log.latke.util.Paginator
;
import
org.b3log.latke.util.Strings
;
import
org.b3log.solo.SoloServletListener
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Comment
;
import
org.b3log.solo.model.Common
;
...
...
@@ -41,16 +38,18 @@ import org.b3log.solo.model.Page;
import
org.b3log.solo.repository.ArticleRepository
;
import
org.b3log.solo.repository.CommentRepository
;
import
org.b3log.solo.repository.PageRepository
;
import
org.b3log.solo.util.Markdowns
;
import
org.b3log.solo.util.Thumbnails
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
org.jsoup.Jsoup
;
import
org.jsoup.safety.Whitelist
;
/**
* Comment query service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.
0.0.6, Nov 5
, 2015
* @version 1.
1.0.6, Dec 17
, 2015
* @since 0.3.5
*/
@Service
...
...
@@ -103,7 +102,6 @@ public class CommentQueryService {
}
// Here, you are not admin
final
JSONObject
comment
=
commentRepository
.
get
(
commentId
);
if
(
null
==
comment
)
{
...
...
@@ -131,8 +129,7 @@ public class CommentQueryService {
/**
* Gets comments with the specified request json object, request and response.
*
* @param requestJSONObject the specified request json object, for example,
* <pre>
* @param requestJSONObject the specified request json object, for example, <pre>
* {
* "paginationCurrentPageNum": 1,
* "paginationPageSize": 20,
...
...
@@ -140,8 +137,7 @@ public class CommentQueryService {
* }, see {@link Pagination} for more details
* </pre>
*
* @return for example,
* <pre>
* @return for example, <pre>
* {
* "comments": [{
* "oId": "",
...
...
@@ -199,8 +195,9 @@ public class CommentQueryService {
comment
.
put
(
Comment
.
COMMENT_TIME
,
((
Date
)
comment
.
get
(
Comment
.
COMMENT_DATE
)).
getTime
());
comment
.
remove
(
Comment
.
COMMENT_DATE
);
final
String
content
=
comment
.
getString
(
Comment
.
COMMENT_CONTENT
).
replaceAll
(
SoloServletListener
.
ENTER_ESC
,
"<br/>"
);
String
content
=
comment
.
getString
(
Comment
.
COMMENT_CONTENT
);
content
=
Markdowns
.
toHTML
(
content
);
content
=
Jsoup
.
clean
(
content
,
Whitelist
.
relaxed
());
comment
.
put
(
Comment
.
COMMENT_CONTENT
,
content
);
}
...
...
@@ -236,12 +233,14 @@ public class CommentQueryService {
final
List
<
JSONObject
>
comments
=
commentRepository
.
getComments
(
onId
,
1
,
Integer
.
MAX_VALUE
);
for
(
final
JSONObject
comment
:
comments
)
{
final
String
content
=
comment
.
getString
(
Comment
.
COMMENT_CONTENT
).
replaceAll
(
SoloServletListener
.
ENTER_ESC
,
"<br/>"
);
String
content
=
comment
.
getString
(
Comment
.
COMMENT_CONTENT
);
content
=
Markdowns
.
toHTML
(
content
);
content
=
Jsoup
.
clean
(
content
,
Whitelist
.
relaxed
());
comment
.
put
(
Comment
.
COMMENT_CONTENT
,
content
);
comment
.
put
(
Comment
.
COMMENT_TIME
,
((
Date
)
comment
.
get
(
Comment
.
COMMENT_DATE
)).
getTime
());
comment
.
put
(
Comment
.
COMMENT_NAME
,
StringEscapeUtils
.
escapeHtml
(
comment
.
getString
(
Comment
.
COMMENT_NAME
)
));
comment
.
put
(
Comment
.
COMMENT_URL
,
StringEscapeUtils
.
escapeHtml
(
comment
.
getString
(
Comment
.
COMMENT_URL
)
));
comment
.
put
(
Comment
.
COMMENT_NAME
,
comment
.
getString
(
Comment
.
COMMENT_NAME
));
comment
.
put
(
Comment
.
COMMENT_URL
,
comment
.
getString
(
Comment
.
COMMENT_URL
));
comment
.
put
(
Common
.
IS_REPLY
,
false
);
// Assumes this comment is not a reply
final
String
email
=
comment
.
optString
(
Comment
.
COMMENT_EMAIL
);
...
...
src/main/java/org/b3log/solo/service/InitService.java
View file @
2afdf994
...
...
@@ -22,7 +22,6 @@ import java.util.List;
import
java.util.Set
;
import
javax.inject.Inject
;
import
javax.servlet.ServletContext
;
import
org.apache.commons.lang.StringEscapeUtils
;
import
org.apache.commons.lang.time.DateFormatUtils
;
import
org.apache.commons.lang.time.DateUtils
;
import
org.b3log.latke.Keys
;
...
...
@@ -70,7 +69,7 @@ import org.json.JSONObject;
* Solo initialization service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.4.2.
8, Nov 20
, 2015
* @version 1.4.2.
9, Dec 17
, 2015
* @since 0.4.0
*/
@Service
...
...
@@ -324,7 +323,7 @@ public class InitService {
comment
.
put
(
Comment
.
COMMENT_NAME
,
"88250"
);
comment
.
put
(
Comment
.
COMMENT_EMAIL
,
"dl88250@gmail.com"
);
comment
.
put
(
Comment
.
COMMENT_URL
,
"http://88250.b3log.org"
);
comment
.
put
(
Comment
.
COMMENT_CONTENT
,
StringEscapeUtils
.
escapeHtml
(
langPropsService
.
get
(
"helloWorld.comment.content"
)
));
comment
.
put
(
Comment
.
COMMENT_CONTENT
,
langPropsService
.
get
(
"helloWorld.comment.content"
));
comment
.
put
(
Comment
.
COMMENT_ORIGINAL_COMMENT_ID
,
""
);
comment
.
put
(
Comment
.
COMMENT_ORIGINAL_COMMENT_NAME
,
""
);
comment
.
put
(
Comment
.
COMMENT_THUMBNAIL_URL
,
Thumbnails
.
GRAVATAR
+
"59a5e8209c780307dbe9c9ba728073f5??s=60&r=G"
);
...
...
src/main/java/org/b3log/solo/service/UpgradeService.java
View file @
2afdf994
...
...
@@ -19,6 +19,7 @@ import java.io.IOException;
import
java.sql.Connection
;
import
java.sql.Statement
;
import
javax.inject.Inject
;
import
org.apache.commons.lang.StringEscapeUtils
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.logging.Level
;
...
...
@@ -34,17 +35,20 @@ import org.b3log.latke.service.annotation.Service;
import
org.b3log.solo.SoloServletListener
;
import
org.b3log.solo.model.*
;
import
org.b3log.solo.repository.*
;
import
org.b3log.solo.util.Markdowns
;
import
org.b3log.solo.util.Thumbnails
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.jsoup.Jsoup
;
import
org.jsoup.safety.Whitelist
;
/**
* Upgrade service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="mailto:dongxu.wang@acm.org">Dongxu Wang</a>
* @version 1.
1.0.4, Dec 13
, 2015
* @version 1.
2.0.4, Dec 17
, 2015
* @since 1.2.0
*/
@Service
...
...
@@ -61,6 +65,12 @@ public class UpgradeService {
@Inject
private
ArticleRepository
articleRepository
;
/**
* Comment repository.
*/
@Inject
private
CommentRepository
commentRepository
;
/**
* User repository.
*/
...
...
@@ -174,6 +184,23 @@ public class UpgradeService {
versionOpt
.
put
(
Option
.
OPTION_VALUE
,
TO_VER
);
optionRepository
.
update
(
Option
.
ID_C_VERSION
,
versionOpt
);
final
JSONArray
comments
=
commentRepository
.
get
(
new
Query
()).
optJSONArray
(
Keys
.
RESULTS
);
for
(
int
i
=
0
;
i
<
comments
.
length
();
i
++)
{
final
JSONObject
comment
=
comments
.
getJSONObject
(
i
);
String
name
=
comment
.
optString
(
Comment
.
COMMENT_NAME
);
name
=
Jsoup
.
clean
(
name
,
Whitelist
.
none
());
comment
.
put
(
Comment
.
COMMENT_NAME
,
name
);
String
content
=
comment
.
optString
(
Comment
.
COMMENT_CONTENT
);
content
=
StringEscapeUtils
.
unescapeHtml
(
content
).
replaceAll
(
"_esc_enter_88250_"
,
"<br/>"
);
content
=
Markdowns
.
toHTML
(
content
);
content
=
Jsoup
.
clean
(
content
,
Whitelist
.
relaxed
());
comment
.
put
(
Comment
.
COMMENT_CONTENT
,
content
);
commentRepository
.
update
(
comment
.
optString
(
Keys
.
OBJECT_ID
),
comment
);
}
transaction
.
commit
();
LOGGER
.
log
(
Level
.
INFO
,
"Updated preference"
);
...
...
src/main/resources/lang_zh_CN.properties
View file @
2afdf994
...
...
@@ -16,7 +16,7 @@
#
# Description: Solo default language configurations(zh_CN).
# Version: 2.5.4.1
5, Nov 20
, 2015
# Version: 2.5.4.1
6, Dec 18
, 2015
# Author: Liang Ding
# Author: Liyuan Li
# Author: Dongxu Wang
...
...
@@ -387,6 +387,6 @@ helloWorld.content=<p>\u6b22\u8fce\u4f7f\u7528 \
\u3002\u
8fd9
\u
662f
\u
7cfb
\u
7edf
\u
81ea
\u
52a8
\u
751f
\u6210\u7684\u
6f14
\u
793a
\u6587\u
7ae0
\u3002\u
7f16
\u
8f91
\u6216\u8005\u5220\u9664\u
5b83
\u
ff0c
\u7136\u
540e
\u
5f00
\u
59cb
\u
60a8
\u7684\u
535a
\u
5ba2
\u
ff01</p>
\
<p>
\u
53e6
\u5916\u
ff0c
\u
6b22
\u
8fce
\u
60a8
\u
52a0
\u5165
<a href="http://hacpai.com" target="_blank">
\u
9ed1
\u
5ba2
\u
4e0e
\u
753b
\u
5bb6
\u7684\u
793e
\u
533a</a>
\u
ff0c
\u
60a8
\u
53ef
\u
4ee5
\u
4f7f
\u7528\u
60a8
\u7684\u
535a
\u
5ba2
\u
8d26
\u
53f7
\u
76f4
\u
63a5
\u
767b
\u
5f55
\u
ff01
\
</p>
helloWorld.comment.content
=
\u
60a8
\u
597d
\u
ff0c
\u
8fd9
\u
662f
\u
4e00
\u6761\u
8bc4
\u
8bba
\u3002
_esc_enter_88250_
\u8981\u5220\u9664\u
8bc4
\u
8bba
\u
ff0c
\u
8bf7
\u5148\u
767b
\u
5f55
\u
ff0c
\u7136\u
540e
\u
518d
\u
67e5
\u
770b
\u
8fd9
\u
7bc7
\u6587\u
7ae0
\u7684\u
8bc4
\u
8bba
\u3002\u5728\u
90a3
\u
91cc
\u
ff0c
\u
60a8
\u
53ef
\u
4ee5
\u
770b
\u5230\u5220\u9664\u
8bc4
\u
8bba
\u7684\u9009\u9879\u3002
helloWorld.comment.content
=
\u
60a8
\u
597d
\u
ff0c
\u
8fd9
\u
662f
\u
4e00
\u6761\u
8bc4
\u
8bba
\u3002
<br/>
\u8981\u5220\u9664\u
8bc4
\u
8bba
\u
ff0c
\u
8bf7
\u5148\u
767b
\u
5f55
\u
ff0c
\u7136\u
540e
\u
518d
\u
67e5
\u
770b
\u
8fd9
\u
7bc7
\u6587\u
7ae0
\u7684\u
8bc4
\u
8bba
\u3002\u5728\u
90a3
\u
91cc
\u
ff0c
\u
60a8
\u
53ef
\u
4ee5
\u
770b
\u5230\u5220\u9664\u
8bc4
\u
8bba
\u7684\u9009\u9879\u3002
articleContentPwd
=
\u
8be5
\u6587\u
7ae0
\u
5df2
\u
7ecf
\u
52a0
\u
5bc6
\u3002
ok
=
\u
786e
\u
5b9a
\ No newline at end of file
src/main/webapp/js/page.js
View file @
2afdf994
...
...
@@ -590,9 +590,13 @@ $.extend(Page.prototype, {
if
(
!
Util
.
isLoggedIn
())
{
$
(
"
#captcha
"
+
state
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
());
}
return
;
}
$
(
"
#comment
"
+
state
).
val
(
result
.
commentContent
);
// Server processed XSS
$
(
"
#commentName
"
+
state
).
val
(
result
.
commentName
);
// Server processed XSS
result
.
replyNameHTML
=
""
;
if
(
!
Util
.
isLoggedIn
())
{
$
(
"
#captcha
"
+
state
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
());
...
...
@@ -602,7 +606,7 @@ $.extend(Page.prototype, {
result
.
replyNameHTML
=
'
<a href="
'
+
Util
.
proessURL
(
$
(
"
#commentURL
"
+
state
).
val
())
+
'
" target="_blank">
'
+
$
(
"
#commentName
"
+
state
).
val
()
+
'
</a>
'
;
}
result
.
userName
=
$
(
"
#commentName
"
+
state
).
val
()
;
result
.
userName
=
result
.
commentName
;
}
else
{
result
.
replyNameHTML
=
'
<a href="
'
+
window
.
location
.
host
+
'
" target="_blank">
'
+
Util
.
getUserName
()
+
'
</a>
'
;
...
...
src/main/webapp/js/page.min.js
View file @
2afdf994
...
...
@@ -13,4 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var
Page
=
function
(
tips
){
this
.
currentCommentId
=
""
;
this
.
tips
=
tips
};
$
.
extend
(
Page
.
prototype
,{
insertEmotions
:
function
(
name
){
var
_it
=
this
;
if
(
name
===
undefined
){
name
=
""
}
$
(
"
#emotions
"
+
name
+
"
span
"
).
click
(
function
(){
var
$comment
=
$
(
"
#comment
"
+
name
);
var
endPosition
=
_it
.
_getCursorEndPosition
(
$comment
[
0
]);
var
key
=
"
[
"
+
this
.
className
+
"
]
"
,
textValue
=
$comment
[
0
].
value
;
textValue
=
textValue
.
substring
(
0
,
endPosition
)
+
key
+
textValue
.
substring
(
endPosition
,
textValue
.
length
);
$
(
"
#comment
"
+
name
).
val
(
textValue
);
if
(
$
.
browser
.
msie
){
endPosition
-=
textValue
.
split
(
"
\n
"
).
length
-
1
;
var
oR
=
$comment
[
0
].
createTextRange
();
oR
.
collapse
(
true
);
oR
.
moveStart
(
"
character
"
,
endPosition
+
6
);
oR
.
select
()}
else
{
$comment
[
0
].
setSelectionRange
(
endPosition
+
6
,
endPosition
+
6
)}})},
_getCursorEndPosition
:
function
(
textarea
){
textarea
.
focus
();
if
(
textarea
.
setSelectionRange
){
return
textarea
.
selectionEnd
}
else
{
if
(
document
.
selection
){
var
i
=
0
,
oS
=
document
.
selection
.
createRange
(),
oR
=
document
.
body
.
createTextRange
();
oR
.
moveToElementText
(
textarea
);
oS
.
getBookmark
();
for
(
i
=
0
;
oR
.
compareEndPoints
(
"
StartToStart
"
,
oS
)
<
0
&&
oS
.
moveStart
(
"
character
"
,
-
1
)
!==
0
;
i
++
){
if
(
textarea
.
value
.
charAt
(
i
)
===
"
\n
"
){
i
++
}}
return
i
}}},
validateComment
:
function
(
state
){
if
(
Util
.
isLoggedIn
()){
var
commenterContent
=
$
(
"
#comment
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
);
if
(
2
>
commenterContent
.
length
||
commenterContent
.
length
>
500
){
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
commentContentCannotEmptyLabel
);
$
(
"
#comment
"
+
state
).
focus
()}
else
{
return
true
}
$
(
"
#commentErrorTip
"
+
state
).
show
();
return
false
}
var
commentName
=
$
(
"
#commentName
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
),
commenterContent
=
$
(
"
#comment
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
);
if
(
2
>
commentName
.
length
||
commentName
.
length
>
20
){
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
nameTooLongLabel
);
$
(
"
#commentName
"
+
state
).
focus
()}
else
{
if
(
$
(
"
#commentEmail
"
+
state
).
val
().
replace
(
/
\s
/g
,
""
)
===
""
){
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
mailCannotEmptyLabel
);
$
(
"
#commentEmail
"
+
state
).
focus
()}
else
{
if
(
!
/^
((([
a-z
]
|
\d
|
[
!#
\$
%&'
\*\+\-\/
=
\?\^
_`{
\|
}~
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
+
(\.([
a-z
]
|
\d
|
[
!#
\$
%&'
\*\+\-\/
=
\?\^
_`{
\|
}~
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
+
)
*
)
|
((\x
22
)((((\x
20|
\x
09
)
*
(\x
0d
\x
0a
))?(\x
20|
\x
09
)
+
)?(([\x
01-
\x
08
\x
0b
\x
0c
\x
0e-
\x
1f
\x
7f
]
|
\x
21|
[\x
23-
\x
5b
]
|
[\x
5d-
\x
7e
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
|
(\\([\x
01-
\x
09
\x
0b
\x
0c
\x
0d-
\x
7f
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
]))))
*
(((\x
20|
\x
09
)
*
(\x
0d
\x
0a
))?(\x
20|
\x
09
)
+
)?(\x
22
)))
@
((([
a-z
]
|
\d
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
|
(([
a-z
]
|
\d
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])([
a-z
]
|
\d
|-|
\.
|_|~|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
*
([
a-z
]
|
\d
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])))\.)
+
(([
a-z
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
|
(([
a-z
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])([
a-z
]
|
\d
|-|
\.
|_|~|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
*
([
a-z
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])))\.?
$/i
.
test
(
$
(
"
#commentEmail
"
+
state
).
val
())){
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
mailInvalidLabel
);
$
(
"
#commentEmail
"
+
state
).
focus
()}
else
{
if
(
2
>
commenterContent
.
length
||
commenterContent
.
length
>
500
){
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
commentContentCannotEmptyLabel
);
$
(
"
#comment
"
+
state
).
focus
()}
else
{
if
(
$
(
"
#commentValidate
"
+
state
).
val
().
replace
(
/
\s
/g
,
""
)
===
""
){
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
captchaCannotEmptyLabel
);
$
(
"
#commentValidate
"
+
state
).
focus
()}
else
{
return
true
}}}}}
$
(
"
#commentErrorTip
"
+
state
).
show
();
return
false
},
replaceCommentsEm
:
function
(
selector
){
var
$commentContents
=
$
(
selector
);
for
(
var
i
=
0
;
i
<
$commentContents
.
length
;
i
++
){
var
str
=
$commentContents
[
i
].
innerHTML
;
$commentContents
[
i
].
innerHTML
=
Util
.
replaceEmString
(
str
)}},
_initSyntaxHighlighter
:
function
(
languages
){
for
(
var
i
=
0
;
i
<
languages
.
length
;
i
++
){
switch
(
languages
[
i
]){
case
"
groovy
"
:
languages
[
i
]
=
"
groovy
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushGroovy.js
"
;
break
;
case
"
java
"
:
languages
[
i
]
=
"
java
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushJava.js
"
;
break
;
case
"
php
"
:
languages
[
i
]
=
"
php
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushPhp.js
"
;
break
;
case
"
scala
"
:
languages
[
i
]
=
"
scala
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushScala.js
"
;
break
;
case
"
sql
"
:
languages
[
i
]
=
"
sql
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushSql.js
"
;
break
;
case
"
applescript
"
:
languages
[
i
]
=
"
applescript
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushAppleScript.js
"
;
break
;
case
"
as3
"
:
case
"
actionscript3
"
:
languages
[
i
]
=
"
actionscript3 as3
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushAS3.js
"
;
break
;
case
"
bash
"
:
case
"
shell
"
:
languages
[
i
]
=
"
bash shell
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushBash.js
"
;
break
;
case
"
coldfusion
"
:
case
"
cf
"
:
languages
[
i
]
=
"
coldfusion cf
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushColdFusion.js
"
;
break
;
case
"
c#
"
:
case
"
c-sharp
"
:
case
"
csharp
"
:
languages
[
i
]
=
"
c# c-sharp csharp
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushCSharp.js
"
;
break
;
case
"
cpp
"
:
case
"
c
"
:
languages
[
i
]
=
"
cpp c
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushCpp.js
"
;
break
;
case
"
css
"
:
languages
[
i
]
=
"
css
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushCss.js
"
;
break
;
case
"
delphi
"
:
case
"
pascal
"
:
languages
[
i
]
=
"
delphi pascal
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushDelphi.js
"
;
break
;
case
"
diff
"
:
case
"
patch
"
:
case
"
pas
"
:
languages
[
i
]
=
"
diff patch pas
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushDiff.js
"
;
break
;
case
"
erl
"
:
case
"
erlang
"
:
languages
[
i
]
=
"
erl erlang
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushErlang.js
"
;
break
;
case
"
js
"
:
case
"
jscript
"
:
case
"
javascript
"
:
languages
[
i
]
=
"
js jscript javascript
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushJScript.js
"
;
break
;
case
"
jfx
"
:
case
"
javafx
"
:
languages
[
i
]
=
"
jfx javafx
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushJavaFX.js
"
;
break
;
case
"
perl
"
:
case
"
pl
"
:
languages
[
i
]
=
"
perl pl
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushPerl.js
"
;
break
;
case
"
plain
"
:
case
"
text
"
:
languages
[
i
]
=
"
text plain
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushPlain.js
"
;
break
;
case
"
ps
"
:
case
"
powershell
"
:
languages
[
i
]
=
"
ps powershell
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushPowerShell.js
"
;
break
;
case
"
py
"
:
case
"
python
"
:
languages
[
i
]
=
"
py python
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushPython.js
"
;
break
;
case
"
rails
"
:
case
"
ror
"
:
case
"
ruby
"
:
case
"
rb
"
:
languages
[
i
]
=
"
ruby rails ror rb
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushRuby.js
"
;
break
;
case
"
sass
"
:
case
"
scss
"
:
languages
[
i
]
=
"
sass scss
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushSass.js
"
;
break
;
case
"
vb
"
:
case
"
vbnet
"
:
languages
[
i
]
=
"
vb vbnet
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushVb.js
"
;
break
;
case
"
xml
"
:
case
"
xhtml
"
:
case
"
xslt
"
:
case
"
html
"
:
languages
[
i
]
=
"
xml xhtml xslt html
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushXml.js
"
;
break
;
default
:
break
}}
SyntaxHighlighter
.
autoloader
.
apply
(
null
,
languages
);
SyntaxHighlighter
.
config
.
stripBrs
=
true
;
SyntaxHighlighter
.
all
()},
_loadSyntaxHighlighter
:
function
(
SHTheme
){
var
cssName
=
SHTheme
?
SHTheme
:
"
shCoreEclipse
"
,
that
=
this
;
if
(
document
.
createStyleSheet
){
document
.
createStyleSheet
(
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/styles/
"
+
cssName
+
"
.css
"
)}
else
{
$
(
"
head
"
).
append
(
$
(
"
<link rel='stylesheet' href='
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/styles/
"
+
cssName
+
"
.css' type='text/css' charset='utf-8' />
"
))}
$
.
ajax
({
url
:
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shCore.js
"
,
dataType
:
"
script
"
,
cache
:
true
,
success
:
function
(){
var
languages
=
[],
isScrip
=
false
;
$
(
"
.article-body pre, .code-highlight pre
"
).
each
(
function
(){
var
name
=
this
.
className
.
split
(
"
;
"
)[
0
];
var
language
=
name
.
substr
(
7
,
name
.
length
-
1
);
if
(
this
.
className
.
indexOf
(
"
html-script: true
"
)
>-
1
&&
(
language
!==
"
xml
"
&&
language
!==
"
xhtml
"
&&
language
!==
"
xslt
"
&&
language
!=
"
html
"
)){
isScrip
=
true
}
languages
.
push
(
language
)});
if
(
isScrip
){
$
.
ajax
({
url
:
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushXml.js
"
,
dataType
:
"
script
"
,
cache
:
true
,
success
:
function
(){
that
.
_initSyntaxHighlighter
(
languages
)}})}
else
{
that
.
_initSyntaxHighlighter
(
languages
)}}})},
parseLanguage
:
function
(
obj
){
var
isPrettify
=
false
,
isSH
=
false
;
$
(
"
.article-body pre, .code-highlight pre
"
).
each
(
function
(){
if
(
this
.
className
.
indexOf
(
"
brush
"
)
>-
1
){
isSH
=
true
}
if
(
this
.
className
.
indexOf
(
"
prettyprint
"
)
>-
1
){
isPrettify
=
true
}});
if
(
isSH
){
this
.
_loadSyntaxHighlighter
(
obj
?(
obj
.
SHTheme
?
obj
.
SHTheme
:
undefined
):
undefined
);
return
false
}
if
(
isPrettify
){
if
(
document
.
createStyleSheet
){
document
.
createStyleSheet
(
latkeConfig
.
staticServePath
+
"
/js/lib/google-code-prettify/prettify.css
"
)}
else
{
$
(
"
head
"
).
append
(
$
(
"
<link rel='stylesheet' href='
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/google-code-prettify/prettify.css'>
"
))}
$
.
ajax
({
url
:
latkeConfig
.
staticServePath
+
"
/js/lib/google-code-prettify/prettify.js
"
,
dataType
:
"
script
"
,
cache
:
true
,
success
:
function
(){
prettyPrint
()}});
return
false
}
if
(
document
.
createStyleSheet
){
document
.
createStyleSheet
(
latkeConfig
.
staticServePath
+
"
/js/lib/highlight/styles/default.css
"
)}
else
{
$
(
"
head
"
).
append
(
$
(
"
<link rel='stylesheet' href='
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/highlight/styles/github.css'>
"
))}
$
.
ajax
({
url
:
latkeConfig
.
staticServePath
+
"
/js/lib/highlight/highlight.pack.js
"
,
dataType
:
"
script
"
,
cache
:
true
,
success
:
function
(){
hljs
.
initHighlightingOnLoad
()}})},
load
:
function
(
obj
){
var
that
=
this
;
that
.
insertEmotions
();
that
.
parseLanguage
(
obj
?(
obj
.
language
?
obj
.
language
:
undefined
):
undefined
);
$
(
"
#commentValidate
"
).
keypress
(
function
(
event
){
if
(
event
.
keyCode
===
13
){
that
.
submitComment
()}});
$
(
"
#comment
"
).
keypress
(
function
(
event
){
if
(
event
.
keyCode
===
13
&&
event
.
ctrlKey
){
that
.
submitComment
()}});
$
(
"
#captcha
"
).
click
(
function
(){
$
(
this
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
())});
if
(
!
Util
.
isLoggedIn
()){
$
(
"
#commentEmail
"
).
val
(
Cookie
.
readCookie
(
"
commentEmail
"
));
$
(
"
#commentURL
"
).
val
(
Cookie
.
readCookie
(
"
commentURL
"
));
$
(
"
#commentName
"
).
val
(
Cookie
.
readCookie
(
"
commentName
"
))}
try
{
JSON
}
catch
(
e
){
document
.
write
(
'
<script src="
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/json2.js"><
\
/script>
'
)}},
loadRandomArticles
:
function
(
headTitle
){
var
randomArticles1Label
=
this
.
tips
.
randomArticles1Label
;
$
.
ajax
({
url
:
latkeConfig
.
servePath
+
"
/get-random-articles.do
"
,
type
:
"
POST
"
,
success
:
function
(
result
,
textStatus
){
var
randomArticles
=
result
.
randomArticles
;
if
(
!
randomArticles
||
0
===
randomArticles
.
length
){
$
(
"
#randomArticles
"
).
remove
();
return
}
var
listHtml
=
""
;
for
(
var
i
=
0
;
i
<
randomArticles
.
length
;
i
++
){
var
article
=
randomArticles
[
i
];
var
title
=
article
.
articleTitle
;
var
randomArticleLiHtml
=
"
<li><a rel='nofollow' title='
"
+
title
+
"
' href='
"
+
latkeConfig
.
servePath
+
article
.
articlePermalink
+
"
'>
"
+
title
+
"
</a></li>
"
;
listHtml
+=
randomArticleLiHtml
}
var
titleHTML
=
headTitle
?
headTitle
:
"
<h4>
"
+
randomArticles1Label
+
"
</h4>
"
;
var
randomArticleListHtml
=
titleHTML
+
"
<ul class='marginLeft12'>
"
+
listHtml
+
"
</ul>
"
;
$
(
"
#randomArticles
"
).
append
(
randomArticleListHtml
)}})},
loadRelevantArticles
:
function
(
id
,
headTitle
){
$
.
ajax
({
url
:
latkeConfig
.
servePath
+
"
/article/id/
"
+
id
+
"
/relevant/articles
"
,
type
:
"
GET
"
,
success
:
function
(
data
,
textStatus
){
var
articles
=
data
.
relevantArticles
;
if
(
!
articles
||
0
===
articles
.
length
){
$
(
"
#relevantArticles
"
).
remove
();
return
}
var
listHtml
=
""
;
for
(
var
i
=
0
;
i
<
articles
.
length
;
i
++
){
var
article
=
articles
[
i
];
var
title
=
article
.
articleTitle
;
var
articleLiHtml
=
"
<li><a rel='nofollow' title='
"
+
title
+
"
' href='
"
+
latkeConfig
.
servePath
+
article
.
articlePermalink
+
"
'>
"
+
title
+
"
</a></li>
"
;
listHtml
+=
articleLiHtml
}
var
relevantArticleListHtml
=
headTitle
+
"
<ul class='marginLeft12'>
"
+
listHtml
+
"
</ul>
"
;
$
(
"
#relevantArticles
"
).
append
(
relevantArticleListHtml
)},
error
:
function
(){
$
(
"
#relevantArticles
"
).
remove
()}})},
loadExternalRelevantArticles
:
function
(
tags
,
headTitle
){
var
tips
=
this
.
tips
;
try
{
$
.
ajax
({
url
:
"
http://rhythm.b3log.org:80/get-articles-by-tags.do?tags=
"
+
tags
+
"
&blogHost=
"
+
tips
.
blogHost
+
"
&paginationPageSize=
"
+
tips
.
externalRelevantArticlesDisplayCount
,
type
:
"
GET
"
,
cache
:
true
,
dataType
:
"
jsonp
"
,
error
:
function
(){
$
(
"
#externalRelevantArticles
"
).
remove
()},
success
:
function
(
data
,
textStatus
){
var
articles
=
data
.
articles
;
if
(
!
articles
||
0
===
articles
.
length
){
$
(
"
#externalRelevantArticles
"
).
remove
();
return
}
var
listHtml
=
""
;
for
(
var
i
=
0
;
i
<
articles
.
length
;
i
++
){
var
article
=
articles
[
i
];
var
title
=
article
.
articleTitle
;
var
articleLiHtml
=
"
<li><a rel='nofollow' title='
"
+
title
+
"
' target='_blank' href='
"
+
article
.
articlePermalink
+
"
'>
"
+
title
+
"
</a></li>
"
;
listHtml
+=
articleLiHtml
}
var
titleHTML
=
headTitle
?
headTitle
:
"
<h4>
"
+
tips
.
externalRelevantArticles1Label
+
"
</h4>
"
;
var
randomArticleListHtml
=
titleHTML
+
"
<ul class='marginLeft12'>
"
+
listHtml
+
"
</ul>
"
;
$
(
"
#externalRelevantArticles
"
).
append
(
randomArticleListHtml
)}})}
catch
(
e
){}},
submitComment
:
function
(
commentId
,
state
){
if
(
!
state
){
state
=
""
}
var
that
=
this
,
tips
=
this
.
tips
,
type
=
"
article
"
;
if
(
tips
.
externalRelevantArticlesDisplayCount
===
undefined
){
type
=
"
page
"
}
if
(
this
.
validateComment
(
state
)){
$
(
"
#submitCommentButton
"
+
state
).
attr
(
"
disabled
"
,
"
disabled
"
);
$
(
"
#commentErrorTip
"
+
state
).
show
().
html
(
this
.
tips
.
loadingLabel
);
var
requestJSONObject
=
{
oId
:
tips
.
oId
,
commentContent
:
$
(
"
#comment
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
)};
if
(
!
Util
.
isLoggedIn
()){
requestJSONObject
=
{
oId
:
tips
.
oId
,
commentContent
:
$
(
"
#comment
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
),
commentEmail
:
$
(
"
#commentEmail
"
+
state
).
val
(),
commentURL
:
Util
.
proessURL
(
$
(
"
#commentURL
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
)),
commentName
:
$
(
"
#commentName
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
),
captcha
:
$
(
"
#commentValidate
"
+
state
).
val
()};
Cookie
.
createCookie
(
"
commentName
"
,
requestJSONObject
.
commentName
,
365
);
Cookie
.
createCookie
(
"
commentEmail
"
,
requestJSONObject
.
commentEmail
,
365
);
Cookie
.
createCookie
(
"
commentURL
"
,
$
(
"
#commentURL
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
),
365
)}
if
(
state
===
"
Reply
"
){
requestJSONObject
.
commentOriginalCommentId
=
commentId
}
$
.
ajax
({
type
:
"
POST
"
,
url
:
latkeConfig
.
servePath
+
"
/add-
"
+
type
+
"
-comment.do
"
,
cache
:
false
,
contentType
:
"
application/json
"
,
data
:
JSON
.
stringify
(
requestJSONObject
),
success
:
function
(
result
){
if
(
!
result
.
sc
){
$
(
"
#commentErrorTip
"
+
state
).
html
(
result
.
msg
);
$
(
"
#comment
"
+
state
).
val
(
""
).
focus
();
$
(
"
#submitCommentButton
"
+
state
).
removeAttr
(
"
disabled
"
);
if
(
!
Util
.
isLoggedIn
()){
$
(
"
#captcha
"
+
state
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
())}
return
}
result
.
replyNameHTML
=
""
;
if
(
!
Util
.
isLoggedIn
()){
$
(
"
#captcha
"
+
state
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
());
if
(
$
(
"
#commentURL
"
+
state
).
val
().
replace
(
/
\s
/g
,
""
)
===
""
){
result
.
replyNameHTML
=
"
<a>
"
+
$
(
"
#commentName
"
+
state
).
val
()
+
"
</a>
"
}
else
{
result
.
replyNameHTML
=
'
<a href="
'
+
Util
.
proessURL
(
$
(
"
#commentURL
"
+
state
).
val
())
+
'
" target="_blank">
'
+
$
(
"
#commentName
"
+
state
).
val
()
+
"
</a>
"
}
result
.
userName
=
$
(
"
#commentName
"
+
state
).
val
()}
else
{
result
.
replyNameHTML
=
'
<a href="
'
+
window
.
location
.
host
+
'
" target="_blank">
'
+
Util
.
getUserName
()
+
"
</a>
"
;
result
.
userName
=
Util
.
getUserName
()}
that
.
addCommentAjax
(
addComment
(
result
,
state
),
state
);
$
(
"
#submitCommentButton
"
+
state
).
removeAttr
(
"
disabled
"
)}})}},
addReplyForm
:
function
(
id
,
commentFormHTML
,
endHTML
){
var
that
=
this
;
if
(
id
===
this
.
currentCommentId
){
if
(
$
(
"
#commentNameReply
"
).
val
()
===
""
){
$
(
"
#commentNameReply
"
).
focus
()}
else
{
if
(
$
(
"
#commentEmailReply
"
).
val
()
===
""
){
$
(
"
#commentEmailReply
"
).
focus
()}
else
{
$
(
"
#commentReply
"
).
focus
()}}
return
}
$
(
"
#replyForm
"
).
remove
();
endHTML
=
endHTML
?
endHTML
:
""
;
if
(
endHTML
===
"
</div>
"
){
$
(
"
#
"
+
id
).
append
(
commentFormHTML
+
$
(
"
#commentForm
"
).
html
()
+
endHTML
)}
else
{
$
(
"
#
"
+
id
).
append
(
commentFormHTML
+
$
(
"
#commentForm
"
).
html
()
+
"
</table>
"
+
endHTML
)}
$
(
"
#replyForm input, #replyForm textarea
"
).
each
(
function
(){
this
.
id
=
this
.
id
+
"
Reply
"
});
$
(
"
#commentNameReply
"
).
val
(
Cookie
.
readCookie
(
"
commentName
"
));
$
(
"
#commentEmailReply
"
).
val
(
Cookie
.
readCookie
(
"
commentEmail
"
));
var
$label
=
$
(
"
#replyForm #commentURLLabel
"
);
if
(
$label
.
length
===
1
){
$label
.
attr
(
"
id
"
,
"
commentURLLabelReply
"
)}
$
(
"
#commentURLReply
"
).
val
(
Cookie
.
readCookie
(
"
commentURL
"
));
$
(
"
#replyForm #emotions
"
).
attr
(
"
id
"
,
"
emotionsReply
"
);
this
.
insertEmotions
(
"
Reply
"
);
$
(
"
#commentReply
"
).
unbind
().
keypress
(
function
(
event
){
if
(
event
.
keyCode
===
13
&&
event
.
ctrlKey
){
that
.
submitComment
(
id
,
"
Reply
"
);
event
.
preventDefault
()}});
$
(
"
#commentValidateReply
"
).
unbind
().
keypress
(
function
(
event
){
if
(
event
.
keyCode
===
13
){
that
.
submitComment
(
id
,
"
Reply
"
);
event
.
preventDefault
()}});
$
(
"
#replyForm #captcha
"
).
attr
(
"
id
"
,
"
captchaReply
"
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?
"
+
new
Date
().
getTime
()).
click
(
function
(){
$
(
this
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
())});
$
(
"
#replyForm #commentErrorTip
"
).
attr
(
"
id
"
,
"
commentErrorTipReply
"
).
html
(
""
).
hide
();
$
(
"
#replyForm #submitCommentButton
"
).
attr
(
"
id
"
,
"
submitCommentButtonReply
"
);
$
(
"
#replyForm #submitCommentButtonReply
"
).
unbind
(
"
click
"
).
removeAttr
(
"
onclick
"
).
click
(
function
(){
that
.
submitComment
(
id
,
"
Reply
"
)});
if
(
$
(
"
#commentNameReply
"
).
val
()
===
""
){
$
(
"
#commentNameReply
"
).
focus
()}
else
{
if
(
$
(
"
#commentEmailReply
"
).
val
()
===
""
){
$
(
"
#commentEmailReply
"
).
focus
()}
else
{
$
(
"
#commentReply
"
).
focus
()}}
this
.
currentCommentId
=
id
},
hideComment
:
function
(
id
){
$
(
"
#commentRef
"
+
id
).
hide
()},
showComment
:
function
(
it
,
id
,
top
,
parentTag
){
var
positionTop
=
parseInt
(
$
(
it
).
position
().
top
);
if
(
parentTag
){
positionTop
=
parseInt
(
$
(
it
).
parents
(
parentTag
).
position
().
top
)}
if
(
$
(
"
#commentRef
"
+
id
).
length
>
0
){
$
(
"
#commentRef
"
+
id
).
show
().
css
(
"
top
"
,(
positionTop
+
top
)
+
"
px
"
)}
else
{
var
$refComment
=
$
(
"
#
"
+
id
).
clone
();
$refComment
.
addClass
(
"
comment-body-ref
"
).
attr
(
"
id
"
,
"
commentRef
"
+
id
);
$refComment
.
find
(
"
#replyForm
"
).
remove
();
$
(
"
#comments
"
).
append
(
$refComment
);
$
(
"
#commentRef
"
+
id
).
css
(
"
top
"
,(
positionTop
+
top
)
+
"
px
"
)}},
addCommentAjax
:
function
(
commentHTML
,
state
){
if
(
$
(
"
#comments
"
).
children
().
length
>
0
){
$
(
$
(
"
#comments
"
).
children
()[
0
]).
before
(
commentHTML
)}
else
{
$
(
"
#comments
"
).
html
(
commentHTML
)}
if
(
state
===
""
){
$
(
"
#commentErrorTip
"
).
html
(
""
).
hide
();
$
(
"
#comment
"
).
val
(
""
);
$
(
"
#commentValidate
"
).
val
(
""
);
$
(
"
#captcha
"
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
())}
else
{
$
(
"
#replyForm
"
).
remove
()}
window
.
location
.
hash
=
"
#comments
"
}});
\ No newline at end of file
var
Page
=
function
(
tips
){
this
.
currentCommentId
=
""
;
this
.
tips
=
tips
};
$
.
extend
(
Page
.
prototype
,{
insertEmotions
:
function
(
name
){
var
_it
=
this
;
if
(
name
===
undefined
){
name
=
""
}
$
(
"
#emotions
"
+
name
+
"
span
"
).
click
(
function
(){
var
$comment
=
$
(
"
#comment
"
+
name
);
var
endPosition
=
_it
.
_getCursorEndPosition
(
$comment
[
0
]);
var
key
=
"
[
"
+
this
.
className
+
"
]
"
,
textValue
=
$comment
[
0
].
value
;
textValue
=
textValue
.
substring
(
0
,
endPosition
)
+
key
+
textValue
.
substring
(
endPosition
,
textValue
.
length
);
$
(
"
#comment
"
+
name
).
val
(
textValue
);
if
(
$
.
browser
.
msie
){
endPosition
-=
textValue
.
split
(
"
\n
"
).
length
-
1
;
var
oR
=
$comment
[
0
].
createTextRange
();
oR
.
collapse
(
true
);
oR
.
moveStart
(
"
character
"
,
endPosition
+
6
);
oR
.
select
()}
else
{
$comment
[
0
].
setSelectionRange
(
endPosition
+
6
,
endPosition
+
6
)}})},
_getCursorEndPosition
:
function
(
textarea
){
textarea
.
focus
();
if
(
textarea
.
setSelectionRange
){
return
textarea
.
selectionEnd
}
else
{
if
(
document
.
selection
){
var
i
=
0
,
oS
=
document
.
selection
.
createRange
(),
oR
=
document
.
body
.
createTextRange
();
oR
.
moveToElementText
(
textarea
);
oS
.
getBookmark
();
for
(
i
=
0
;
oR
.
compareEndPoints
(
"
StartToStart
"
,
oS
)
<
0
&&
oS
.
moveStart
(
"
character
"
,
-
1
)
!==
0
;
i
++
){
if
(
textarea
.
value
.
charAt
(
i
)
===
"
\n
"
){
i
++
}}
return
i
}}},
validateComment
:
function
(
state
){
if
(
Util
.
isLoggedIn
()){
var
commenterContent
=
$
(
"
#comment
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
);
if
(
2
>
commenterContent
.
length
||
commenterContent
.
length
>
500
){
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
commentContentCannotEmptyLabel
);
$
(
"
#comment
"
+
state
).
focus
()}
else
{
return
true
}
$
(
"
#commentErrorTip
"
+
state
).
show
();
return
false
}
var
commentName
=
$
(
"
#commentName
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
),
commenterContent
=
$
(
"
#comment
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
);
if
(
2
>
commentName
.
length
||
commentName
.
length
>
20
){
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
nameTooLongLabel
);
$
(
"
#commentName
"
+
state
).
focus
()}
else
{
if
(
$
(
"
#commentEmail
"
+
state
).
val
().
replace
(
/
\s
/g
,
""
)
===
""
){
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
mailCannotEmptyLabel
);
$
(
"
#commentEmail
"
+
state
).
focus
()}
else
{
if
(
!
/^
((([
a-z
]
|
\d
|
[
!#
\$
%&'
\*\+\-\/
=
\?\^
_`{
\|
}~
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
+
(\.([
a-z
]
|
\d
|
[
!#
\$
%&'
\*\+\-\/
=
\?\^
_`{
\|
}~
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
+
)
*
)
|
((\x
22
)((((\x
20|
\x
09
)
*
(\x
0d
\x
0a
))?(\x
20|
\x
09
)
+
)?(([\x
01-
\x
08
\x
0b
\x
0c
\x
0e-
\x
1f
\x
7f
]
|
\x
21|
[\x
23-
\x
5b
]
|
[\x
5d-
\x
7e
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
|
(\\([\x
01-
\x
09
\x
0b
\x
0c
\x
0d-
\x
7f
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
]))))
*
(((\x
20|
\x
09
)
*
(\x
0d
\x
0a
))?(\x
20|
\x
09
)
+
)?(\x
22
)))
@
((([
a-z
]
|
\d
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
|
(([
a-z
]
|
\d
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])([
a-z
]
|
\d
|-|
\.
|_|~|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
*
([
a-z
]
|
\d
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])))\.)
+
(([
a-z
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
|
(([
a-z
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])([
a-z
]
|
\d
|-|
\.
|_|~|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
*
([
a-z
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])))\.?
$/i
.
test
(
$
(
"
#commentEmail
"
+
state
).
val
())){
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
mailInvalidLabel
);
$
(
"
#commentEmail
"
+
state
).
focus
()}
else
{
if
(
2
>
commenterContent
.
length
||
commenterContent
.
length
>
500
){
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
commentContentCannotEmptyLabel
);
$
(
"
#comment
"
+
state
).
focus
()}
else
{
if
(
$
(
"
#commentValidate
"
+
state
).
val
().
replace
(
/
\s
/g
,
""
)
===
""
){
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
captchaCannotEmptyLabel
);
$
(
"
#commentValidate
"
+
state
).
focus
()}
else
{
return
true
}}}}}
$
(
"
#commentErrorTip
"
+
state
).
show
();
return
false
},
replaceCommentsEm
:
function
(
selector
){
var
$commentContents
=
$
(
selector
);
for
(
var
i
=
0
;
i
<
$commentContents
.
length
;
i
++
){
var
str
=
$commentContents
[
i
].
innerHTML
;
$commentContents
[
i
].
innerHTML
=
Util
.
replaceEmString
(
str
)}},
_initSyntaxHighlighter
:
function
(
languages
){
for
(
var
i
=
0
;
i
<
languages
.
length
;
i
++
){
switch
(
languages
[
i
]){
case
"
groovy
"
:
languages
[
i
]
=
"
groovy
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushGroovy.js
"
;
break
;
case
"
java
"
:
languages
[
i
]
=
"
java
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushJava.js
"
;
break
;
case
"
php
"
:
languages
[
i
]
=
"
php
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushPhp.js
"
;
break
;
case
"
scala
"
:
languages
[
i
]
=
"
scala
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushScala.js
"
;
break
;
case
"
sql
"
:
languages
[
i
]
=
"
sql
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushSql.js
"
;
break
;
case
"
applescript
"
:
languages
[
i
]
=
"
applescript
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushAppleScript.js
"
;
break
;
case
"
as3
"
:
case
"
actionscript3
"
:
languages
[
i
]
=
"
actionscript3 as3
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushAS3.js
"
;
break
;
case
"
bash
"
:
case
"
shell
"
:
languages
[
i
]
=
"
bash shell
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushBash.js
"
;
break
;
case
"
coldfusion
"
:
case
"
cf
"
:
languages
[
i
]
=
"
coldfusion cf
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushColdFusion.js
"
;
break
;
case
"
c#
"
:
case
"
c-sharp
"
:
case
"
csharp
"
:
languages
[
i
]
=
"
c# c-sharp csharp
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushCSharp.js
"
;
break
;
case
"
cpp
"
:
case
"
c
"
:
languages
[
i
]
=
"
cpp c
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushCpp.js
"
;
break
;
case
"
css
"
:
languages
[
i
]
=
"
css
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushCss.js
"
;
break
;
case
"
delphi
"
:
case
"
pascal
"
:
languages
[
i
]
=
"
delphi pascal
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushDelphi.js
"
;
break
;
case
"
diff
"
:
case
"
patch
"
:
case
"
pas
"
:
languages
[
i
]
=
"
diff patch pas
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushDiff.js
"
;
break
;
case
"
erl
"
:
case
"
erlang
"
:
languages
[
i
]
=
"
erl erlang
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushErlang.js
"
;
break
;
case
"
js
"
:
case
"
jscript
"
:
case
"
javascript
"
:
languages
[
i
]
=
"
js jscript javascript
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushJScript.js
"
;
break
;
case
"
jfx
"
:
case
"
javafx
"
:
languages
[
i
]
=
"
jfx javafx
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushJavaFX.js
"
;
break
;
case
"
perl
"
:
case
"
pl
"
:
languages
[
i
]
=
"
perl pl
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushPerl.js
"
;
break
;
case
"
plain
"
:
case
"
text
"
:
languages
[
i
]
=
"
text plain
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushPlain.js
"
;
break
;
case
"
ps
"
:
case
"
powershell
"
:
languages
[
i
]
=
"
ps powershell
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushPowerShell.js
"
;
break
;
case
"
py
"
:
case
"
python
"
:
languages
[
i
]
=
"
py python
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushPython.js
"
;
break
;
case
"
rails
"
:
case
"
ror
"
:
case
"
ruby
"
:
case
"
rb
"
:
languages
[
i
]
=
"
ruby rails ror rb
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushRuby.js
"
;
break
;
case
"
sass
"
:
case
"
scss
"
:
languages
[
i
]
=
"
sass scss
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushSass.js
"
;
break
;
case
"
vb
"
:
case
"
vbnet
"
:
languages
[
i
]
=
"
vb vbnet
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushVb.js
"
;
break
;
case
"
xml
"
:
case
"
xhtml
"
:
case
"
xslt
"
:
case
"
html
"
:
languages
[
i
]
=
"
xml xhtml xslt html
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushXml.js
"
;
break
;
default
:
break
}}
SyntaxHighlighter
.
autoloader
.
apply
(
null
,
languages
);
SyntaxHighlighter
.
config
.
stripBrs
=
true
;
SyntaxHighlighter
.
all
()},
_loadSyntaxHighlighter
:
function
(
SHTheme
){
var
cssName
=
SHTheme
?
SHTheme
:
"
shCoreEclipse
"
,
that
=
this
;
if
(
document
.
createStyleSheet
){
document
.
createStyleSheet
(
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/styles/
"
+
cssName
+
"
.css
"
)}
else
{
$
(
"
head
"
).
append
(
$
(
"
<link rel='stylesheet' href='
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/styles/
"
+
cssName
+
"
.css' type='text/css' charset='utf-8' />
"
))}
$
.
ajax
({
url
:
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shCore.js
"
,
dataType
:
"
script
"
,
cache
:
true
,
success
:
function
(){
var
languages
=
[],
isScrip
=
false
;
$
(
"
.article-body pre, .code-highlight pre
"
).
each
(
function
(){
var
name
=
this
.
className
.
split
(
"
;
"
)[
0
];
var
language
=
name
.
substr
(
7
,
name
.
length
-
1
);
if
(
this
.
className
.
indexOf
(
"
html-script: true
"
)
>-
1
&&
(
language
!==
"
xml
"
&&
language
!==
"
xhtml
"
&&
language
!==
"
xslt
"
&&
language
!=
"
html
"
)){
isScrip
=
true
}
languages
.
push
(
language
)});
if
(
isScrip
){
$
.
ajax
({
url
:
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushXml.js
"
,
dataType
:
"
script
"
,
cache
:
true
,
success
:
function
(){
that
.
_initSyntaxHighlighter
(
languages
)}})}
else
{
that
.
_initSyntaxHighlighter
(
languages
)}}})},
parseLanguage
:
function
(
obj
){
var
isPrettify
=
false
,
isSH
=
false
;
$
(
"
.article-body pre, .code-highlight pre
"
).
each
(
function
(){
if
(
this
.
className
.
indexOf
(
"
brush
"
)
>-
1
){
isSH
=
true
}
if
(
this
.
className
.
indexOf
(
"
prettyprint
"
)
>-
1
){
isPrettify
=
true
}});
if
(
isSH
){
this
.
_loadSyntaxHighlighter
(
obj
?(
obj
.
SHTheme
?
obj
.
SHTheme
:
undefined
):
undefined
);
return
false
}
if
(
isPrettify
){
if
(
document
.
createStyleSheet
){
document
.
createStyleSheet
(
latkeConfig
.
staticServePath
+
"
/js/lib/google-code-prettify/prettify.css
"
)}
else
{
$
(
"
head
"
).
append
(
$
(
"
<link rel='stylesheet' href='
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/google-code-prettify/prettify.css'>
"
))}
$
.
ajax
({
url
:
latkeConfig
.
staticServePath
+
"
/js/lib/google-code-prettify/prettify.js
"
,
dataType
:
"
script
"
,
cache
:
true
,
success
:
function
(){
prettyPrint
()}});
return
false
}
if
(
document
.
createStyleSheet
){
document
.
createStyleSheet
(
latkeConfig
.
staticServePath
+
"
/js/lib/highlight/styles/default.css
"
)}
else
{
$
(
"
head
"
).
append
(
$
(
"
<link rel='stylesheet' href='
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/highlight/styles/github.css'>
"
))}
$
.
ajax
({
url
:
latkeConfig
.
staticServePath
+
"
/js/lib/highlight/highlight.pack.js
"
,
dataType
:
"
script
"
,
cache
:
true
,
success
:
function
(){
hljs
.
initHighlightingOnLoad
()}})},
load
:
function
(
obj
){
var
that
=
this
;
that
.
insertEmotions
();
that
.
parseLanguage
(
obj
?(
obj
.
language
?
obj
.
language
:
undefined
):
undefined
);
$
(
"
#commentValidate
"
).
keypress
(
function
(
event
){
if
(
event
.
keyCode
===
13
){
that
.
submitComment
()}});
$
(
"
#comment
"
).
keypress
(
function
(
event
){
if
(
event
.
keyCode
===
13
&&
event
.
ctrlKey
){
that
.
submitComment
()}});
$
(
"
#captcha
"
).
click
(
function
(){
$
(
this
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
())});
if
(
!
Util
.
isLoggedIn
()){
$
(
"
#commentEmail
"
).
val
(
Cookie
.
readCookie
(
"
commentEmail
"
));
$
(
"
#commentURL
"
).
val
(
Cookie
.
readCookie
(
"
commentURL
"
));
$
(
"
#commentName
"
).
val
(
Cookie
.
readCookie
(
"
commentName
"
))}
try
{
JSON
}
catch
(
e
){
document
.
write
(
'
<script src="
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/json2.js"><
\
/script>
'
)}},
loadRandomArticles
:
function
(
headTitle
){
var
randomArticles1Label
=
this
.
tips
.
randomArticles1Label
;
$
.
ajax
({
url
:
latkeConfig
.
servePath
+
"
/get-random-articles.do
"
,
type
:
"
POST
"
,
success
:
function
(
result
,
textStatus
){
var
randomArticles
=
result
.
randomArticles
;
if
(
!
randomArticles
||
0
===
randomArticles
.
length
){
$
(
"
#randomArticles
"
).
remove
();
return
}
var
listHtml
=
""
;
for
(
var
i
=
0
;
i
<
randomArticles
.
length
;
i
++
){
var
article
=
randomArticles
[
i
];
var
title
=
article
.
articleTitle
;
var
randomArticleLiHtml
=
"
<li><a rel='nofollow' title='
"
+
title
+
"
' href='
"
+
latkeConfig
.
servePath
+
article
.
articlePermalink
+
"
'>
"
+
title
+
"
</a></li>
"
;
listHtml
+=
randomArticleLiHtml
}
var
titleHTML
=
headTitle
?
headTitle
:
"
<h4>
"
+
randomArticles1Label
+
"
</h4>
"
;
var
randomArticleListHtml
=
titleHTML
+
"
<ul class='marginLeft12'>
"
+
listHtml
+
"
</ul>
"
;
$
(
"
#randomArticles
"
).
append
(
randomArticleListHtml
)}})},
loadRelevantArticles
:
function
(
id
,
headTitle
){
$
.
ajax
({
url
:
latkeConfig
.
servePath
+
"
/article/id/
"
+
id
+
"
/relevant/articles
"
,
type
:
"
GET
"
,
success
:
function
(
data
,
textStatus
){
var
articles
=
data
.
relevantArticles
;
if
(
!
articles
||
0
===
articles
.
length
){
$
(
"
#relevantArticles
"
).
remove
();
return
}
var
listHtml
=
""
;
for
(
var
i
=
0
;
i
<
articles
.
length
;
i
++
){
var
article
=
articles
[
i
];
var
title
=
article
.
articleTitle
;
var
articleLiHtml
=
"
<li><a rel='nofollow' title='
"
+
title
+
"
' href='
"
+
latkeConfig
.
servePath
+
article
.
articlePermalink
+
"
'>
"
+
title
+
"
</a></li>
"
;
listHtml
+=
articleLiHtml
}
var
relevantArticleListHtml
=
headTitle
+
"
<ul class='marginLeft12'>
"
+
listHtml
+
"
</ul>
"
;
$
(
"
#relevantArticles
"
).
append
(
relevantArticleListHtml
)},
error
:
function
(){
$
(
"
#relevantArticles
"
).
remove
()}})},
loadExternalRelevantArticles
:
function
(
tags
,
headTitle
){
var
tips
=
this
.
tips
;
try
{
$
.
ajax
({
url
:
"
http://rhythm.b3log.org:80/get-articles-by-tags.do?tags=
"
+
tags
+
"
&blogHost=
"
+
tips
.
blogHost
+
"
&paginationPageSize=
"
+
tips
.
externalRelevantArticlesDisplayCount
,
type
:
"
GET
"
,
cache
:
true
,
dataType
:
"
jsonp
"
,
error
:
function
(){
$
(
"
#externalRelevantArticles
"
).
remove
()},
success
:
function
(
data
,
textStatus
){
var
articles
=
data
.
articles
;
if
(
!
articles
||
0
===
articles
.
length
){
$
(
"
#externalRelevantArticles
"
).
remove
();
return
}
var
listHtml
=
""
;
for
(
var
i
=
0
;
i
<
articles
.
length
;
i
++
){
var
article
=
articles
[
i
];
var
title
=
article
.
articleTitle
;
var
articleLiHtml
=
"
<li><a rel='nofollow' title='
"
+
title
+
"
' target='_blank' href='
"
+
article
.
articlePermalink
+
"
'>
"
+
title
+
"
</a></li>
"
;
listHtml
+=
articleLiHtml
}
var
titleHTML
=
headTitle
?
headTitle
:
"
<h4>
"
+
tips
.
externalRelevantArticles1Label
+
"
</h4>
"
;
var
randomArticleListHtml
=
titleHTML
+
"
<ul class='marginLeft12'>
"
+
listHtml
+
"
</ul>
"
;
$
(
"
#externalRelevantArticles
"
).
append
(
randomArticleListHtml
)}})}
catch
(
e
){}},
submitComment
:
function
(
commentId
,
state
){
if
(
!
state
){
state
=
""
}
var
that
=
this
,
tips
=
this
.
tips
,
type
=
"
article
"
;
if
(
tips
.
externalRelevantArticlesDisplayCount
===
undefined
){
type
=
"
page
"
}
if
(
this
.
validateComment
(
state
)){
$
(
"
#submitCommentButton
"
+
state
).
attr
(
"
disabled
"
,
"
disabled
"
);
$
(
"
#commentErrorTip
"
+
state
).
show
().
html
(
this
.
tips
.
loadingLabel
);
var
requestJSONObject
=
{
oId
:
tips
.
oId
,
commentContent
:
$
(
"
#comment
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
)};
if
(
!
Util
.
isLoggedIn
()){
requestJSONObject
=
{
oId
:
tips
.
oId
,
commentContent
:
$
(
"
#comment
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
),
commentEmail
:
$
(
"
#commentEmail
"
+
state
).
val
(),
commentURL
:
Util
.
proessURL
(
$
(
"
#commentURL
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
)),
commentName
:
$
(
"
#commentName
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
),
captcha
:
$
(
"
#commentValidate
"
+
state
).
val
()};
Cookie
.
createCookie
(
"
commentName
"
,
requestJSONObject
.
commentName
,
365
);
Cookie
.
createCookie
(
"
commentEmail
"
,
requestJSONObject
.
commentEmail
,
365
);
Cookie
.
createCookie
(
"
commentURL
"
,
$
(
"
#commentURL
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
),
365
)}
if
(
state
===
"
Reply
"
){
requestJSONObject
.
commentOriginalCommentId
=
commentId
}
$
.
ajax
({
type
:
"
POST
"
,
url
:
latkeConfig
.
servePath
+
"
/add-
"
+
type
+
"
-comment.do
"
,
cache
:
false
,
contentType
:
"
application/json
"
,
data
:
JSON
.
stringify
(
requestJSONObject
),
success
:
function
(
result
){
if
(
!
result
.
sc
){
$
(
"
#commentErrorTip
"
+
state
).
html
(
result
.
msg
);
$
(
"
#comment
"
+
state
).
val
(
""
).
focus
();
$
(
"
#submitCommentButton
"
+
state
).
removeAttr
(
"
disabled
"
);
if
(
!
Util
.
isLoggedIn
()){
$
(
"
#captcha
"
+
state
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
())}
return
}
$
(
"
#comment
"
+
state
).
val
(
result
.
commentContent
);
$
(
"
#commentName
"
+
state
).
val
(
result
.
commentName
);
result
.
replyNameHTML
=
""
;
if
(
!
Util
.
isLoggedIn
()){
$
(
"
#captcha
"
+
state
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
());
if
(
$
(
"
#commentURL
"
+
state
).
val
().
replace
(
/
\s
/g
,
""
)
===
""
){
result
.
replyNameHTML
=
"
<a>
"
+
$
(
"
#commentName
"
+
state
).
val
()
+
"
</a>
"
}
else
{
result
.
replyNameHTML
=
'
<a href="
'
+
Util
.
proessURL
(
$
(
"
#commentURL
"
+
state
).
val
())
+
'
" target="_blank">
'
+
$
(
"
#commentName
"
+
state
).
val
()
+
"
</a>
"
}
result
.
userName
=
result
.
commentName
}
else
{
result
.
replyNameHTML
=
'
<a href="
'
+
window
.
location
.
host
+
'
" target="_blank">
'
+
Util
.
getUserName
()
+
"
</a>
"
;
result
.
userName
=
Util
.
getUserName
()}
that
.
addCommentAjax
(
addComment
(
result
,
state
),
state
);
$
(
"
#submitCommentButton
"
+
state
).
removeAttr
(
"
disabled
"
)}})}},
addReplyForm
:
function
(
id
,
commentFormHTML
,
endHTML
){
var
that
=
this
;
if
(
id
===
this
.
currentCommentId
){
if
(
$
(
"
#commentNameReply
"
).
val
()
===
""
){
$
(
"
#commentNameReply
"
).
focus
()}
else
{
if
(
$
(
"
#commentEmailReply
"
).
val
()
===
""
){
$
(
"
#commentEmailReply
"
).
focus
()}
else
{
$
(
"
#commentReply
"
).
focus
()}}
return
}
$
(
"
#replyForm
"
).
remove
();
endHTML
=
endHTML
?
endHTML
:
""
;
if
(
endHTML
===
"
</div>
"
){
$
(
"
#
"
+
id
).
append
(
commentFormHTML
+
$
(
"
#commentForm
"
).
html
()
+
endHTML
)}
else
{
$
(
"
#
"
+
id
).
append
(
commentFormHTML
+
$
(
"
#commentForm
"
).
html
()
+
"
</table>
"
+
endHTML
)}
$
(
"
#replyForm input, #replyForm textarea
"
).
each
(
function
(){
this
.
id
=
this
.
id
+
"
Reply
"
});
$
(
"
#commentNameReply
"
).
val
(
Cookie
.
readCookie
(
"
commentName
"
));
$
(
"
#commentEmailReply
"
).
val
(
Cookie
.
readCookie
(
"
commentEmail
"
));
var
$label
=
$
(
"
#replyForm #commentURLLabel
"
);
if
(
$label
.
length
===
1
){
$label
.
attr
(
"
id
"
,
"
commentURLLabelReply
"
)}
$
(
"
#commentURLReply
"
).
val
(
Cookie
.
readCookie
(
"
commentURL
"
));
$
(
"
#replyForm #emotions
"
).
attr
(
"
id
"
,
"
emotionsReply
"
);
this
.
insertEmotions
(
"
Reply
"
);
$
(
"
#commentReply
"
).
unbind
().
keypress
(
function
(
event
){
if
(
event
.
keyCode
===
13
&&
event
.
ctrlKey
){
that
.
submitComment
(
id
,
"
Reply
"
);
event
.
preventDefault
()}});
$
(
"
#commentValidateReply
"
).
unbind
().
keypress
(
function
(
event
){
if
(
event
.
keyCode
===
13
){
that
.
submitComment
(
id
,
"
Reply
"
);
event
.
preventDefault
()}});
$
(
"
#replyForm #captcha
"
).
attr
(
"
id
"
,
"
captchaReply
"
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?
"
+
new
Date
().
getTime
()).
click
(
function
(){
$
(
this
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
())});
$
(
"
#replyForm #commentErrorTip
"
).
attr
(
"
id
"
,
"
commentErrorTipReply
"
).
html
(
""
).
hide
();
$
(
"
#replyForm #submitCommentButton
"
).
attr
(
"
id
"
,
"
submitCommentButtonReply
"
);
$
(
"
#replyForm #submitCommentButtonReply
"
).
unbind
(
"
click
"
).
removeAttr
(
"
onclick
"
).
click
(
function
(){
that
.
submitComment
(
id
,
"
Reply
"
)});
if
(
$
(
"
#commentNameReply
"
).
val
()
===
""
){
$
(
"
#commentNameReply
"
).
focus
()}
else
{
if
(
$
(
"
#commentEmailReply
"
).
val
()
===
""
){
$
(
"
#commentEmailReply
"
).
focus
()}
else
{
$
(
"
#commentReply
"
).
focus
()}}
this
.
currentCommentId
=
id
},
hideComment
:
function
(
id
){
$
(
"
#commentRef
"
+
id
).
hide
()},
showComment
:
function
(
it
,
id
,
top
,
parentTag
){
var
positionTop
=
parseInt
(
$
(
it
).
position
().
top
);
if
(
parentTag
){
positionTop
=
parseInt
(
$
(
it
).
parents
(
parentTag
).
position
().
top
)}
if
(
$
(
"
#commentRef
"
+
id
).
length
>
0
){
$
(
"
#commentRef
"
+
id
).
show
().
css
(
"
top
"
,(
positionTop
+
top
)
+
"
px
"
)}
else
{
var
$refComment
=
$
(
"
#
"
+
id
).
clone
();
$refComment
.
addClass
(
"
comment-body-ref
"
).
attr
(
"
id
"
,
"
commentRef
"
+
id
);
$refComment
.
find
(
"
#replyForm
"
).
remove
();
$
(
"
#comments
"
).
append
(
$refComment
);
$
(
"
#commentRef
"
+
id
).
css
(
"
top
"
,(
positionTop
+
top
)
+
"
px
"
)}},
addCommentAjax
:
function
(
commentHTML
,
state
){
if
(
$
(
"
#comments
"
).
children
().
length
>
0
){
$
(
$
(
"
#comments
"
).
children
()[
0
]).
before
(
commentHTML
)}
else
{
$
(
"
#comments
"
).
html
(
commentHTML
)}
if
(
state
===
""
){
$
(
"
#commentErrorTip
"
).
html
(
""
).
hide
();
$
(
"
#comment
"
).
val
(
""
);
$
(
"
#commentValidate
"
).
val
(
""
);
$
(
"
#captcha
"
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
())}
else
{
$
(
"
#replyForm
"
).
remove
()}
window
.
location
.
hash
=
"
#comments
"
}});
\ No newline at end of file
src/main/webapp/skins/yilia/macro-comments.ftl
View file @
2afdf994
...
...
@@ -131,7 +131,7 @@
commentHTML += '<a class="fn-right" href="javascript:replyTo(\'' + result.oId + '\');">${replyLabel}</a>';
}
commentHTML += '</div><div class="comment-content">' +
Util.replaceEmString($("#comment" + state).val()
.replace(/</g, "<").replace(/>/g, ">").replace(/\n/g, "<br/>")
)
Util.replaceEmString($("#comment" + state).val())
+ '</div></div></li>';
return commentHTML;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment