Commit a10545dc authored by wangdx's avatar wangdx

ignore some idea files/folders

parent b8e2ea7a
...@@ -6,4 +6,10 @@ ...@@ -6,4 +6,10 @@
/war/mysql/target/ /war/mysql/target/
/war/h2/target/ /war/h2/target/
/war/src/main/webapp/WEB-INF/lib/ /war/src/main/webapp/WEB-INF/lib/
.idea/copyright/
.idea/uiDesigner.xml
.idea/workspace.xml
.idea/tasks.xml
.DS_Store .DS_Store
...@@ -2704,268 +2704,268 @@ admin.register["link-list"] = { ...@@ -2704,268 +2704,268 @@ admin.register["link-list"] = {
"obj": admin.linkList, "obj": admin.linkList,
"init": admin.linkList.init, "init": admin.linkList.init,
"refresh": admin.linkList.getList "refresh": admin.linkList.getList
}/* }/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team * Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/** /**
* preference for admin. * preference for admin.
* *
* @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.1.7, Mar 5, 2013 * @version 1.0.1.7, Mar 5, 2013
*/ */
/* preference 相关操作 */ /* preference 相关操作 */
admin.preference = { admin.preference = {
locale: "", locale: "",
editorType: "", editorType: "",
/* /*
* 初始化 * 初始化
*/ */
init: function () { init: function () {
$("#tabPreference").tabs(); $("#tabPreference").tabs();
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/preference/", url: latkeConfig.servePath + "/console/preference/",
type: "GET", type: "GET",
cache: false, cache: false,
success: function(result, textStatus){ success: function(result, textStatus){
$("#tipMsg").text(result.msg); $("#tipMsg").text(result.msg);
if (!result.sc) { if (!result.sc) {
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
var preference = result.preference; var preference = result.preference;
$("#metaKeywords").val(preference.metaKeywords), $("#metaKeywords").val(preference.metaKeywords),
$("#metaDescription").val(preference.metaDescription), $("#metaDescription").val(preference.metaDescription),
$("#blogTitle").val(preference.blogTitle), $("#blogTitle").val(preference.blogTitle),
$("#blogSubtitle").val(preference.blogSubtitle), $("#blogSubtitle").val(preference.blogSubtitle),
$("#mostCommentArticleDisplayCount").val(preference.mostCommentArticleDisplayCount); $("#mostCommentArticleDisplayCount").val(preference.mostCommentArticleDisplayCount);
$("#mostViewArticleDisplayCount").val(preference.mostViewArticleDisplayCount), $("#mostViewArticleDisplayCount").val(preference.mostViewArticleDisplayCount),
$("#recentCommentDisplayCount").val(preference.recentCommentDisplayCount); $("#recentCommentDisplayCount").val(preference.recentCommentDisplayCount);
$("#mostUsedTagDisplayCount").val(preference.mostUsedTagDisplayCount); $("#mostUsedTagDisplayCount").val(preference.mostUsedTagDisplayCount);
$("#articleListDisplayCount").val(preference.articleListDisplayCount); $("#articleListDisplayCount").val(preference.articleListDisplayCount);
$("#articleListPaginationWindowSize").val(preference.articleListPaginationWindowSize); $("#articleListPaginationWindowSize").val(preference.articleListPaginationWindowSize);
$("#localeString").val(preference.localeString); $("#localeString").val(preference.localeString);
$("#timeZoneId").val(preference.timeZoneId); $("#timeZoneId").val(preference.timeZoneId);
$("#noticeBoard").val(preference.noticeBoard); $("#noticeBoard").val(preference.noticeBoard);
$("#htmlHead").val(preference.htmlHead); $("#htmlHead").val(preference.htmlHead);
$("#externalRelevantArticlesDisplayCount").val(preference.externalRelevantArticlesDisplayCount); $("#externalRelevantArticlesDisplayCount").val(preference.externalRelevantArticlesDisplayCount);
$("#relevantArticlesDisplayCount").val(preference.relevantArticlesDisplayCount); $("#relevantArticlesDisplayCount").val(preference.relevantArticlesDisplayCount);
$("#randomArticlesDisplayCount").val(preference.randomArticlesDisplayCount); $("#randomArticlesDisplayCount").val(preference.randomArticlesDisplayCount);
$("#keyOfSolo").val(preference.keyOfSolo); $("#keyOfSolo").val(preference.keyOfSolo);
preference.enableArticleUpdateHint ? $("#enableArticleUpdateHint").attr("checked", "checked") : $("#enableArticleUpdateHint").removeAttr("checked"); preference.enableArticleUpdateHint ? $("#enableArticleUpdateHint").attr("checked", "checked") : $("#enableArticleUpdateHint").removeAttr("checked");
preference.allowVisitDraftViaPermalink ? $("#allowVisitDraftViaPermalink").attr("checked", "checked") : $("allowVisitDraftViaPermalink").removeAttr("checked"); preference.allowVisitDraftViaPermalink ? $("#allowVisitDraftViaPermalink").attr("checked", "checked") : $("allowVisitDraftViaPermalink").removeAttr("checked");
admin.preference.locale = preference.localeString; admin.preference.locale = preference.localeString;
admin.preference.editorType = preference.editorType; admin.preference.editorType = preference.editorType;
// skin // skin
$("#skinMain").data("skinDirName", preference.skinDirName); $("#skinMain").data("skinDirName", preference.skinDirName);
var skins = eval('(' + preference.skins + ')'); var skins = eval('(' + preference.skins + ')');
var skinsHTML = ""; var skinsHTML = "";
for (var i = 0; i < skins.length; i++) { for (var i = 0; i < skins.length; i++) {
var selectedClass = ""; var selectedClass = "";
if (skins[i].skinName === preference.skinName if (skins[i].skinName === preference.skinName
&& skins[i].skinDirName === preference.skinDirName ) { && skins[i].skinDirName === preference.skinDirName ) {
selectedClass += " selected"; selectedClass += " selected";
} }
skinsHTML += "<div title='" + skins[i].skinDirName skinsHTML += "<div title='" + skins[i].skinDirName
+ "' class='left skinItem" + selectedClass + "'><img class='skinPreview' src='" + "' class='left skinItem" + selectedClass + "'><img class='skinPreview' src='"
+ latkeConfig.staticServePath + "/skins/" + skins[i].skinDirName + latkeConfig.staticServePath + "/skins/" + skins[i].skinDirName
+ "/preview.png'/><div>" + skins[i].skinName + "</div></div>"; + "/preview.png'/><div>" + skins[i].skinName + "</div></div>";
} }
$("#skinMain").append(skinsHTML + "<div class='clear'></div>"); $("#skinMain").append(skinsHTML + "<div class='clear'></div>");
$(".skinItem").click(function () { $(".skinItem").click(function () {
$(".skinItem").removeClass("selected"); $(".skinItem").removeClass("selected");
$(this).addClass("selected"); $(this).addClass("selected");
$("#skinMain").data("skinDirName", this.title); $("#skinMain").data("skinDirName", this.title);
}); });
// sign // sign
var signs = eval('(' + preference.signs + ')'); var signs = eval('(' + preference.signs + ')');
for (var j = 1; j < signs.length; j++) { for (var j = 1; j < signs.length; j++) {
$("#preferenceSign" + j).val(signs[j].signHTML); $("#preferenceSign" + j).val(signs[j].signHTML);
$("#preferenceSignButton" + j).tip({ $("#preferenceSignButton" + j).tip({
content: signs[j].signHTML === "" ? Label.signIsNullLabel : signs[j].signHTML.replace(/\n/g, "").replace(/<script.*<\/script>/ig, ""), content: signs[j].signHTML === "" ? Label.signIsNullLabel : signs[j].signHTML.replace(/\n/g, "").replace(/<script.*<\/script>/ig, ""),
position: "bottom" position: "bottom"
}); });
} }
// Article list style // Article list style
$("#articleListDisplay").val(preference.articleListStyle); $("#articleListDisplay").val(preference.articleListStyle);
// Editor Type // Editor Type
$("#editorType").val(preference.editorType); $("#editorType").val(preference.editorType);
// Feed output // Feed output
$("#feedOutputMode").val(preference.feedOutputMode); $("#feedOutputMode").val(preference.feedOutputMode);
$("#feedOutputCnt").val(preference.feedOutputCnt); $("#feedOutputCnt").val(preference.feedOutputCnt);
// Commentable // Commentable
preference.commentable ? $("#commentable").attr("checked", "checked") : $("commentable").removeAttr("checked"); preference.commentable ? $("#commentable").attr("checked", "checked") : $("commentable").removeAttr("checked");
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
}, },
/* /*
* @description 参数校验 * @description 参数校验
*/ */
validate: function () { validate: function () {
if (!/^\d+$/.test($("#mostUsedTagDisplayCount").val())) { if (!/^\d+$/.test($("#mostUsedTagDisplayCount").val())) {
$("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.indexTagDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel); $("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.indexTagDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel);
$("#mostUsedTagDisplayCount").focus(); $("#mostUsedTagDisplayCount").focus();
return false; return false;
} else if (!/^\d+$/.test($("#recentCommentDisplayCount").val())) { } else if (!/^\d+$/.test($("#recentCommentDisplayCount").val())) {
$("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.indexRecentCommentDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel); $("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.indexRecentCommentDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel);
$("#recentCommentDisplayCount").focus(); $("#recentCommentDisplayCount").focus();
return false; return false;
} else if (!/^\d+$/.test($("#mostCommentArticleDisplayCount").val())) { } else if (!/^\d+$/.test($("#mostCommentArticleDisplayCount").val())) {
$("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.indexMostCommentArticleDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel); $("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.indexMostCommentArticleDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel);
$("#mostCommentArticleDisplayCount").focus(); $("#mostCommentArticleDisplayCount").focus();
return false; return false;
} else if (!/^\d+$/.test($("#mostViewArticleDisplayCount").val())) { } else if (!/^\d+$/.test($("#mostViewArticleDisplayCount").val())) {
$("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.indexMostViewArticleDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel); $("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.indexMostViewArticleDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel);
$("#mostViewArticleDisplayCount").focus(); $("#mostViewArticleDisplayCount").focus();
return false; return false;
} else if (!/^\d+$/.test($("#articleListDisplayCount").val())) { } else if (!/^\d+$/.test($("#articleListDisplayCount").val())) {
$("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.pageSizeLabel + "] " + Label.nonNegativeIntegerOnlyLabel); $("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.pageSizeLabel + "] " + Label.nonNegativeIntegerOnlyLabel);
$("#articleListDisplayCount").focus(); $("#articleListDisplayCount").focus();
return false; return false;
} else if (!/^\d+$/.test($("#articleListPaginationWindowSize").val())) { } else if (!/^\d+$/.test($("#articleListPaginationWindowSize").val())) {
$("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.windowSizeLabel + "] " + Label.nonNegativeIntegerOnlyLabel); $("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.windowSizeLabel + "] " + Label.nonNegativeIntegerOnlyLabel);
$("#articleListPaginationWindowSize").focus(); $("#articleListPaginationWindowSize").focus();
return false; return false;
} else if (!/^\d+$/.test($("#randomArticlesDisplayCount").val())) { } else if (!/^\d+$/.test($("#randomArticlesDisplayCount").val())) {
$("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.randomArticlesDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel); $("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.randomArticlesDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel);
$("#randomArticlesDisplayCount").focus(); $("#randomArticlesDisplayCount").focus();
return false; return false;
} else if (!/^\d+$/.test($("#relevantArticlesDisplayCount").val())) { } else if (!/^\d+$/.test($("#relevantArticlesDisplayCount").val())) {
$("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.relevantArticlesDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel); $("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.relevantArticlesDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel);
$("#relevantArticlesDisplayCount").focus(); $("#relevantArticlesDisplayCount").focus();
return false; return false;
} else if (!/^\d+$/.test($("#externalRelevantArticlesDisplayCount").val())) { } else if (!/^\d+$/.test($("#externalRelevantArticlesDisplayCount").val())) {
$("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.externalRelevantArticlesDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel); $("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.externalRelevantArticlesDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel);
$("#externalRelevantArticlesDisplayCount").focus(); $("#externalRelevantArticlesDisplayCount").focus();
return false; return false;
} }
return true; return true;
}, },
/* /*
* @description 更新 * @description 更新
*/ */
update: function () { update: function () {
if (!admin.preference.validate()) { if (!admin.preference.validate()) {
return; return;
} }
$("#tipMsg").text(""); $("#tipMsg").text("");
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
var signs = [{ var signs = [{
"oId": 0, "oId": 0,
"signHTML": "" "signHTML": ""
}, { }, {
"oId": 1, "oId": 1,
"signHTML": $("#preferenceSign1").val() "signHTML": $("#preferenceSign1").val()
}, { }, {
"oId": 2, "oId": 2,
"signHTML": $("#preferenceSign2").val() "signHTML": $("#preferenceSign2").val()
}, { }, {
"oId": 3, "oId": 3,
"signHTML": $("#preferenceSign3").val() "signHTML": $("#preferenceSign3").val()
}]; }];
var requestJSONObject = { var requestJSONObject = {
"preference": { "preference": {
"metaKeywords": $("#metaKeywords").val(), "metaKeywords": $("#metaKeywords").val(),
"metaDescription": $("#metaDescription").val(), "metaDescription": $("#metaDescription").val(),
"blogTitle": $("#blogTitle").val(), "blogTitle": $("#blogTitle").val(),
"blogSubtitle": $("#blogSubtitle").val(), "blogSubtitle": $("#blogSubtitle").val(),
"mostCommentArticleDisplayCount": $("#mostCommentArticleDisplayCount").val(), "mostCommentArticleDisplayCount": $("#mostCommentArticleDisplayCount").val(),
"mostViewArticleDisplayCount": $("#mostViewArticleDisplayCount").val(), "mostViewArticleDisplayCount": $("#mostViewArticleDisplayCount").val(),
"recentCommentDisplayCount": $("#recentCommentDisplayCount").val(), "recentCommentDisplayCount": $("#recentCommentDisplayCount").val(),
"mostUsedTagDisplayCount": $("#mostUsedTagDisplayCount").val(), "mostUsedTagDisplayCount": $("#mostUsedTagDisplayCount").val(),
"articleListDisplayCount": $("#articleListDisplayCount").val(), "articleListDisplayCount": $("#articleListDisplayCount").val(),
"articleListPaginationWindowSize": $("#articleListPaginationWindowSize").val(), "articleListPaginationWindowSize": $("#articleListPaginationWindowSize").val(),
"skinDirName": $("#skinMain").data("skinDirName"), "skinDirName": $("#skinMain").data("skinDirName"),
"localeString": $("#localeString").val(), "localeString": $("#localeString").val(),
"timeZoneId": $("#timeZoneId").val(), "timeZoneId": $("#timeZoneId").val(),
"noticeBoard": $("#noticeBoard").val(), "noticeBoard": $("#noticeBoard").val(),
"htmlHead": $("#htmlHead").val(), "htmlHead": $("#htmlHead").val(),
"externalRelevantArticlesDisplayCount": $("#externalRelevantArticlesDisplayCount").val(), "externalRelevantArticlesDisplayCount": $("#externalRelevantArticlesDisplayCount").val(),
"relevantArticlesDisplayCount": $("#relevantArticlesDisplayCount").val(), "relevantArticlesDisplayCount": $("#relevantArticlesDisplayCount").val(),
"randomArticlesDisplayCount": $("#randomArticlesDisplayCount").val(), "randomArticlesDisplayCount": $("#randomArticlesDisplayCount").val(),
"enableArticleUpdateHint": $("#enableArticleUpdateHint").prop("checked"), "enableArticleUpdateHint": $("#enableArticleUpdateHint").prop("checked"),
"signs": signs, "signs": signs,
"keyOfSolo": $("#keyOfSolo").val(), "keyOfSolo": $("#keyOfSolo").val(),
"allowVisitDraftViaPermalink": $("#allowVisitDraftViaPermalink").prop("checked"), "allowVisitDraftViaPermalink": $("#allowVisitDraftViaPermalink").prop("checked"),
"articleListStyle": $("#articleListDisplay").val(), "articleListStyle": $("#articleListDisplay").val(),
"editorType": $("#editorType").val(), "editorType": $("#editorType").val(),
"feedOutputMode": $("#feedOutputMode").val(), "feedOutputMode": $("#feedOutputMode").val(),
"feedOutputCnt": $("#feedOutputCnt").val(), "feedOutputCnt": $("#feedOutputCnt").val(),
"commentable": $("#commentable").prop("checked") "commentable": $("#commentable").prop("checked")
} }
}; };
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/preference/", url: latkeConfig.servePath + "/console/preference/",
type: "PUT", type: "PUT",
cache: false, cache: false,
data: JSON.stringify(requestJSONObject), data: JSON.stringify(requestJSONObject),
success: function(result, textStatus){ success: function(result, textStatus){
$("#tipMsg").text(result.msg); $("#tipMsg").text(result.msg);
if (!result.sc) { if (!result.sc) {
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
if ($("#localeString").val() !== admin.preference.locale || if ($("#localeString").val() !== admin.preference.locale ||
$("#editorType").val() !== admin.preference.editorType) { $("#editorType").val() !== admin.preference.editorType) {
window.location.reload(); window.location.reload();
} }
// update article and preferences signs // update article and preferences signs
for (var i = 1; i < signs.length; i++) { for (var i = 1; i < signs.length; i++) {
if ($("#articleSign" + signs[i].oId).length === 1) { if ($("#articleSign" + signs[i].oId).length === 1) {
$("#articleSign" + signs[i].oId).tip("option", "content", $("#articleSign" + signs[i].oId).tip("option", "content",
signs[i].signHTML === "" ? Label.signIsNullLabel : signs[i].signHTML.replace(/\n/g, "").replace(/<script.*<\/script>/ig, "")); signs[i].signHTML === "" ? Label.signIsNullLabel : signs[i].signHTML.replace(/\n/g, "").replace(/<script.*<\/script>/ig, ""));
} }
$("#preferenceSignButton" + signs[i].oId).tip("option", "content", $("#preferenceSignButton" + signs[i].oId).tip("option", "content",
signs[i].signHTML === "" ? Label.signIsNullLabel : signs[i].signHTML.replace(/\n/g, "").replace(/<script.*<\/script>/ig, "")); signs[i].signHTML === "" ? Label.signIsNullLabel : signs[i].signHTML.replace(/\n/g, "").replace(/<script.*<\/script>/ig, ""));
} }
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
} }
}; };
/* /*
* 注册到 admin 进行管理 * 注册到 admin 进行管理
*/ */
admin.register["preference"] = { admin.register["preference"] = {
"obj": admin.preference, "obj": admin.preference,
"init": admin.preference.init, "init": admin.preference.init,
"refresh": function () { "refresh": function () {
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
} }
/* /*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team * Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
* *
...@@ -3143,362 +3143,362 @@ admin.register["plugin-list"] = { ...@@ -3143,362 +3143,362 @@ admin.register["plugin-list"] = {
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
} }
/* /*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team * Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/** /**
* user list for admin * user list for admin
* *
* @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.1.6, Apr 2, 2013 * @version 1.0.1.6, Apr 2, 2013
*/ */
/* user-list 相关操作 */ /* user-list 相关操作 */
admin.userList = { admin.userList = {
tablePagination: new TablePaginate("user"), tablePagination: new TablePaginate("user"),
pageInfo: { pageInfo: {
currentCount: 1, currentCount: 1,
pageCount: 1, pageCount: 1,
currentPage: 1 currentPage: 1
}, },
userInfo: { userInfo: {
'oId': "", 'oId': "",
"userRole": "" "userRole": ""
}, },
/* /*
* 初始化 table, pagination * 初始化 table, pagination
*/ */
init: function(page) { init: function(page) {
this.tablePagination.buildTable([{ this.tablePagination.buildTable([{
style: "padding-left: 12px;", style: "padding-left: 12px;",
text: Label.commentNameLabel, text: Label.commentNameLabel,
index: "userName", index: "userName",
width: 230 width: 230
}, { }, {
style: "padding-left: 12px;", style: "padding-left: 12px;",
text: Label.commentEmailLabel, text: Label.commentEmailLabel,
index: "userEmail", index: "userEmail",
minWidth: 180 minWidth: 180
}, { }, {
style: "padding-left: 12px;", style: "padding-left: 12px;",
text: Label.roleLabel, text: Label.roleLabel,
index: "isAdmin", index: "isAdmin",
width: 120 width: 120
}]); }]);
this.tablePagination.initPagination(); this.tablePagination.initPagination();
this.getList(page); this.getList(page);
$("#userUpdate").dialog({ $("#userUpdate").dialog({
width: 700, width: 700,
height: 230, height: 230,
"modal": true, "modal": true,
"hideFooter": true "hideFooter": true
}); });
}, },
/* /*
* 根据当前页码获取列表 * 根据当前页码获取列表
* @pagNum 当前页码 * @pagNum 当前页码
*/ */
getList: function(pageNum) { getList: function(pageNum) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
this.pageInfo.currentPage = pageNum; this.pageInfo.currentPage = pageNum;
var that = this; var that = this;
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/users/" + pageNum + "/" + Label.PAGE_SIZE + "/" + Label.WINDOW_SIZE, url: latkeConfig.servePath + "/console/users/" + pageNum + "/" + Label.PAGE_SIZE + "/" + Label.WINDOW_SIZE,
type: "GET", type: "GET",
cache: false, cache: false,
success: function(result, textStatus) { success: function(result, textStatus) {
$("#tipMsg").text(result.msg); $("#tipMsg").text(result.msg);
if (!result.sc) { if (!result.sc) {
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
var users = result.users; var users = result.users;
var userData = []; var userData = [];
admin.userList.pageInfo.currentCount = users.length; admin.userList.pageInfo.currentCount = users.length;
admin.userList.pageInfo.pageCount = result.pagination.paginationPageCount; admin.userList.pageInfo.pageCount = result.pagination.paginationPageCount;
if (users.length < 1) { if (users.length < 1) {
$("#tipMsg").text("No user " + Label.reportIssueLabel); $("#tipMsg").text("No user " + Label.reportIssueLabel);
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
for (var i = 0; i < users.length; i++) { for (var i = 0; i < users.length; i++) {
userData[i] = {}; userData[i] = {};
userData[i].userName = users[i].userName; userData[i].userName = users[i].userName;
userData[i].userEmail = users[i].userEmail; userData[i].userEmail = users[i].userEmail;
if ("adminRole" === users[i].userRole) { if ("adminRole" === users[i].userRole) {
userData[i].isAdmin = "&nbsp;" + Label.administratorLabel; userData[i].isAdmin = "&nbsp;" + Label.administratorLabel;
userData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.userList.get('" + userData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.userList.get('" +
users[i].oId + "', '" + users[i].userRole + "')\">" + Label.updateLabel + "</a>"; users[i].oId + "', '" + users[i].userRole + "')\">" + Label.updateLabel + "</a>";
} else { } else {
userData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.userList.get('" + userData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.userList.get('" +
users[i].oId + "', '" + users[i].userRole + "')\">" + Label.updateLabel + "</a>\ users[i].oId + "', '" + users[i].userRole + "')\">" + Label.updateLabel + "</a>\
<a href='javascript:void(0)' onclick=\"admin.userList.del('" + users[i].oId + "', '" + users[i].userName + "')\">" + Label.removeLabel + "</a>" + <a href='javascript:void(0)' onclick=\"admin.userList.del('" + users[i].oId + "', '" + users[i].userName + "')\">" + Label.removeLabel + "</a>" +
"<a href='javascript:void(0)' onclick=\"admin.userList.changeRole('" + users[i].oId + "')\">" + Label.changeRoleLabel + "</a>"; "<a href='javascript:void(0)' onclick=\"admin.userList.changeRole('" + users[i].oId + "')\">" + Label.changeRoleLabel + "</a>";
if ("defaultRole" === users[i].userRole) { if ("defaultRole" === users[i].userRole) {
userData[i].isAdmin = Label.commonUserLabel; userData[i].isAdmin = Label.commonUserLabel;
} }
else { else {
userData[i].isAdmin = Label.visitorUserLabel; userData[i].isAdmin = Label.visitorUserLabel;
} }
} }
that.tablePagination.updateTablePagination(userData, pageNum, result.pagination); that.tablePagination.updateTablePagination(userData, pageNum, result.pagination);
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
} }
}); });
}, },
/* /*
* 添加用户 * 添加用户
*/ */
add: function() { add: function() {
if (this.validate()) { if (this.validate()) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text(""); $("#tipMsg").text("");
var requestJSONObject = { var requestJSONObject = {
"userName": $("#userName").val(), "userName": $("#userName").val(),
"userEmail": $("#userEmail").val(), "userEmail": $("#userEmail").val(),
"userURL": $("#userURL").val(), "userURL": $("#userURL").val(),
"userPassword": $("#userPassword").val() "userPassword": $("#userPassword").val()
}; };
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/user/", url: latkeConfig.servePath + "/console/user/",
type: "POST", type: "POST",
cache: false, cache: false,
data: JSON.stringify(requestJSONObject), data: JSON.stringify(requestJSONObject),
success: function(result, textStatus) { success: function(result, textStatus) {
$("#tipMsg").text(result.msg); $("#tipMsg").text(result.msg);
if (!result.sc) { if (!result.sc) {
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
$("#userName").val(""); $("#userName").val("");
$("#userEmail").val(""); $("#userEmail").val("");
$("#userURL").val(""); $("#userURL").val("");
$("#userPassword").val(""); $("#userPassword").val("");
if (admin.userList.pageInfo.currentCount === Label.PAGE_SIZE && if (admin.userList.pageInfo.currentCount === Label.PAGE_SIZE &&
admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) { admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) {
admin.userList.pageInfo.pageCount++; admin.userList.pageInfo.pageCount++;
} }
var hashList = window.location.hash.split("/"); var hashList = window.location.hash.split("/");
if (admin.userList.pageInfo.pageCount !== parseInt(hashList[hashList.length - 1])) { if (admin.userList.pageInfo.pageCount !== parseInt(hashList[hashList.length - 1])) {
admin.setHashByPage(admin.userList.pageInfo.pageCount); admin.setHashByPage(admin.userList.pageInfo.pageCount);
} }
admin.userList.getList(admin.userList.pageInfo.pageCount); admin.userList.getList(admin.userList.pageInfo.pageCount);
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
} }
}, },
/* /*
* 获取用户 * 获取用户
* @id 用户 id * @id 用户 id
*/ */
get: function(id, userRole) { get: function(id, userRole) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#userUpdate").dialog("open"); $("#userUpdate").dialog("open");
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/user/" + id, url: latkeConfig.servePath + "/console/user/" + id,
type: "GET", type: "GET",
cache: false, cache: false,
success: function(result, textStatus) { success: function(result, textStatus) {
$("#tipMsg").text(result.msg); $("#tipMsg").text(result.msg);
if (!result.sc) { if (!result.sc) {
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
var $userEmailUpdate = $("#userEmailUpdate"); var $userEmailUpdate = $("#userEmailUpdate");
$("#userNameUpdate").val(result.user.userName).data("userInfo", { $("#userNameUpdate").val(result.user.userName).data("userInfo", {
'oId': id, 'oId': id,
"userRole": userRole "userRole": userRole
}); });
$userEmailUpdate.val(result.user.userEmail); $userEmailUpdate.val(result.user.userEmail);
if ("adminRole" === userRole) { if ("adminRole" === userRole) {
$userEmailUpdate.attr("disabled", "disabled"); $userEmailUpdate.attr("disabled", "disabled");
} else { } else {
$userEmailUpdate.removeAttr("disabled"); $userEmailUpdate.removeAttr("disabled");
} }
$("#userURLUpdate").val(result.user.userURL); $("#userURLUpdate").val(result.user.userURL);
$("#userPasswordUpdate").val(result.user.userPassword); $("#userPasswordUpdate").val(result.user.userPassword);
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
}, },
/* /*
* 更新用户 * 更新用户
*/ */
update: function() { update: function() {
if (this.validate("Update")) { if (this.validate("Update")) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text(""); $("#tipMsg").text("");
var userInfo = $("#userNameUpdate").data("userInfo"); var userInfo = $("#userNameUpdate").data("userInfo");
var requestJSONObject = { var requestJSONObject = {
"userName": $("#userNameUpdate").val(), "userName": $("#userNameUpdate").val(),
"oId": userInfo.oId, "oId": userInfo.oId,
"userEmail": $("#userEmailUpdate").val(), "userEmail": $("#userEmailUpdate").val(),
"userURL": $("#userURLUpdate").val(), "userURL": $("#userURLUpdate").val(),
"userRole": userInfo.userRole, "userRole": userInfo.userRole,
"userPassword": $("#userPasswordUpdate").val() "userPassword": $("#userPasswordUpdate").val()
}; };
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/user/", url: latkeConfig.servePath + "/console/user/",
type: "PUT", type: "PUT",
cache: false, cache: false,
data: JSON.stringify(requestJSONObject), data: JSON.stringify(requestJSONObject),
success: function(result, textStatus) { success: function(result, textStatus) {
$("#userUpdate").dialog("close"); $("#userUpdate").dialog("close");
$("#tipMsg").text(result.msg); $("#tipMsg").text(result.msg);
if (!result.sc) { if (!result.sc) {
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
admin.userList.getList(admin.userList.pageInfo.currentPage); admin.userList.getList(admin.userList.pageInfo.currentPage);
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
} }
}, },
/* /*
* 删除用户 * 删除用户
* @id 用户 id * @id 用户 id
* @userName 用户名称 * @userName 用户名称
*/ */
del: function(id, userName) { del: function(id, userName) {
var isDelete = confirm(Label.confirmRemoveLabel + Label.userLabel + '"' + userName + '"?'); var isDelete = confirm(Label.confirmRemoveLabel + Label.userLabel + '"' + userName + '"?');
if (isDelete) { if (isDelete) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text(""); $("#tipMsg").text("");
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/user/" + id, url: latkeConfig.servePath + "/console/user/" + id,
type: "DELETE", type: "DELETE",
cache: false, cache: false,
success: function(result, textStatus) { success: function(result, textStatus) {
$("#tipMsg").text(result.msg); $("#tipMsg").text(result.msg);
if (!result.sc) { if (!result.sc) {
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
var pageNum = admin.userList.pageInfo.currentPage; var pageNum = admin.userList.pageInfo.currentPage;
if (admin.userList.pageInfo.currentCount === 1 && admin.userList.pageInfo.pageCount !== 1 && if (admin.userList.pageInfo.currentCount === 1 && admin.userList.pageInfo.pageCount !== 1 &&
admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) { admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) {
admin.userList.pageInfo.pageCount--; admin.userList.pageInfo.pageCount--;
pageNum = admin.userList.pageInfo.pageCount; pageNum = admin.userList.pageInfo.pageCount;
} }
var hashList = window.location.hash.split("/"); var hashList = window.location.hash.split("/");
if (pageNum !== parseInt(hashList[hashList.length - 1])) { if (pageNum !== parseInt(hashList[hashList.length - 1])) {
admin.setHashByPage(pageNum); admin.setHashByPage(pageNum);
} }
admin.userList.getList(pageNum); admin.userList.getList(pageNum);
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
} }
}, },
/** /**
* 修改角色 * 修改角色
* @param id * @param id
*/ */
changeRole: function(id) { changeRole: function(id) {
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/changeRole/" + id, url: latkeConfig.servePath + "/console/changeRole/" + id,
type: "GET", type: "GET",
cache: false, cache: false,
success: function(result, textStatus) { success: function(result, textStatus) {
$("#tipMsg").text(result.msg); $("#tipMsg").text(result.msg);
if (!result.sc) { if (!result.sc) {
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
var pageNum = admin.userList.pageInfo.currentPage; var pageNum = admin.userList.pageInfo.currentPage;
if (admin.userList.pageInfo.currentCount === 1 && admin.userList.pageInfo.pageCount !== 1 && if (admin.userList.pageInfo.currentCount === 1 && admin.userList.pageInfo.pageCount !== 1 &&
admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) { admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) {
admin.userList.pageInfo.pageCount--; admin.userList.pageInfo.pageCount--;
pageNum = admin.userList.pageInfo.pageCount; pageNum = admin.userList.pageInfo.pageCount;
} }
var hashList = window.location.hash.split("/"); var hashList = window.location.hash.split("/");
if (pageNum !== parseInt(hashList[hashList.length - 1])) { if (pageNum !== parseInt(hashList[hashList.length - 1])) {
admin.setHashByPage(pageNum); admin.setHashByPage(pageNum);
} }
admin.userList.getList(pageNum); admin.userList.getList(pageNum);
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
}, },
/* /*
* 验证字段 * 验证字段
* @status 更新或者添加时进行验证 * @status 更新或者添加时进行验证
*/ */
validate: function(status) { validate: function(status) {
if (!status) { if (!status) {
status = ""; status = "";
} }
var userName = $("#userName" + status).val().replace(/(^\s*)|(\s*$)/g, ""); var userName = $("#userName" + status).val().replace(/(^\s*)|(\s*$)/g, "");
if (2 > userName.length || userName.length > 20) { if (2 > userName.length || userName.length > 20) {
$("#tipMsg").text(Label.nameTooLongLabel); $("#tipMsg").text(Label.nameTooLongLabel);
$("#userName" + status).focus(); $("#userName" + status).focus();
} else if ($("#userEmail" + status).val().replace(/\s/g, "") === "") { } else if ($("#userEmail" + status).val().replace(/\s/g, "") === "") {
$("#tipMsg").text(Label.mailCannotEmptyLabel); $("#tipMsg").text(Label.mailCannotEmptyLabel);
$("#userEmail" + status).focus(); $("#userEmail" + status).focus();
} else if (!/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test($("#userEmail" + status).val())) { } else if (!/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test($("#userEmail" + status).val())) {
$("#tipMsg").text(Label.mailInvalidLabel); $("#tipMsg").text(Label.mailInvalidLabel);
$("#userEmail" + status).focus(); $("#userEmail" + status).focus();
} else if ($("#userPassword" + status).val().replace(/\s/g, "") === "") { } else if ($("#userPassword" + status).val().replace(/\s/g, "") === "") {
$("#tipMsg").text(Label.passwordEmptyLabel); $("#tipMsg").text(Label.passwordEmptyLabel);
$("#userPassword" + status).focus(); $("#userPassword" + status).focus();
} else { } else {
return true; return true;
} }
return false; return false;
} }
}; };
/* /*
* 注册到 admin 进行管理 * 注册到 admin 进行管理
*/ */
admin.register["user-list"] = { admin.register["user-list"] = {
"obj": admin.userList, "obj": admin.userList,
"init": admin.userList.init, "init": admin.userList.init,
"refresh": function() { "refresh": function() {
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}/* }/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team * Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
* *
......
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