Commit d44d2f5b authored by Vanessa's avatar Vanessa

评论获取用户名修改

parent 7aa15afe
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* *
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a> * @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a> * @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.3.4, Sep 12, 2013 * @version 1.0.3.5, Oct 26, 2013
*/ */
var Page = function(tips) { var Page = function(tips) {
this.currentCommentId = ""; this.currentCommentId = "";
...@@ -265,7 +265,7 @@ $.extend(Page.prototype, { ...@@ -265,7 +265,7 @@ $.extend(Page.prototype, {
} }
} }
// code high lighter // code high lighter
SyntaxHighlighter.autoloader.apply(null, languages); SyntaxHighlighter.autoloader.apply(null, languages);
SyntaxHighlighter.config.stripBrs = true; SyntaxHighlighter.config.stripBrs = true;
SyntaxHighlighter.all(); SyntaxHighlighter.all();
...@@ -285,13 +285,13 @@ $.extend(Page.prototype, { ...@@ -285,13 +285,13 @@ $.extend(Page.prototype, {
+ cssName + ".css' type='text/css' charset='utf-8' />")); + cssName + ".css' type='text/css' charset='utf-8' />"));
} }
// load js // load js
$.ajax({ $.ajax({
url: latkeConfig.staticServePath + "/js/lib/SyntaxHighlighter/scripts/shCore.js", url: latkeConfig.staticServePath + "/js/lib/SyntaxHighlighter/scripts/shCore.js",
dataType: "script", dataType: "script",
cache: true, cache: true,
success: function() { success: function() {
// get brush settings // get brush settings
var languages = [], var languages = [],
isScrip = false; isScrip = false;
$(".article-body pre").each(function() { $(".article-body pre").each(function() {
...@@ -343,14 +343,14 @@ $.extend(Page.prototype, { ...@@ -343,14 +343,14 @@ $.extend(Page.prototype, {
} }
if (isPrettify) { if (isPrettify) {
// load css // load css
if (document.createStyleSheet) { if (document.createStyleSheet) {
document.createStyleSheet(latkeConfig.staticServePath + "/js/lib/google-code-prettify/prettify.css"); document.createStyleSheet(latkeConfig.staticServePath + "/js/lib/google-code-prettify/prettify.css");
} else { } else {
$("head").append($("<link rel='stylesheet' href='" + latkeConfig.staticServePath + "/js/lib/google-code-prettify/prettify.css'>")); $("head").append($("<link rel='stylesheet' href='" + latkeConfig.staticServePath + "/js/lib/google-code-prettify/prettify.css'>"));
} }
// load js // load js
$.ajax({ $.ajax({
url: latkeConfig.staticServePath + "/js/lib/google-code-prettify/prettify.js", url: latkeConfig.staticServePath + "/js/lib/google-code-prettify/prettify.js",
dataType: "script", dataType: "script",
...@@ -510,7 +510,7 @@ $.extend(Page.prototype, { ...@@ -510,7 +510,7 @@ $.extend(Page.prototype, {
} }
}); });
} catch (e) { } catch (e) {
// 忽略相关文章加载异常:load script error // 忽略相关文章加载异常:load script error
} }
}, },
/* /*
...@@ -536,9 +536,6 @@ $.extend(Page.prototype, { ...@@ -536,9 +536,6 @@ $.extend(Page.prototype, {
"oId": tips.oId, "oId": tips.oId,
"commentContent": $("#comment" + state).val().replace(/(^\s*)|(\s*$)/g, "") "commentContent": $("#comment" + state).val().replace(/(^\s*)|(\s*$)/g, "")
}; };
if (state === "Reply") {
requestJSONObject.commentOriginalCommentId = commentId;
}
if (!$("#admin").data("login")) { if (!$("#admin").data("login")) {
requestJSONObject = { requestJSONObject = {
...@@ -553,6 +550,11 @@ $.extend(Page.prototype, { ...@@ -553,6 +550,11 @@ $.extend(Page.prototype, {
Cookie.createCookie("commentEmail", requestJSONObject.commentEmail, 365); Cookie.createCookie("commentEmail", requestJSONObject.commentEmail, 365);
Cookie.createCookie("commentURL", $("#commentURL" + state).val().replace(/(^\s*)|(\s*$)/g, ""), 365); Cookie.createCookie("commentURL", $("#commentURL" + state).val().replace(/(^\s*)|(\s*$)/g, ""), 365);
} }
if (state === "Reply") {
requestJSONObject.commentOriginalCommentId = commentId;
}
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: latkeConfig.servePath + "/add-" + type + "-comment.do", url: latkeConfig.servePath + "/add-" + type + "-comment.do",
...@@ -579,9 +581,11 @@ $.extend(Page.prototype, { ...@@ -579,9 +581,11 @@ $.extend(Page.prototype, {
result.replyNameHTML = '<a href="' + Util.proessURL($("#commentURL" + state).val()) + result.replyNameHTML = '<a href="' + Util.proessURL($("#commentURL" + state).val()) +
'" target="_blank">' + $("#commentName" + state).val() + '</a>'; '" target="_blank">' + $("#commentName" + state).val() + '</a>';
} }
result.userName = $("#commentName" + state).val();
} else { } else {
result.replyNameHTML = '<a href="' + window.location.host + result.replyNameHTML = '<a href="' + window.location.host +
'" target="_blank">' + $("#adminName").val() + '</a>'; '" target="_blank">' + $("#adminName").text() + '</a>';
result.userName = $("#adminName").text();
} }
that.addCommentAjax(addComment(result, state), state); that.addCommentAjax(addComment(result, state), state);
......
This diff is collapsed.
...@@ -124,14 +124,18 @@ ...@@ -124,14 +124,18 @@
var addComment = function(result, state) { var addComment = function(result, state) {
var commentHTML = '<div id="' + result.oId + '"><img class="comment-header" \ var commentHTML = '<div id="' + result.oId + '"><img class="comment-header" \
title="' + $("#commentName" + state).val() + '" alt="' + $("#commentName" + state).val() + title="' + result.userName + '" alt="' + result.userName +
'" src="' + result.commentThumbnailURL + '"/><div class="comment-panel"><div class="left">' + result.replyNameHTML; '" src="' + result.commentThumbnailURL
+ '"/><div class="comment-panel"><div class="left">' + result.replyNameHTML;
if (state !== "") { if (state !== "") {
var commentOriginalCommentName = $("#" + page.currentCommentId + " .comment-panel>.left a").first().text(); var commentOriginalCommentName = $("#" + page.currentCommentId
commentHTML += '&nbsp;@&nbsp;<a href="${servePath}' + result.commentSharpURL.split("#")[0] + '#' + page.currentCommentId + '"' + " .comment-panel>.left a").first().text();
commentHTML += '&nbsp;@&nbsp;<a href="${servePath}'
+ result.commentSharpURL.split("#")[0] + '#' + page.currentCommentId + '"'
+ 'onmouseover="page.showComment(this, \'' + page.currentCommentId + '\', 20);"' + 'onmouseover="page.showComment(this, \'' + page.currentCommentId + '\', 20);"'
+ 'onmouseout="page.hideComment(\'' + page.currentCommentId + '\')">' + commentOriginalCommentName + '</a>'; + 'onmouseout="page.hideComment(\'' + page.currentCommentId + '\')">'
+ commentOriginalCommentName + '</a>';
} }
commentHTML += '</div><div class="right ft-gray">' + result.commentDate.substring(2, 16) commentHTML += '</div><div class="right ft-gray">' + result.commentDate.substring(2, 16)
...@@ -141,7 +145,7 @@ ...@@ -141,7 +145,7 @@
+ '</div></div><span class="clear"></span></div>'; + '</div></div><span class="clear"></span></div>';
return commentHTML; return commentHTML;
} };
var replyTo = function(id) { var replyTo = function(id) {
var commentFormHTML = "<table class='form' id='replyForm'>"; var commentFormHTML = "<table class='form' id='replyForm'>";
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
</div> </div>
<ul id="head-pages"> <ul id="head-pages">
<li><a href="${servePath}/admin-index.do#main"><img src="${staticServePath}/skins/${skinDirName}/images/icon-pool/Home.png" alt=""/>Admin</a></li> <li id="admin" data-login="${isLoggedIn?string}"><a href="${servePath}/admin-index.do#main"><img src="${staticServePath}/skins/${skinDirName}/images/icon-pool/Home.png" alt=""/>Admin</a></li>
<#list pageNavigations as page> <#list pageNavigations as page>
<li><a href="${page.pagePermalink}" target="${page.pageOpenTarget}"><img src="${staticServePath}/skins/${skinDirName}/images/icon-pool/Apps.png" alt=""/>${page.pageTitle}</a></li> <li><a href="${page.pagePermalink}" target="${page.pageOpenTarget}"><img src="${staticServePath}/skins/${skinDirName}/images/icon-pool/Apps.png" alt=""/>${page.pageTitle}</a></li>
</#list> </#list>
......
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
<#macro comment_script oId> <#macro comment_script oId>
<script type="text/javascript" src="${staticServePath}/js/page${miniPostfix}.js?${staticResourceVersion}" charset="utf-8"></script> <script type="text/javascript" src="${staticServePath}/js/page${miniPostfix}.js?${staticResourceVersion}" charset="utf-8"></script>
<script type="text/javascript"> <script type="text/javascript">
Page.prototype.submitComment = function (commentId, state) { Page.prototype.submitComment = function(commentId, state) {
if (!state) { if (!state) {
state = ''; state = '';
} }
...@@ -102,9 +102,14 @@ ...@@ -102,9 +102,14 @@
if (this.validateComment(state)) { if (this.validateComment(state)) {
$("#submitCommentButton" + state).attr("disabled", "disabled"); $("#submitCommentButton" + state).attr("disabled", "disabled");
$("#commentErrorTip" + state).html(this.tips.loadingLabel); $("#commentErrorTip" + state).show().html(this.tips.loadingLabel);
var requestJSONObject = { var requestJSONObject = {
"oId": tips.oId,
"commentContent": $("#comment" + state).val().replace(/(^\s*)|(\s*$)/g, "")
};
if (!$("#admin").data("login")) {
requestJSONObject = {
"oId": tips.oId, "oId": tips.oId,
"commentContent": $("#comment" + state).val().replace(/(^\s*)|(\s*$)/g, ""), "commentContent": $("#comment" + state).val().replace(/(^\s*)|(\s*$)/g, ""),
"commentEmail": $("#commentEmail" + state).val(), "commentEmail": $("#commentEmail" + state).val(),
...@@ -112,19 +117,21 @@ ...@@ -112,19 +117,21 @@
"commentName": $("#commentName" + state).val().replace(/(^\s*)|(\s*$)/g, ""), "commentName": $("#commentName" + state).val().replace(/(^\s*)|(\s*$)/g, ""),
"captcha": $("#commentValidate" + state).val() "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") { if (state === "Reply") {
requestJSONObject.commentOriginalCommentId = commentId; requestJSONObject.commentOriginalCommentId = commentId;
} }
$wpt("#loading").fadeIn(400);
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/add-" + type + "-comment.do", url: latkeConfig.servePath + "/add-" + type + "-comment.do",
cache: false,
contentType: "application/json", contentType: "application/json",
data: JSON.stringify(requestJSONObject), data: JSON.stringify(requestJSONObject),
success: function(result){ success: function(result) {
$("#submitCommentButton" + state).removeAttr("disabled"); $("#submitCommentButton" + state).removeAttr("disabled");
if (!result.sc) { if (!result.sc) {
...@@ -145,17 +152,13 @@ ...@@ -145,17 +152,13 @@
}, // end success }, // end success
error: function() { error: function() {
} //end error } //end error
}); });
Cookie.createCookie("commentName", requestJSONObject.commentName, 365);
Cookie.createCookie("commentEmail", requestJSONObject.commentEmail, 365);
Cookie.createCookie("commentURL", $("#commentURL" + state).val().replace(/(^\s*)|(\s*$)/g, ""), 365);
} }
}; };
var replyTo = function (id) { var replyTo = function(id) {
var commentFormHTML = "<div id='replyForm'>"; var commentFormHTML = "<div id='replyForm'>";
page.addReplyForm(id, commentFormHTML, "</div>"); page.addReplyForm(id, commentFormHTML, "</div>");
}; };
...@@ -174,7 +177,7 @@ ...@@ -174,7 +177,7 @@
"externalRelevantArticles1Label": "${externalRelevantArticles1Label}" "externalRelevantArticles1Label": "${externalRelevantArticles1Label}"
}); });
(function () { (function() {
page.load(); page.load();
// emotions // emotions
page.replaceCommentsEm("#commentlist .combody"); page.replaceCommentsEm("#commentlist .combody");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment