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,10 +536,7 @@ $.extend(Page.prototype, { ...@@ -536,10 +536,7 @@ $.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 = {
"oId": tips.oId, "oId": tips.oId,
...@@ -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,94 +90,97 @@ ...@@ -90,94 +90,97 @@
<#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 = '';
}
var tips = this.tips,
type = "article";
if (tips.externalRelevantArticlesDisplayCount === undefined) {
type = "page";
}
if (this.validateComment(state)) {
$("#submitCommentButton" + state).attr("disabled", "disabled");
$("#commentErrorTip" + state).html(this.tips.loadingLabel);
var 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()
};
if (state === "Reply") {
requestJSONObject.commentOriginalCommentId = commentId;
} }
var 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 (!$("#admin").data("login")) {
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);
}
$wpt("#loading").fadeIn(400); if (state === "Reply") {
requestJSONObject.commentOriginalCommentId = commentId;
$.ajax({ }
type: "POST", $.ajax({
url: "/add-" + type + "-comment.do", type: "POST",
contentType: "application/json", url: latkeConfig.servePath + "/add-" + type + "-comment.do",
data: JSON.stringify(requestJSONObject), cache: false,
success: function(result){ contentType: "application/json",
$("#submitCommentButton" + state).removeAttr("disabled"); data: JSON.stringify(requestJSONObject),
success: function(result) {
$("#submitCommentButton" + state).removeAttr("disabled");
if (!result.sc) { if (!result.sc) {
$("#commentValidate" + state).val("").focus(); $("#commentValidate" + state).val("").focus();
$("#commentErrorTip" + state).html(result.msg); $("#commentErrorTip" + state).html(result.msg);
$("#captcha" + state).attr("src", "/captcha.do?code=" + Math.random()); $("#captcha" + state).attr("src", "/captcha.do?code=" + Math.random());
$wpt('#commentErrorTip' + state).show(); $wpt('#commentErrorTip' + state).show();
$wpt("#loading").fadeOut(400);
return;
}
$wpt("#commentForm").hide();
$wpt("#loading").fadeOut(400); $wpt("#loading").fadeOut(400);
return; $wpt("#refresher").fadeIn(400);
} $("#comment" + state).val("");
$("#commentValidate" + state).val("");
$wpt("#commentForm").hide(); $("#replyForm").remove();
$wpt("#loading").fadeOut(400);
$wpt("#refresher").fadeIn(400); }, // end success
$("#comment" + state).val(""); error: function() {
$("#commentValidate" + state).val(""); } //end error
$("#replyForm").remove(); });
}
}, // end success
error: function() { };
} //end error var replyTo = function(id) {
}); var commentFormHTML = "<div id='replyForm'>";
page.addReplyForm(id, commentFormHTML, "</div>");
};
Cookie.createCookie("commentName", requestJSONObject.commentName, 365); var page = new Page({
Cookie.createCookie("commentEmail", requestJSONObject.commentEmail, 365); "nameTooLongLabel": "${nameTooLongLabel}",
Cookie.createCookie("commentURL", $("#commentURL" + state).val().replace(/(^\s*)|(\s*$)/g, ""), 365); "mailCannotEmptyLabel": "${mailCannotEmptyLabel}",
} "mailInvalidLabel": "${mailInvalidLabel}",
}; "commentContentCannotEmptyLabel": "${commentContentCannotEmptyLabel}",
"captchaCannotEmptyLabel": "${captchaCannotEmptyLabel}",
var replyTo = function (id) { "loadingLabel": "${loadingLabel}",
var commentFormHTML = "<div id='replyForm'>"; "oId": "${oId}",
page.addReplyForm(id, commentFormHTML, "</div>"); "skinDirName": "${skinDirName}",
}; "blogHost": "${blogHost}",
"randomArticles1Label": "${randomArticles1Label}",
var page = new Page({ "externalRelevantArticles1Label": "${externalRelevantArticles1Label}"
"nameTooLongLabel": "${nameTooLongLabel}", });
"mailCannotEmptyLabel": "${mailCannotEmptyLabel}",
"mailInvalidLabel": "${mailInvalidLabel}",
"commentContentCannotEmptyLabel": "${commentContentCannotEmptyLabel}",
"captchaCannotEmptyLabel": "${captchaCannotEmptyLabel}",
"loadingLabel": "${loadingLabel}",
"oId": "${oId}",
"skinDirName": "${skinDirName}",
"blogHost": "${blogHost}",
"randomArticles1Label": "${randomArticles1Label}",
"externalRelevantArticles1Label": "${externalRelevantArticles1Label}"
});
(function () { (function() {
page.load(); page.load();
// emotions // emotions
page.replaceCommentsEm("#commentlist .combody"); page.replaceCommentsEm("#commentlist .combody");
<#nested> <#nested>
})(); })();
</script> </script>
......
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