Commit d44d2f5b authored by Vanessa's avatar Vanessa

评论获取用户名修改

parent 7aa15afe
......@@ -18,7 +18,7 @@
*
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</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) {
this.currentCommentId = "";
......@@ -265,7 +265,7 @@ $.extend(Page.prototype, {
}
}
// code high lighter
// code high lighter
SyntaxHighlighter.autoloader.apply(null, languages);
SyntaxHighlighter.config.stripBrs = true;
SyntaxHighlighter.all();
......@@ -285,13 +285,13 @@ $.extend(Page.prototype, {
+ cssName + ".css' type='text/css' charset='utf-8' />"));
}
// load js
// load js
$.ajax({
url: latkeConfig.staticServePath + "/js/lib/SyntaxHighlighter/scripts/shCore.js",
dataType: "script",
cache: true,
success: function() {
// get brush settings
// get brush settings
var languages = [],
isScrip = false;
$(".article-body pre").each(function() {
......@@ -343,14 +343,14 @@ $.extend(Page.prototype, {
}
if (isPrettify) {
// load css
// load css
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'>"));
}
// load js
// load js
$.ajax({
url: latkeConfig.staticServePath + "/js/lib/google-code-prettify/prettify.js",
dataType: "script",
......@@ -510,7 +510,7 @@ $.extend(Page.prototype, {
}
});
} catch (e) {
// 忽略相关文章加载异常:load script error
// 忽略相关文章加载异常:load script error
}
},
/*
......@@ -536,10 +536,7 @@ $.extend(Page.prototype, {
"oId": tips.oId,
"commentContent": $("#comment" + state).val().replace(/(^\s*)|(\s*$)/g, "")
};
if (state === "Reply") {
requestJSONObject.commentOriginalCommentId = commentId;
}
if (!$("#admin").data("login")) {
requestJSONObject = {
"oId": tips.oId,
......@@ -553,6 +550,11 @@ $.extend(Page.prototype, {
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",
......@@ -579,9 +581,11 @@ $.extend(Page.prototype, {
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">' + $("#adminName").val() + '</a>';
'" target="_blank">' + $("#adminName").text() + '</a>';
result.userName = $("#adminName").text();
}
that.addCommentAjax(addComment(result, state), state);
......
This diff is collapsed.
......@@ -124,14 +124,18 @@
var addComment = function(result, state) {
var commentHTML = '<div id="' + result.oId + '"><img class="comment-header" \
title="' + $("#commentName" + state).val() + '" alt="' + $("#commentName" + state).val() +
'" src="' + result.commentThumbnailURL + '"/><div class="comment-panel"><div class="left">' + result.replyNameHTML;
title="' + result.userName + '" alt="' + result.userName +
'" src="' + result.commentThumbnailURL
+ '"/><div class="comment-panel"><div class="left">' + result.replyNameHTML;
if (state !== "") {
var commentOriginalCommentName = $("#" + page.currentCommentId + " .comment-panel>.left a").first().text();
commentHTML += '&nbsp;@&nbsp;<a href="${servePath}' + result.commentSharpURL.split("#")[0] + '#' + page.currentCommentId + '"'
var commentOriginalCommentName = $("#" + 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);"'
+ '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)
......@@ -141,7 +145,7 @@
+ '</div></div><span class="clear"></span></div>';
return commentHTML;
}
};
var replyTo = function(id) {
var commentFormHTML = "<table class='form' id='replyForm'>";
......
......@@ -34,7 +34,7 @@
</div>
<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>
<li><a href="${page.pagePermalink}" target="${page.pageOpenTarget}"><img src="${staticServePath}/skins/${skinDirName}/images/icon-pool/Apps.png" alt=""/>${page.pageTitle}</a></li>
</#list>
......
......@@ -90,94 +90,97 @@
<#macro comment_script oId>
<script type="text/javascript" src="${staticServePath}/js/page${miniPostfix}.js?${staticResourceVersion}" charset="utf-8"></script>
<script type="text/javascript">
Page.prototype.submitComment = function (commentId, state) {
if (!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;
Page.prototype.submitComment = function(commentId, state) {
if (!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).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);
$.ajax({
type: "POST",
url: "/add-" + type + "-comment.do",
contentType: "application/json",
data: JSON.stringify(requestJSONObject),
success: function(result){
$("#submitCommentButton" + state).removeAttr("disabled");
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) {
$("#submitCommentButton" + state).removeAttr("disabled");
if (!result.sc) {
$("#commentValidate" + state).val("").focus();
$("#commentErrorTip" + state).html(result.msg);
$("#captcha" + state).attr("src", "/captcha.do?code=" + Math.random());
$wpt('#commentErrorTip' + state).show();
if (!result.sc) {
$("#commentValidate" + state).val("").focus();
$("#commentErrorTip" + state).html(result.msg);
$("#captcha" + state).attr("src", "/captcha.do?code=" + Math.random());
$wpt('#commentErrorTip' + state).show();
$wpt("#loading").fadeOut(400);
return;
}
$wpt("#commentForm").hide();
$wpt("#loading").fadeOut(400);
return;
}
$wpt("#commentForm").hide();
$wpt("#loading").fadeOut(400);
$wpt("#refresher").fadeIn(400);
$("#comment" + state).val("");
$("#commentValidate" + state).val("");
$("#replyForm").remove();
}, // end success
error: function() {
} //end error
});
$wpt("#refresher").fadeIn(400);
$("#comment" + state).val("");
$("#commentValidate" + state).val("");
$("#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);
Cookie.createCookie("commentEmail", requestJSONObject.commentEmail, 365);
Cookie.createCookie("commentURL", $("#commentURL" + state).val().replace(/(^\s*)|(\s*$)/g, ""), 365);
}
};
var replyTo = function (id) {
var commentFormHTML = "<div id='replyForm'>";
page.addReplyForm(id, commentFormHTML, "</div>");
};
var page = new Page({
"nameTooLongLabel": "${nameTooLongLabel}",
"mailCannotEmptyLabel": "${mailCannotEmptyLabel}",
"mailInvalidLabel": "${mailInvalidLabel}",
"commentContentCannotEmptyLabel": "${commentContentCannotEmptyLabel}",
"captchaCannotEmptyLabel": "${captchaCannotEmptyLabel}",
"loadingLabel": "${loadingLabel}",
"oId": "${oId}",
"skinDirName": "${skinDirName}",
"blogHost": "${blogHost}",
"randomArticles1Label": "${randomArticles1Label}",
"externalRelevantArticles1Label": "${externalRelevantArticles1Label}"
});
var page = new Page({
"nameTooLongLabel": "${nameTooLongLabel}",
"mailCannotEmptyLabel": "${mailCannotEmptyLabel}",
"mailInvalidLabel": "${mailInvalidLabel}",
"commentContentCannotEmptyLabel": "${commentContentCannotEmptyLabel}",
"captchaCannotEmptyLabel": "${captchaCannotEmptyLabel}",
"loadingLabel": "${loadingLabel}",
"oId": "${oId}",
"skinDirName": "${skinDirName}",
"blogHost": "${blogHost}",
"randomArticles1Label": "${randomArticles1Label}",
"externalRelevantArticles1Label": "${externalRelevantArticles1Label}"
});
(function () {
page.load();
// emotions
page.replaceCommentsEm("#commentlist .combody");
(function() {
page.load();
// emotions
page.replaceCommentsEm("#commentlist .combody");
<#nested>
})();
</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