Commit 6059316e authored by Vanessa's avatar Vanessa

about #135

parent a10545dc
...@@ -18,29 +18,28 @@ ...@@ -18,29 +18,28 @@
* *
* @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.0.3, Jan 7, 2012 * @version 1.0.0.4, May 28, 2013
*/ */
/* about 相关操作 */ /* about 相关操作 */
admin.about = { admin.about = {
init: function () { init: function() {
$.ajax({ $.ajax({
url: "http://rhythm.b3log.org/version/solo/latest/" + Label.version, url: "http://rhythm.b3log.org/version/solo/latest/" + Label.version,
type: "GET", type: "GET",
cache: false, cache: false,
dataType:"jsonp", dataType: "jsonp",
error: function() {
// alert("Error loading articles from Rhythm");
},
success: function(data, textStatus) { success: function(data, textStatus) {
var version = data.soloVersion; var version = data.soloVersion;
if (version === Label.version) { if (version === Label.version) {
$("#aboutLatest").text(Label.upToDateLabel); $("#aboutLatest").text(Label.upToDateLabel);
} else { } else {
$("#aboutLatest").html(Label.outOfDateLabel + $("#aboutLatest").html(Label.outOfDateLabel +
"<a href='" + data.soloDownload + "'>" + version + "</a>"); "<a href='" + data.soloDownload + "'>" + version + "</a>");
} }
$("#loadMsg").text(""); },
complete: function(XHR, TS) {
admin.clearTip();
} }
}); });
} }
...@@ -52,7 +51,7 @@ admin.about = { ...@@ -52,7 +51,7 @@ admin.about = {
admin.register["about"] = { admin.register["about"] = {
"obj": admin.about, "obj": admin.about,
"init": admin.about.init, "init": admin.about.init,
"refresh": function () { "refresh": function() {
$("#loadMsg").text(""); admin.clearTip();
} }
} };
\ No newline at end of file \ No newline at end of file
...@@ -17,34 +17,39 @@ ...@@ -17,34 +17,39 @@
* index for admin * index for admin
* *
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a> * @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.2.1, Jan 29, 2013 * @version 1.0.2.2, May 28, 2013
*/ */
var Admin = function() {
var Admin = function () {
this.register = {}; this.register = {};
// 工具栏下的工具 // 工具栏下的工具
this.tools = ['#page-list', '#file-list', '#link-list', '#preference', this.tools = ['#page-list', '#file-list', '#link-list', '#preference',
'#user-list', '#plugin-list', '#others']; '#user-list', '#plugin-list', '#others'];
// 多用户时,一般用户不能使用的功能 // 多用户时,一般用户不能使用的功能
this.adTools = ['link-list', 'preference', 'file-list', 'page-list', this.adTools = ['link-list', 'preference', 'file-list', 'page-list',
'user-list', 'plugin-list', 'others']; 'user-list', 'plugin-list', 'others'];
}; };
$.extend(Admin.prototype, { $.extend(Admin.prototype, {
/* /*
* 登出 * 登出
*/ */
logout: function () { logout: function() {
window.location.href = latkeConfig.servePath + "/logout?goto=" + latkeConfig.servePath; window.location.href = latkeConfig.servePath + "/logout?goto=" + latkeConfig.servePath;
}, },
/**
* @description 清除提示
*/
clearTip: function() {
$("#tipMsg").text("");
$("#loadMsg").text("");
},
/* /*
* 根据当前页数设置 hash * 根据当前页数设置 hash
* @currentPage {string} 当前页 * @currentPage {string} 当前页
*/ */
setHashByPage: function (currentPage) { setHashByPage: function(currentPage) {
var hash = window.location.hash, var hash = window.location.hash,
hashList = hash.split("/"); hashList = hash.split("/");
if (/^\d*$/.test(hashList[hashList.length - 1])) { if (/^\d*$/.test(hashList[hashList.length - 1])) {
hashList[hashList.length - 1] = currentPage; hashList[hashList.length - 1] = currentPage;
} else { } else {
...@@ -52,25 +57,23 @@ $.extend(Admin.prototype, { ...@@ -52,25 +57,23 @@ $.extend(Admin.prototype, {
} }
window.location.hash = hashList.join("/"); window.location.hash = hashList.join("/");
}, },
/* /*
* 设置某个 tab 被选择 * 设置某个 tab 被选择
* @id tab id * @id tab id
*/ */
selectTab: function (id) { selectTab: function(id) {
window.location.hash = "#" + id; window.location.hash = "#" + id;
}, },
/* /*
* 根据当前 hash 解析出当前页数及 hash 数组。 * 根据当前 hash 解析出当前页数及 hash 数组。
*/ */
analyseHash: function () { analyseHash: function() {
var hash = window.location.hash; var hash = window.location.hash;
var tag = hash.substr(1, hash.length - 1); var tag = hash.substr(1, hash.length - 1);
var tagList = tag.split("/"); var tagList = tag.split("/");
var tags = {}; var tags = {};
tags.page = 1, tags.page = 1,
tags.hashList = []; tags.hashList = [];
for (var i = 0; i < tagList.length; i++) { for (var i = 0; i < tagList.length; i++) {
if (i === tagList.length - 1 && (/^\d+$/.test(tagList[i]))) { if (i === tagList.length - 1 && (/^\d+$/.test(tagList[i]))) {
tags.page = tagList[i]; tags.page = tagList[i];
...@@ -80,29 +83,29 @@ $.extend(Admin.prototype, { ...@@ -80,29 +83,29 @@ $.extend(Admin.prototype, {
} }
return tags; return tags;
}, },
/* /*
* 根据当前 hash 设置当前 tab * 根据当前 hash 设置当前 tab
*/ */
setCurByHash: function () { setCurByHash: function() {
$("#tipMsg").text("");
var tags = admin.analyseHash(); var tags = admin.analyseHash();
var tab = tags.hashList[1], var tab = tags.hashList[1],
subTab = tags.hashList[2]; subTab = tags.hashList[2];
if (tags.hashList.length === 1) { if (tags.hashList.length === 1) {
tab = tags.hashList[0]; tab = tags.hashList[0];
} }
if (tab === "") { if (tab === "") {
return; return;
} }
// 离开编辑器时进行提示 // 离开编辑器时进行提示
try { try {
// 除更新、发布、取消发布文章,编辑器中无内容外,离开编辑器需进行提示。 // 除更新、发布、取消发布文章,编辑器中无内容外,离开编辑器需进行提示。
if (tab !== "article" && admin.article.isConfirm && if (tab !== "article" && admin.article.isConfirm &&
admin.editors.articleEditor.getContent().replace(/\s/g, '') !== "" admin.editors.articleEditor.getContent().replace(/\s/g, '') !== ""
&& admin.article.content !== admin.editors.articleEditor.getContent()) { && admin.article.content !== admin.editors.articleEditor.getContent()) {
if (!confirm(Label.editorLeaveLabel)) { if (!confirm(Label.editorLeaveLabel)) {
window.location.hash = "#article/article"; window.location.hash = "#article/article";
return; return;
...@@ -110,16 +113,16 @@ $.extend(Admin.prototype, { ...@@ -110,16 +113,16 @@ $.extend(Admin.prototype, {
} }
// 不离开编辑器,hash 需变为 "#article/article",此时不需要做任何处理。 // 不离开编辑器,hash 需变为 "#article/article",此时不需要做任何处理。
if (tab === "article" && admin.article.isConfirm && if (tab === "article" && admin.article.isConfirm &&
admin.editors.articleEditor.getContent().replace(/\s/g, '') !== "" admin.editors.articleEditor.getContent().replace(/\s/g, '') !== ""
&& admin.article.content !== admin.editors.articleEditor.getContent()) { && admin.article.content !== admin.editors.articleEditor.getContent()) {
return; return;
} }
} catch (e) { } catch (e) {
var $articleContent = $('#articleContent'); var $articleContent = $('#articleContent');
if ($articleContent.length > 0) { if ($articleContent.length > 0) {
if (tab !== "article" && admin.article.isConfirm && if (tab !== "article" && admin.article.isConfirm &&
$articleContent.val().replace(/\s/g, '') !== "" $articleContent.val().replace(/\s/g, '') !== ""
&& admin.article.content !== $articleContent.val()) { && admin.article.content !== $articleContent.val()) {
if (!confirm(Label.editorLeaveLabel)) { if (!confirm(Label.editorLeaveLabel)) {
window.location.hash = "#article/article"; window.location.hash = "#article/article";
return; return;
...@@ -127,26 +130,26 @@ $.extend(Admin.prototype, { ...@@ -127,26 +130,26 @@ $.extend(Admin.prototype, {
} }
// 不离开编辑器,hash 需变为 "#article/article",此时不需要做任何处理。 // 不离开编辑器,hash 需变为 "#article/article",此时不需要做任何处理。
if (tab === "article" && admin.article.isConfirm && if (tab === "article" && admin.article.isConfirm &&
$articleContent.val().replace(/\s/g, '') !== "" $articleContent.val().replace(/\s/g, '') !== ""
&& admin.article.content !== $articleContent.val()) { && admin.article.content !== $articleContent.val()) {
return; return;
} }
} }
} }
// clear article // clear article
if (tab !== "article" && admin.editors.articleEditor.setContent) { if (tab !== "article" && admin.editors.articleEditor.setContent) {
admin.article.clear(); admin.article.clear();
} }
admin.article.isConfirm = true; admin.article.isConfirm = true;
$("#tabs").tabs("setCurrent", tab); $("#tabs").tabs("setCurrent", tab);
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
if ($("#tabsPanel_" + tab).length === 1) { if ($("#tabsPanel_" + tab).length === 1) {
if ($("#tabsPanel_" + tab).html().replace(/\s/g, "") === "") { if ($("#tabsPanel_" + tab).html().replace(/\s/g, "") === "") {
// 还未加载 HTML // 还未加载 HTML
$("#tabsPanel_" + tab).load("admin-" + tab + ".do", function () { $("#tabsPanel_" + tab).load("admin-" + tab + ".do", function() {
// 页面加载完后,回调初始函数 // 页面加载完后,回调初始函数
if (tab === "article" && admin.article.status.id) { if (tab === "article" && admin.article.status.id) {
// 当文章页面编辑器未初始化时,调用更新文章需先初始化编辑器 // 当文章页面编辑器未初始化时,调用更新文章需先初始化编辑器
...@@ -154,13 +157,13 @@ $.extend(Admin.prototype, { ...@@ -154,13 +157,13 @@ $.extend(Admin.prototype, {
} else { } else {
admin.register[tab].init.call(admin.register[tab].obj, tags.page); admin.register[tab].init.call(admin.register[tab].obj, tags.page);
} }
// 页面包含子 tab,需根据 hash 定位到相应的 tab // 页面包含子 tab,需根据 hash 定位到相应的 tab
if (subTab) { if (subTab) {
$("#tab" + tab.substring(0, 1).toUpperCase() + tab.substring(1)). $("#tab" + tab.substring(0, 1).toUpperCase() + tab.substring(1)).
tabs("setCurrent", subTab); tabs("setCurrent", subTab);
} }
// 根据 hash 调用现有的插件函数 // 根据 hash 调用现有的插件函数
admin.plugin.setCurByHash(tags); admin.plugin.setCurByHash(tags);
}); });
...@@ -168,57 +171,55 @@ $.extend(Admin.prototype, { ...@@ -168,57 +171,55 @@ $.extend(Admin.prototype, {
if (tab === "article" && admin.article.status.id) { if (tab === "article" && admin.article.status.id) {
admin.article.getAndSet(); admin.article.getAndSet();
} }
// 已加载过 HTML,只需调用刷新函数 // 已加载过 HTML,只需调用刷新函数
if (admin.register[tab] && admin.register[tab].refresh) { if (admin.register[tab] && admin.register[tab].refresh) {
admin.register[tab].refresh.call(admin.register[tab].obj, tags.page); admin.register[tab].refresh.call(admin.register[tab].obj, tags.page);
} }
// 页面包含子 tab,需根据 hash 定位到相应的 tab // 页面包含子 tab,需根据 hash 定位到相应的 tab
if (subTab) { if (subTab) {
$("#tab" + tab.substring(0, 1).toUpperCase() + tab.substring(1)). $("#tab" + tab.substring(0, 1).toUpperCase() + tab.substring(1)).
tabs("setCurrent", subTab); tabs("setCurrent", subTab);
} }
// 根据 hash 调用现有的插件函数 // 根据 hash 调用现有的插件函数
admin.plugin.setCurByHash(tags); admin.plugin.setCurByHash(tags);
} }
} else { } else {
$("#tipMsg").text("Error: No tab! " + Label.reportIssueLabel); $("#tipMsg").text("Error: No tab! " + Label.reportIssueLabel);
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}, },
/* /*
* 初始化整个后台 * 初始化整个后台
*/ */
init: function () { init: function() {
//window.onerror = Util.error; //window.onerror = Util.error;
Util.killIE(); Util.killIE();
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
// 构建 tabs // 构建 tabs
$("#tabs").tabs(); $("#tabs").tabs();
// tipMsg // tipMsg
setInterval(function () { setInterval(function() {
if($("#tipMsg").text() !== "") { if ($("#tipMsg").text() !== "") {
setTimeout(function () { setTimeout(function() {
$("#tipMsg").text(""); $("#tipMsg").text("");
}, 7000); }, 7000);
} }
}, 6000); }, 6000);
$("#loadMsg").text(""); $("#loadMsg").text("");
}, },
/* /*
* @description tools and article collapse * @description tools and article collapse
* @param {bom} it 触发事件对象 * @param {bom} it 触发事件对象
*/ */
collapseNav: function (it) { collapseNav: function(it) {
var subNav = $(it).next(); var subNav = $(it).next();
subNav.slideToggle("normal", function () { subNav.slideToggle("normal", function() {
if (this.style.display !== "none") { if (this.style.display !== "none") {
$(it).find(".ico-arrow-down")[0].className = "ico-arrow-up"; $(it).find(".ico-arrow-down")[0].className = "ico-arrow-up";
} else { } else {
...@@ -226,11 +227,10 @@ $.extend(Admin.prototype, { ...@@ -226,11 +227,10 @@ $.extend(Admin.prototype, {
} }
}); });
}, },
/* /*
* 后台及当前页面所需插件初始化完后,对权限进行控制及当前页面属于 tools 时,tools 选项需展开。 * 后台及当前页面所需插件初始化完后,对权限进行控制及当前页面属于 tools 时,tools 选项需展开。
*/ */
inited: function () { inited: function() {
// Removes functions with the current user role // Removes functions with the current user role
if (Label.userRole !== "adminRole") { if (Label.userRole !== "adminRole") {
for (var i = 0; i < this.adTools.length; i++) { for (var i = 0; i < this.adTools.length; i++) {
......
...@@ -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.1, Feb 23, 2013 * @version 1.0.3.2, May 28, 2013
*/ */
admin.article = { admin.article = {
// 当发文章,取消发布,更新文章时设置为 false。不需在离开编辑器时进行提示。 // 当发文章,取消发布,更新文章时设置为 false。不需在离开编辑器时进行提示。
...@@ -42,7 +42,7 @@ admin.article = { ...@@ -42,7 +42,7 @@ admin.article = {
getAndSet: function () { getAndSet: function () {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/article/" + admin.article.status.id, url: latkeConfig.servePath + "/console/article/" + admin.article.status.id,
type: "GET", type: "GET",
...@@ -515,7 +515,7 @@ admin.article = { ...@@ -515,7 +515,7 @@ admin.article = {
admin.article.clear(); admin.article.clear();
} }
} }
$("#tipMsg").text("");
$("#loadMsg").text(""); $("#loadMsg").text("");
}, },
...@@ -547,5 +547,6 @@ admin.register.article = { ...@@ -547,5 +547,6 @@ admin.register.article = {
"init": admin.article.init, "init": admin.article.init,
"refresh": function () { "refresh": function () {
$("#loadMsg").text(""); $("#loadMsg").text("");
$("#tipMsg").text("");
} }
} };
\ No newline at end of file \ No newline at end of file
...@@ -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.1.4, Feb 23, 2013 * @version 1.0.1.5, May 28, 2013
*/ */
/* article-list 相关操作 */ /* article-list 相关操作 */
...@@ -67,7 +67,6 @@ admin.articleList = { ...@@ -67,7 +67,6 @@ admin.articleList = {
getList: function (pageNum) { getList: function (pageNum) {
var that = this; var that = this;
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/articles/status/published/" + pageNum + "/" + Label.PAGE_SIZE + "/" + Label.WINDOW_SIZE, url: latkeConfig.servePath + "/console/articles/status/published/" + pageNum + "/" + Label.PAGE_SIZE + "/" + Label.WINDOW_SIZE,
type: "GET", type: "GET",
......
...@@ -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.0.8, Feb 23, 2013 * @version 1.0.0.9, May 28, 2013
*/ */
admin.comment = { admin.comment = {
...@@ -40,6 +40,7 @@ admin.comment = { ...@@ -40,6 +40,7 @@ admin.comment = {
*/ */
getList: function (onId, fromId) { getList: function (onId, fromId) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
$("#" + fromId + "Comments").html(""); $("#" + fromId + "Comments").html("");
var from = "article"; var from = "article";
......
...@@ -17,34 +17,39 @@ ...@@ -17,34 +17,39 @@
* index for admin * index for admin
* *
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a> * @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.2.1, Jan 29, 2013 * @version 1.0.2.2, May 28, 2013
*/ */
var Admin = function() {
var Admin = function () {
this.register = {}; this.register = {};
// 工具栏下的工具 // 工具栏下的工具
this.tools = ['#page-list', '#file-list', '#link-list', '#preference', this.tools = ['#page-list', '#file-list', '#link-list', '#preference',
'#user-list', '#plugin-list', '#others']; '#user-list', '#plugin-list', '#others'];
// 多用户时,一般用户不能使用的功能 // 多用户时,一般用户不能使用的功能
this.adTools = ['link-list', 'preference', 'file-list', 'page-list', this.adTools = ['link-list', 'preference', 'file-list', 'page-list',
'user-list', 'plugin-list', 'others']; 'user-list', 'plugin-list', 'others'];
}; };
$.extend(Admin.prototype, { $.extend(Admin.prototype, {
/* /*
* 登出 * 登出
*/ */
logout: function () { logout: function() {
window.location.href = latkeConfig.servePath + "/logout?goto=" + latkeConfig.servePath; window.location.href = latkeConfig.servePath + "/logout?goto=" + latkeConfig.servePath;
}, },
/**
* @description 清除提示
*/
clearTip: function() {
$("#tipMsg").text("");
$("#loadMsg").text("");
},
/* /*
* 根据当前页数设置 hash * 根据当前页数设置 hash
* @currentPage {string} 当前页 * @currentPage {string} 当前页
*/ */
setHashByPage: function (currentPage) { setHashByPage: function(currentPage) {
var hash = window.location.hash, var hash = window.location.hash,
hashList = hash.split("/"); hashList = hash.split("/");
if (/^\d*$/.test(hashList[hashList.length - 1])) { if (/^\d*$/.test(hashList[hashList.length - 1])) {
hashList[hashList.length - 1] = currentPage; hashList[hashList.length - 1] = currentPage;
} else { } else {
...@@ -52,25 +57,23 @@ $.extend(Admin.prototype, { ...@@ -52,25 +57,23 @@ $.extend(Admin.prototype, {
} }
window.location.hash = hashList.join("/"); window.location.hash = hashList.join("/");
}, },
/* /*
* 设置某个 tab 被选择 * 设置某个 tab 被选择
* @id tab id * @id tab id
*/ */
selectTab: function (id) { selectTab: function(id) {
window.location.hash = "#" + id; window.location.hash = "#" + id;
}, },
/* /*
* 根据当前 hash 解析出当前页数及 hash 数组。 * 根据当前 hash 解析出当前页数及 hash 数组。
*/ */
analyseHash: function () { analyseHash: function() {
var hash = window.location.hash; var hash = window.location.hash;
var tag = hash.substr(1, hash.length - 1); var tag = hash.substr(1, hash.length - 1);
var tagList = tag.split("/"); var tagList = tag.split("/");
var tags = {}; var tags = {};
tags.page = 1, tags.page = 1,
tags.hashList = []; tags.hashList = [];
for (var i = 0; i < tagList.length; i++) { for (var i = 0; i < tagList.length; i++) {
if (i === tagList.length - 1 && (/^\d+$/.test(tagList[i]))) { if (i === tagList.length - 1 && (/^\d+$/.test(tagList[i]))) {
tags.page = tagList[i]; tags.page = tagList[i];
...@@ -80,29 +83,29 @@ $.extend(Admin.prototype, { ...@@ -80,29 +83,29 @@ $.extend(Admin.prototype, {
} }
return tags; return tags;
}, },
/* /*
* 根据当前 hash 设置当前 tab * 根据当前 hash 设置当前 tab
*/ */
setCurByHash: function () { setCurByHash: function() {
$("#tipMsg").text("");
var tags = admin.analyseHash(); var tags = admin.analyseHash();
var tab = tags.hashList[1], var tab = tags.hashList[1],
subTab = tags.hashList[2]; subTab = tags.hashList[2];
if (tags.hashList.length === 1) { if (tags.hashList.length === 1) {
tab = tags.hashList[0]; tab = tags.hashList[0];
} }
if (tab === "") { if (tab === "") {
return; return;
} }
// 离开编辑器时进行提示 // 离开编辑器时进行提示
try { try {
// 除更新、发布、取消发布文章,编辑器中无内容外,离开编辑器需进行提示。 // 除更新、发布、取消发布文章,编辑器中无内容外,离开编辑器需进行提示。
if (tab !== "article" && admin.article.isConfirm && if (tab !== "article" && admin.article.isConfirm &&
admin.editors.articleEditor.getContent().replace(/\s/g, '') !== "" admin.editors.articleEditor.getContent().replace(/\s/g, '') !== ""
&& admin.article.content !== admin.editors.articleEditor.getContent()) { && admin.article.content !== admin.editors.articleEditor.getContent()) {
if (!confirm(Label.editorLeaveLabel)) { if (!confirm(Label.editorLeaveLabel)) {
window.location.hash = "#article/article"; window.location.hash = "#article/article";
return; return;
...@@ -110,16 +113,16 @@ $.extend(Admin.prototype, { ...@@ -110,16 +113,16 @@ $.extend(Admin.prototype, {
} }
// 不离开编辑器,hash 需变为 "#article/article",此时不需要做任何处理。 // 不离开编辑器,hash 需变为 "#article/article",此时不需要做任何处理。
if (tab === "article" && admin.article.isConfirm && if (tab === "article" && admin.article.isConfirm &&
admin.editors.articleEditor.getContent().replace(/\s/g, '') !== "" admin.editors.articleEditor.getContent().replace(/\s/g, '') !== ""
&& admin.article.content !== admin.editors.articleEditor.getContent()) { && admin.article.content !== admin.editors.articleEditor.getContent()) {
return; return;
} }
} catch (e) { } catch (e) {
var $articleContent = $('#articleContent'); var $articleContent = $('#articleContent');
if ($articleContent.length > 0) { if ($articleContent.length > 0) {
if (tab !== "article" && admin.article.isConfirm && if (tab !== "article" && admin.article.isConfirm &&
$articleContent.val().replace(/\s/g, '') !== "" $articleContent.val().replace(/\s/g, '') !== ""
&& admin.article.content !== $articleContent.val()) { && admin.article.content !== $articleContent.val()) {
if (!confirm(Label.editorLeaveLabel)) { if (!confirm(Label.editorLeaveLabel)) {
window.location.hash = "#article/article"; window.location.hash = "#article/article";
return; return;
...@@ -127,26 +130,26 @@ $.extend(Admin.prototype, { ...@@ -127,26 +130,26 @@ $.extend(Admin.prototype, {
} }
// 不离开编辑器,hash 需变为 "#article/article",此时不需要做任何处理。 // 不离开编辑器,hash 需变为 "#article/article",此时不需要做任何处理。
if (tab === "article" && admin.article.isConfirm && if (tab === "article" && admin.article.isConfirm &&
$articleContent.val().replace(/\s/g, '') !== "" $articleContent.val().replace(/\s/g, '') !== ""
&& admin.article.content !== $articleContent.val()) { && admin.article.content !== $articleContent.val()) {
return; return;
} }
} }
} }
// clear article // clear article
if (tab !== "article" && admin.editors.articleEditor.setContent) { if (tab !== "article" && admin.editors.articleEditor.setContent) {
admin.article.clear(); admin.article.clear();
} }
admin.article.isConfirm = true; admin.article.isConfirm = true;
$("#tabs").tabs("setCurrent", tab); $("#tabs").tabs("setCurrent", tab);
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
if ($("#tabsPanel_" + tab).length === 1) { if ($("#tabsPanel_" + tab).length === 1) {
if ($("#tabsPanel_" + tab).html().replace(/\s/g, "") === "") { if ($("#tabsPanel_" + tab).html().replace(/\s/g, "") === "") {
// 还未加载 HTML // 还未加载 HTML
$("#tabsPanel_" + tab).load("admin-" + tab + ".do", function () { $("#tabsPanel_" + tab).load("admin-" + tab + ".do", function() {
// 页面加载完后,回调初始函数 // 页面加载完后,回调初始函数
if (tab === "article" && admin.article.status.id) { if (tab === "article" && admin.article.status.id) {
// 当文章页面编辑器未初始化时,调用更新文章需先初始化编辑器 // 当文章页面编辑器未初始化时,调用更新文章需先初始化编辑器
...@@ -154,13 +157,13 @@ $.extend(Admin.prototype, { ...@@ -154,13 +157,13 @@ $.extend(Admin.prototype, {
} else { } else {
admin.register[tab].init.call(admin.register[tab].obj, tags.page); admin.register[tab].init.call(admin.register[tab].obj, tags.page);
} }
// 页面包含子 tab,需根据 hash 定位到相应的 tab // 页面包含子 tab,需根据 hash 定位到相应的 tab
if (subTab) { if (subTab) {
$("#tab" + tab.substring(0, 1).toUpperCase() + tab.substring(1)). $("#tab" + tab.substring(0, 1).toUpperCase() + tab.substring(1)).
tabs("setCurrent", subTab); tabs("setCurrent", subTab);
} }
// 根据 hash 调用现有的插件函数 // 根据 hash 调用现有的插件函数
admin.plugin.setCurByHash(tags); admin.plugin.setCurByHash(tags);
}); });
...@@ -168,57 +171,55 @@ $.extend(Admin.prototype, { ...@@ -168,57 +171,55 @@ $.extend(Admin.prototype, {
if (tab === "article" && admin.article.status.id) { if (tab === "article" && admin.article.status.id) {
admin.article.getAndSet(); admin.article.getAndSet();
} }
// 已加载过 HTML,只需调用刷新函数 // 已加载过 HTML,只需调用刷新函数
if (admin.register[tab] && admin.register[tab].refresh) { if (admin.register[tab] && admin.register[tab].refresh) {
admin.register[tab].refresh.call(admin.register[tab].obj, tags.page); admin.register[tab].refresh.call(admin.register[tab].obj, tags.page);
} }
// 页面包含子 tab,需根据 hash 定位到相应的 tab // 页面包含子 tab,需根据 hash 定位到相应的 tab
if (subTab) { if (subTab) {
$("#tab" + tab.substring(0, 1).toUpperCase() + tab.substring(1)). $("#tab" + tab.substring(0, 1).toUpperCase() + tab.substring(1)).
tabs("setCurrent", subTab); tabs("setCurrent", subTab);
} }
// 根据 hash 调用现有的插件函数 // 根据 hash 调用现有的插件函数
admin.plugin.setCurByHash(tags); admin.plugin.setCurByHash(tags);
} }
} else { } else {
$("#tipMsg").text("Error: No tab! " + Label.reportIssueLabel); $("#tipMsg").text("Error: No tab! " + Label.reportIssueLabel);
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}, },
/* /*
* 初始化整个后台 * 初始化整个后台
*/ */
init: function () { init: function() {
//window.onerror = Util.error; //window.onerror = Util.error;
Util.killIE(); Util.killIE();
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
// 构建 tabs // 构建 tabs
$("#tabs").tabs(); $("#tabs").tabs();
// tipMsg // tipMsg
setInterval(function () { setInterval(function() {
if($("#tipMsg").text() !== "") { if ($("#tipMsg").text() !== "") {
setTimeout(function () { setTimeout(function() {
$("#tipMsg").text(""); $("#tipMsg").text("");
}, 7000); }, 7000);
} }
}, 6000); }, 6000);
$("#loadMsg").text(""); $("#loadMsg").text("");
}, },
/* /*
* @description tools and article collapse * @description tools and article collapse
* @param {bom} it 触发事件对象 * @param {bom} it 触发事件对象
*/ */
collapseNav: function (it) { collapseNav: function(it) {
var subNav = $(it).next(); var subNav = $(it).next();
subNav.slideToggle("normal", function () { subNav.slideToggle("normal", function() {
if (this.style.display !== "none") { if (this.style.display !== "none") {
$(it).find(".ico-arrow-down")[0].className = "ico-arrow-up"; $(it).find(".ico-arrow-down")[0].className = "ico-arrow-up";
} else { } else {
...@@ -226,11 +227,10 @@ $.extend(Admin.prototype, { ...@@ -226,11 +227,10 @@ $.extend(Admin.prototype, {
} }
}); });
}, },
/* /*
* 后台及当前页面所需插件初始化完后,对权限进行控制及当前页面属于 tools 时,tools 选项需展开。 * 后台及当前页面所需插件初始化完后,对权限进行控制及当前页面属于 tools 时,tools 选项需展开。
*/ */
inited: function () { inited: function() {
// Removes functions with the current user role // Removes functions with the current user role
if (Label.userRole !== "adminRole") { if (Label.userRole !== "adminRole") {
for (var i = 0; i < this.adTools.length; i++) { for (var i = 0; i < this.adTools.length; i++) {
...@@ -867,7 +867,7 @@ $.extend(TablePaginate.prototype, { ...@@ -867,7 +867,7 @@ $.extend(TablePaginate.prototype, {
* *
* @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.1, Feb 23, 2013 * @version 1.0.3.2, May 28, 2013
*/ */
admin.article = { admin.article = {
// 当发文章,取消发布,更新文章时设置为 false。不需在离开编辑器时进行提示。 // 当发文章,取消发布,更新文章时设置为 false。不需在离开编辑器时进行提示。
...@@ -891,7 +891,7 @@ admin.article = { ...@@ -891,7 +891,7 @@ admin.article = {
getAndSet: function () { getAndSet: function () {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/article/" + admin.article.status.id, url: latkeConfig.servePath + "/console/article/" + admin.article.status.id,
type: "GET", type: "GET",
...@@ -1364,7 +1364,7 @@ admin.article = { ...@@ -1364,7 +1364,7 @@ admin.article = {
admin.article.clear(); admin.article.clear();
} }
} }
$("#tipMsg").text("");
$("#loadMsg").text(""); $("#loadMsg").text("");
}, },
...@@ -1396,8 +1396,9 @@ admin.register.article = { ...@@ -1396,8 +1396,9 @@ admin.register.article = {
"init": admin.article.init, "init": admin.article.init,
"refresh": function () { "refresh": function () {
$("#loadMsg").text(""); $("#loadMsg").text("");
$("#tipMsg").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");
...@@ -1417,7 +1418,7 @@ admin.register.article = { ...@@ -1417,7 +1418,7 @@ admin.register.article = {
* *
* @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.0.8, Feb 23, 2013 * @version 1.0.0.9, May 28, 2013
*/ */
admin.comment = { admin.comment = {
...@@ -1439,6 +1440,7 @@ admin.comment = { ...@@ -1439,6 +1440,7 @@ admin.comment = {
*/ */
getList: function (onId, fromId) { getList: function (onId, fromId) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
$("#" + fromId + "Comments").html(""); $("#" + fromId + "Comments").html("");
var from = "article"; var from = "article";
...@@ -1546,7 +1548,7 @@ admin.comment = { ...@@ -1546,7 +1548,7 @@ admin.comment = {
* *
* @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.4, Feb 23, 2013 * @version 1.0.1.5, May 28, 2013
*/ */
/* article-list 相关操作 */ /* article-list 相关操作 */
...@@ -1595,7 +1597,6 @@ admin.articleList = { ...@@ -1595,7 +1597,6 @@ admin.articleList = {
getList: function (pageNum) { getList: function (pageNum) {
var that = this; var that = this;
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/articles/status/published/" + pageNum + "/" + Label.PAGE_SIZE + "/" + Label.WINDOW_SIZE, url: latkeConfig.servePath + "/console/articles/status/published/" + pageNum + "/" + Label.PAGE_SIZE + "/" + Label.WINDOW_SIZE,
type: "GET", type: "GET",
...@@ -1809,7 +1810,7 @@ admin.register["draft-list"] = { ...@@ -1809,7 +1810,7 @@ admin.register["draft-list"] = {
* *
* @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.2.3, Feb 23, 2013 * @version 1.0.2.4, May 28, 2013
*/ */
/* page-list 相关操作 */ /* page-list 相关操作 */
...@@ -1905,6 +1906,7 @@ admin.pageList = { ...@@ -1905,6 +1906,7 @@ admin.pageList = {
*/ */
getList: function (pageNum) { getList: function (pageNum) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
var that = this; var that = this;
$.ajax({ $.ajax({
...@@ -2247,7 +2249,7 @@ admin.register["page-list"] = { ...@@ -2247,7 +2249,7 @@ admin.register["page-list"] = {
* *
* @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.0.7, May 3, 2012 * @version 1.0.0.8, May 28, 2013
*/ */
/* oterhs 相关操作 */ /* oterhs 相关操作 */
...@@ -2351,9 +2353,9 @@ admin.register.others = { ...@@ -2351,9 +2353,9 @@ admin.register.others = {
"obj": admin.others, "obj": admin.others,
"init":admin.others.init, "init":admin.others.init,
"refresh": function () { "refresh": function () {
$("#loadMsg").text(""); admin.clearTip();
} }
} };
/* /*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team * Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
* *
...@@ -2704,268 +2706,268 @@ admin.register["link-list"] = { ...@@ -2704,268 +2706,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.8, May 28, 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(""); admin.clearTip();
} }
} };
/* /*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team * Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
* *
...@@ -2986,12 +2988,12 @@ admin.register["preference"] = { ...@@ -2986,12 +2988,12 @@ admin.register["preference"] = {
* *
* @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.3, May 3, 2012 * @version 1.0.1.4, May 28, 2013
*/ */
/* plugin-list 相关操作 */ /* plugin-list 相关操作 */
admin.pluginList = { admin.pluginList = {
tablePagination: new TablePaginate("plugin"), tablePagination: new TablePaginate("plugin"),
pageInfo: { pageInfo: {
currentCount: 1, currentCount: 1,
pageCount: 1, pageCount: 1,
...@@ -3000,29 +3002,29 @@ admin.pluginList = { ...@@ -3000,29 +3002,29 @@ admin.pluginList = {
/* /*
* 初始化 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.pluginNameLabel, text: Label.pluginNameLabel,
index: "name", index: "name",
width: 230 width: 230
}, { }, {
style: "padding-left: 12px;", style: "padding-left: 12px;",
text: Label.statusLabel, text: Label.statusLabel,
index: "status", index: "status",
minWidth: 180 minWidth: 180
}, { }, {
style: "padding-left: 12px;", style: "padding-left: 12px;",
text: Label.authorLabel, text: Label.authorLabel,
index: "author", index: "author",
width: 200 width: 200
}, { }, {
style: "padding-left: 12px;", style: "padding-left: 12px;",
text: Label.versionLabel, text: Label.versionLabel,
index: "version", index: "version",
width: 120 width: 120
}]); }]);
this.tablePagination.initPagination(); this.tablePagination.initPagination();
$("#pluginSetting").dialog({ $("#pluginSetting").dialog({
width: 700, width: 700,
...@@ -3032,31 +3034,31 @@ admin.pluginList = { ...@@ -3032,31 +3034,31 @@ admin.pluginList = {
}); });
this.getList(page); this.getList(page);
}, },
/* /*
* 根据当前页码获取列表 * 根据当前页码获取列表
* @pagNum 当前页码 * @pagNum 当前页码
*/ */
getList: function (pageNum) { getList: function(pageNum) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
var that = this; var that = this;
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/plugins/" + pageNum + "/" + Label.PAGE_SIZE + "/" + Label.WINDOW_SIZE, url: latkeConfig.servePath + "/console/plugins/" + 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;
} }
admin.pluginList.pageInfo.currentPage = pageNum; admin.pluginList.pageInfo.currentPage = pageNum;
var datas = result.plugins; var datas = result.plugins;
for (var i = 0; i < datas.length; i++) { for (var i = 0; i < datas.length; i++) {
datas[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.pluginList.changeStatus('" + datas[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.pluginList.changeStatus('" +
datas[i].oId + "', '" + datas[i].status + "')\">"; datas[i].oId + "', '" + datas[i].status + "')\">";
if (datas[i].status === "ENABLED") { if (datas[i].status === "ENABLED") {
datas[i].status = Label.enabledLabel; datas[i].status = Label.enabledLabel;
datas[i].expendRow += Label.disableLabel; datas[i].expendRow += Label.disableLabel;
...@@ -3065,67 +3067,66 @@ admin.pluginList = { ...@@ -3065,67 +3067,66 @@ admin.pluginList = {
datas[i].expendRow += Label.enableLabel; datas[i].expendRow += Label.enableLabel;
} }
datas[i].expendRow += "</a> "; datas[i].expendRow += "</a> ";
if(datas[i].setting!="{}"){ if (datas[i].setting != "{}") {
datas[i].expendRow +="<a href='javascript:void(0)' onclick=\"admin.pluginList.toSetting('"+datas[i].oId+"')\"> "+Label.settingLabel+" </a> "; datas[i].expendRow += "<a href='javascript:void(0)' onclick=\"admin.pluginList.toSetting('" + datas[i].oId + "')\"> " + Label.settingLabel + " </a> ";
} }
} }
that.tablePagination.updateTablePagination(result.plugins, pageNum, result.pagination); that.tablePagination.updateTablePagination(result.plugins, pageNum, result.pagination);
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
}, },
toSetting: function(pluginId) {
toSetting:function(pluginId){
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
var requestJSONObject = { var requestJSONObject = {
"oId": pluginId "oId": pluginId
}; };
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/plugin/toSetting", url: latkeConfig.servePath + "/console/plugin/toSetting",
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);
$("#pluginSetting").html(result); $("#pluginSetting").html(result);
$("#pluginSetting").dialog("open"); $("#pluginSetting").dialog("open");
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
}, },
changeStatus: function(pluginId, status) {
changeStatus: function (pluginId, status) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
if (status === "ENABLED") { if (status === "ENABLED") {
status = "DISABLED"; status = "DISABLED";
} else { } else {
status = "ENABLED"; status = "ENABLED";
} }
var requestJSONObject = { var requestJSONObject = {
"oId": pluginId, "oId": pluginId,
"status": status "status": status
}; };
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/plugin/status/", url: latkeConfig.servePath + "/console/plugin/status/",
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;
} }
$("#loadMsg").text(""); $("#loadMsg").text("");
window.location.reload(); window.location.reload();
} }
...@@ -3134,371 +3135,374 @@ admin.pluginList = { ...@@ -3134,371 +3135,374 @@ admin.pluginList = {
}; };
/* /*
* 注册到 admin 进行管理 * 注册到 admin 进行管理
*/ */
admin.register["plugin-list"] = { admin.register["plugin-list"] = {
"obj": admin.pluginList, "obj": admin.pluginList,
"init": admin.pluginList.init, "init": admin.pluginList.init,
"refresh": function () { "refresh": function() {
$("#loadMsg").text(""); admin.claerTip();
}
};
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* user list for admin
*
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.1.7, May 28, 2013
*/
/* user-list 相关操作 */
admin.userList = {
tablePagination: new TablePaginate("user"),
pageInfo: {
currentCount: 1,
pageCount: 1,
currentPage: 1
},
userInfo: {
'oId': "",
"userRole": ""
},
/*
* 初始化 table, pagination
*/
init: function(page) {
this.tablePagination.buildTable([{
style: "padding-left: 12px;",
text: Label.commentNameLabel,
index: "userName",
width: 230
}, {
style: "padding-left: 12px;",
text: Label.commentEmailLabel,
index: "userEmail",
minWidth: 180
}, {
style: "padding-left: 12px;",
text: Label.roleLabel,
index: "isAdmin",
width: 120
}]);
this.tablePagination.initPagination();
this.getList(page);
$("#userUpdate").dialog({
width: 700,
height: 230,
"modal": true,
"hideFooter": true
});
},
/*
* 根据当前页码获取列表
* @pagNum 当前页码
*/
getList: function(pageNum) {
$("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
this.pageInfo.currentPage = pageNum;
var that = this;
$.ajax({
url: latkeConfig.servePath + "/console/users/" + pageNum + "/" + Label.PAGE_SIZE + "/" + Label.WINDOW_SIZE,
type: "GET",
cache: false,
success: function(result, textStatus) {
$("#tipMsg").text(result.msg);
if (!result.sc) {
$("#loadMsg").text("");
return;
}
var users = result.users;
var userData = [];
admin.userList.pageInfo.currentCount = users.length;
admin.userList.pageInfo.pageCount = result.pagination.paginationPageCount;
if (users.length < 1) {
$("#tipMsg").text("No user " + Label.reportIssueLabel);
$("#loadMsg").text("");
return;
}
for (var i = 0; i < users.length; i++) {
userData[i] = {};
userData[i].userName = users[i].userName;
userData[i].userEmail = users[i].userEmail;
if ("adminRole" === users[i].userRole) {
userData[i].isAdmin = "&nbsp;" + Label.administratorLabel;
userData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.userList.get('" +
users[i].oId + "', '" + users[i].userRole + "')\">" + Label.updateLabel + "</a>";
} else {
userData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.userList.get('" +
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.changeRole('" + users[i].oId + "')\">" + Label.changeRoleLabel + "</a>";
if ("defaultRole" === users[i].userRole) {
userData[i].isAdmin = Label.commonUserLabel;
}
else {
userData[i].isAdmin = Label.visitorUserLabel;
}
}
that.tablePagination.updateTablePagination(userData, pageNum, result.pagination);
$("#loadMsg").text("");
}
}
});
},
/*
* 添加用户
*/
add: function() {
if (this.validate()) {
$("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
var requestJSONObject = {
"userName": $("#userName").val(),
"userEmail": $("#userEmail").val(),
"userURL": $("#userURL").val(),
"userPassword": $("#userPassword").val()
};
$.ajax({
url: latkeConfig.servePath + "/console/user/",
type: "POST",
cache: false,
data: JSON.stringify(requestJSONObject),
success: function(result, textStatus) {
$("#tipMsg").text(result.msg);
if (!result.sc) {
$("#loadMsg").text("");
return;
}
$("#userName").val("");
$("#userEmail").val("");
$("#userURL").val("");
$("#userPassword").val("");
if (admin.userList.pageInfo.currentCount === Label.PAGE_SIZE &&
admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) {
admin.userList.pageInfo.pageCount++;
}
var hashList = window.location.hash.split("/");
if (admin.userList.pageInfo.pageCount !== parseInt(hashList[hashList.length - 1])) {
admin.setHashByPage(admin.userList.pageInfo.pageCount);
}
admin.userList.getList(admin.userList.pageInfo.pageCount);
$("#loadMsg").text("");
}
});
}
},
/*
* 获取用户
* @id 用户 id
*/
get: function(id, userRole) {
$("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
$("#userUpdate").dialog("open");
$.ajax({
url: latkeConfig.servePath + "/console/user/" + id,
type: "GET",
cache: false,
success: function(result, textStatus) {
$("#tipMsg").text(result.msg);
if (!result.sc) {
$("#loadMsg").text("");
return;
}
var $userEmailUpdate = $("#userEmailUpdate");
$("#userNameUpdate").val(result.user.userName).data("userInfo", {
'oId': id,
"userRole": userRole
});
$userEmailUpdate.val(result.user.userEmail);
if ("adminRole" === userRole) {
$userEmailUpdate.attr("disabled", "disabled");
} else {
$userEmailUpdate.removeAttr("disabled");
}
$("#userURLUpdate").val(result.user.userURL);
$("#userPasswordUpdate").val(result.user.userPassword);
$("#loadMsg").text("");
}
});
},
/*
* 更新用户
*/
update: function() {
if (this.validate("Update")) {
$("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
var userInfo = $("#userNameUpdate").data("userInfo");
var requestJSONObject = {
"userName": $("#userNameUpdate").val(),
"oId": userInfo.oId,
"userEmail": $("#userEmailUpdate").val(),
"userURL": $("#userURLUpdate").val(),
"userRole": userInfo.userRole,
"userPassword": $("#userPasswordUpdate").val()
};
$.ajax({
url: latkeConfig.servePath + "/console/user/",
type: "PUT",
cache: false,
data: JSON.stringify(requestJSONObject),
success: function(result, textStatus) {
$("#userUpdate").dialog("close");
$("#tipMsg").text(result.msg);
if (!result.sc) {
$("#loadMsg").text("");
return;
}
admin.userList.getList(admin.userList.pageInfo.currentPage);
$("#loadMsg").text("");
}
});
}
},
/*
* 删除用户
* @id 用户 id
* @userName 用户名称
*/
del: function(id, userName) {
var isDelete = confirm(Label.confirmRemoveLabel + Label.userLabel + '"' + userName + '"?');
if (isDelete) {
$("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
$.ajax({
url: latkeConfig.servePath + "/console/user/" + id,
type: "DELETE",
cache: false,
success: function(result, textStatus) {
$("#tipMsg").text(result.msg);
if (!result.sc) {
$("#loadMsg").text("");
return;
}
var pageNum = admin.userList.pageInfo.currentPage;
if (admin.userList.pageInfo.currentCount === 1 && admin.userList.pageInfo.pageCount !== 1 &&
admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) {
admin.userList.pageInfo.pageCount--;
pageNum = admin.userList.pageInfo.pageCount;
}
var hashList = window.location.hash.split("/");
if (pageNum !== parseInt(hashList[hashList.length - 1])) {
admin.setHashByPage(pageNum);
}
admin.userList.getList(pageNum);
$("#loadMsg").text("");
}
});
}
},
/**
* 修改角色
* @param id
*/
changeRole: function(id) {
$("#tipMsg").text("");
$.ajax({
url: latkeConfig.servePath + "/console/changeRole/" + id,
type: "GET",
cache: false,
success: function(result, textStatus) {
$("#tipMsg").text(result.msg);
if (!result.sc) {
$("#loadMsg").text("");
return;
}
var pageNum = admin.userList.pageInfo.currentPage;
if (admin.userList.pageInfo.currentCount === 1 && admin.userList.pageInfo.pageCount !== 1 &&
admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) {
admin.userList.pageInfo.pageCount--;
pageNum = admin.userList.pageInfo.pageCount;
}
var hashList = window.location.hash.split("/");
if (pageNum !== parseInt(hashList[hashList.length - 1])) {
admin.setHashByPage(pageNum);
}
admin.userList.getList(pageNum);
$("#loadMsg").text("");
}
});
},
/*
* 验证字段
* @status 更新或者添加时进行验证
*/
validate: function(status) {
if (!status) {
status = "";
}
var userName = $("#userName" + status).val().replace(/(^\s*)|(\s*$)/g, "");
if (2 > userName.length || userName.length > 20) {
$("#tipMsg").text(Label.nameTooLongLabel);
$("#userName" + status).focus();
} else if ($("#userEmail" + status).val().replace(/\s/g, "") === "") {
$("#tipMsg").text(Label.mailCannotEmptyLabel);
$("#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())) {
$("#tipMsg").text(Label.mailInvalidLabel);
$("#userEmail" + status).focus();
} else if ($("#userPassword" + status).val().replace(/\s/g, "") === "") {
$("#tipMsg").text(Label.passwordEmptyLabel);
$("#userPassword" + status).focus();
} else {
return true;
}
return false;
}
};
/*
* 注册到 admin 进行管理
*/
admin.register["user-list"] = {
"obj": admin.userList,
"init": admin.userList.init,
"refresh": function() {
admin.clearTip();
} }
}
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* user list for admin
*
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.1.6, Apr 2, 2013
*/
/* user-list 相关操作 */
admin.userList = {
tablePagination: new TablePaginate("user"),
pageInfo: {
currentCount: 1,
pageCount: 1,
currentPage: 1
},
userInfo: {
'oId': "",
"userRole": ""
},
/*
* 初始化 table, pagination
*/
init: function(page) {
this.tablePagination.buildTable([{
style: "padding-left: 12px;",
text: Label.commentNameLabel,
index: "userName",
width: 230
}, {
style: "padding-left: 12px;",
text: Label.commentEmailLabel,
index: "userEmail",
minWidth: 180
}, {
style: "padding-left: 12px;",
text: Label.roleLabel,
index: "isAdmin",
width: 120
}]);
this.tablePagination.initPagination();
this.getList(page);
$("#userUpdate").dialog({
width: 700,
height: 230,
"modal": true,
"hideFooter": true
});
},
/*
* 根据当前页码获取列表
* @pagNum 当前页码
*/
getList: function(pageNum) {
$("#loadMsg").text(Label.loadingLabel);
this.pageInfo.currentPage = pageNum;
var that = this;
$.ajax({
url: latkeConfig.servePath + "/console/users/" + pageNum + "/" + Label.PAGE_SIZE + "/" + Label.WINDOW_SIZE,
type: "GET",
cache: false,
success: function(result, textStatus) {
$("#tipMsg").text(result.msg);
if (!result.sc) {
$("#loadMsg").text("");
return;
}
var users = result.users;
var userData = [];
admin.userList.pageInfo.currentCount = users.length;
admin.userList.pageInfo.pageCount = result.pagination.paginationPageCount;
if (users.length < 1) {
$("#tipMsg").text("No user " + Label.reportIssueLabel);
$("#loadMsg").text("");
return;
}
for (var i = 0; i < users.length; i++) {
userData[i] = {};
userData[i].userName = users[i].userName;
userData[i].userEmail = users[i].userEmail;
if ("adminRole" === users[i].userRole) {
userData[i].isAdmin = "&nbsp;" + Label.administratorLabel;
userData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.userList.get('" +
users[i].oId + "', '" + users[i].userRole + "')\">" + Label.updateLabel + "</a>";
} else {
userData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.userList.get('" +
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.changeRole('" + users[i].oId + "')\">" + Label.changeRoleLabel + "</a>";
if ("defaultRole" === users[i].userRole) {
userData[i].isAdmin = Label.commonUserLabel;
}
else {
userData[i].isAdmin = Label.visitorUserLabel;
}
}
that.tablePagination.updateTablePagination(userData, pageNum, result.pagination);
$("#loadMsg").text("");
}
}
});
},
/*
* 添加用户
*/
add: function() {
if (this.validate()) {
$("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
var requestJSONObject = {
"userName": $("#userName").val(),
"userEmail": $("#userEmail").val(),
"userURL": $("#userURL").val(),
"userPassword": $("#userPassword").val()
};
$.ajax({
url: latkeConfig.servePath + "/console/user/",
type: "POST",
cache: false,
data: JSON.stringify(requestJSONObject),
success: function(result, textStatus) {
$("#tipMsg").text(result.msg);
if (!result.sc) {
$("#loadMsg").text("");
return;
}
$("#userName").val("");
$("#userEmail").val("");
$("#userURL").val("");
$("#userPassword").val("");
if (admin.userList.pageInfo.currentCount === Label.PAGE_SIZE &&
admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) {
admin.userList.pageInfo.pageCount++;
}
var hashList = window.location.hash.split("/");
if (admin.userList.pageInfo.pageCount !== parseInt(hashList[hashList.length - 1])) {
admin.setHashByPage(admin.userList.pageInfo.pageCount);
}
admin.userList.getList(admin.userList.pageInfo.pageCount);
$("#loadMsg").text("");
}
});
}
},
/*
* 获取用户
* @id 用户 id
*/
get: function(id, userRole) {
$("#loadMsg").text(Label.loadingLabel);
$("#userUpdate").dialog("open");
$.ajax({
url: latkeConfig.servePath + "/console/user/" + id,
type: "GET",
cache: false,
success: function(result, textStatus) {
$("#tipMsg").text(result.msg);
if (!result.sc) {
$("#loadMsg").text("");
return;
}
var $userEmailUpdate = $("#userEmailUpdate");
$("#userNameUpdate").val(result.user.userName).data("userInfo", {
'oId': id,
"userRole": userRole
});
$userEmailUpdate.val(result.user.userEmail);
if ("adminRole" === userRole) {
$userEmailUpdate.attr("disabled", "disabled");
} else {
$userEmailUpdate.removeAttr("disabled");
}
$("#userURLUpdate").val(result.user.userURL);
$("#userPasswordUpdate").val(result.user.userPassword);
$("#loadMsg").text("");
}
});
},
/*
* 更新用户
*/
update: function() {
if (this.validate("Update")) {
$("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
var userInfo = $("#userNameUpdate").data("userInfo");
var requestJSONObject = {
"userName": $("#userNameUpdate").val(),
"oId": userInfo.oId,
"userEmail": $("#userEmailUpdate").val(),
"userURL": $("#userURLUpdate").val(),
"userRole": userInfo.userRole,
"userPassword": $("#userPasswordUpdate").val()
};
$.ajax({
url: latkeConfig.servePath + "/console/user/",
type: "PUT",
cache: false,
data: JSON.stringify(requestJSONObject),
success: function(result, textStatus) {
$("#userUpdate").dialog("close");
$("#tipMsg").text(result.msg);
if (!result.sc) {
$("#loadMsg").text("");
return;
}
admin.userList.getList(admin.userList.pageInfo.currentPage);
$("#loadMsg").text("");
}
});
}
},
/*
* 删除用户
* @id 用户 id
* @userName 用户名称
*/
del: function(id, userName) {
var isDelete = confirm(Label.confirmRemoveLabel + Label.userLabel + '"' + userName + '"?');
if (isDelete) {
$("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
$.ajax({
url: latkeConfig.servePath + "/console/user/" + id,
type: "DELETE",
cache: false,
success: function(result, textStatus) {
$("#tipMsg").text(result.msg);
if (!result.sc) {
$("#loadMsg").text("");
return;
}
var pageNum = admin.userList.pageInfo.currentPage;
if (admin.userList.pageInfo.currentCount === 1 && admin.userList.pageInfo.pageCount !== 1 &&
admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) {
admin.userList.pageInfo.pageCount--;
pageNum = admin.userList.pageInfo.pageCount;
}
var hashList = window.location.hash.split("/");
if (pageNum !== parseInt(hashList[hashList.length - 1])) {
admin.setHashByPage(pageNum);
}
admin.userList.getList(pageNum);
$("#loadMsg").text("");
}
});
}
},
/**
* 修改角色
* @param id
*/
changeRole: function(id) {
$.ajax({
url: latkeConfig.servePath + "/console/changeRole/" + id,
type: "GET",
cache: false,
success: function(result, textStatus) {
$("#tipMsg").text(result.msg);
if (!result.sc) {
$("#loadMsg").text("");
return;
}
var pageNum = admin.userList.pageInfo.currentPage;
if (admin.userList.pageInfo.currentCount === 1 && admin.userList.pageInfo.pageCount !== 1 &&
admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) {
admin.userList.pageInfo.pageCount--;
pageNum = admin.userList.pageInfo.pageCount;
}
var hashList = window.location.hash.split("/");
if (pageNum !== parseInt(hashList[hashList.length - 1])) {
admin.setHashByPage(pageNum);
}
admin.userList.getList(pageNum);
$("#loadMsg").text("");
}
});
},
/*
* 验证字段
* @status 更新或者添加时进行验证
*/
validate: function(status) {
if (!status) {
status = "";
}
var userName = $("#userName" + status).val().replace(/(^\s*)|(\s*$)/g, "");
if (2 > userName.length || userName.length > 20) {
$("#tipMsg").text(Label.nameTooLongLabel);
$("#userName" + status).focus();
} else if ($("#userEmail" + status).val().replace(/\s/g, "") === "") {
$("#tipMsg").text(Label.mailCannotEmptyLabel);
$("#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())) {
$("#tipMsg").text(Label.mailInvalidLabel);
$("#userEmail" + status).focus();
} else if ($("#userPassword" + status).val().replace(/\s/g, "") === "") {
$("#tipMsg").text(Label.passwordEmptyLabel);
$("#userPassword" + status).focus();
} else {
return true;
}
return false;
}
};
/*
* 注册到 admin 进行管理
*/
admin.register["user-list"] = {
"obj": admin.userList,
"init": admin.userList.init,
"refresh": function() {
$("#loadMsg").text("");
}
}/* }/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team * Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
* *
...@@ -3802,7 +3806,7 @@ admin.plugin = { ...@@ -3802,7 +3806,7 @@ admin.plugin = {
* main for admin * main for admin
* *
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a> * @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.0.2, Aug 9, 2011 * @version 1.0.0.3, May 28, 2013
*/ */
/* main 相关操作 */ /* main 相关操作 */
...@@ -3815,12 +3819,12 @@ admin.main = { ...@@ -3815,12 +3819,12 @@ admin.main = {
admin.register.main = { admin.register.main = {
"obj": admin.main, "obj": admin.main,
"init": function () { "init": function () {
$("#loadMsg").text(""); admin.clearTip();
}, },
"refresh": function () { "refresh": function () {
$("#loadMsg").text(""); admin.clearTip();
} }
} };
/* /*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team * Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
* *
...@@ -3841,29 +3845,28 @@ admin.register.main = { ...@@ -3841,29 +3845,28 @@ admin.register.main = {
* *
* @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.0.3, Jan 7, 2012 * @version 1.0.0.4, May 28, 2013
*/ */
/* about 相关操作 */ /* about 相关操作 */
admin.about = { admin.about = {
init: function () { init: function() {
$.ajax({ $.ajax({
url: "http://rhythm.b3log.org/version/solo/latest/" + Label.version, url: "http://rhythm.b3log.org/version/solo/latest/" + Label.version,
type: "GET", type: "GET",
cache: false, cache: false,
dataType:"jsonp", dataType: "jsonp",
error: function() {
// alert("Error loading articles from Rhythm");
},
success: function(data, textStatus) { success: function(data, textStatus) {
var version = data.soloVersion; var version = data.soloVersion;
if (version === Label.version) { if (version === Label.version) {
$("#aboutLatest").text(Label.upToDateLabel); $("#aboutLatest").text(Label.upToDateLabel);
} else { } else {
$("#aboutLatest").html(Label.outOfDateLabel + $("#aboutLatest").html(Label.outOfDateLabel +
"<a href='" + data.soloDownload + "'>" + version + "</a>"); "<a href='" + data.soloDownload + "'>" + version + "</a>");
} }
$("#loadMsg").text(""); },
complete: function(XHR, TS) {
admin.clearTip();
} }
}); });
} }
...@@ -3875,7 +3878,7 @@ admin.about = { ...@@ -3875,7 +3878,7 @@ admin.about = {
admin.register["about"] = { admin.register["about"] = {
"obj": admin.about, "obj": admin.about,
"init": admin.about.init, "init": admin.about.init,
"refresh": function () { "refresh": function() {
$("#loadMsg").text(""); admin.clearTip();
} }
} };
\ No newline at end of file \ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* main for admin * main for admin
* *
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a> * @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.0.2, Aug 9, 2011 * @version 1.0.0.3, May 28, 2013
*/ */
/* main 相关操作 */ /* main 相关操作 */
...@@ -30,9 +30,9 @@ admin.main = { ...@@ -30,9 +30,9 @@ admin.main = {
admin.register.main = { admin.register.main = {
"obj": admin.main, "obj": admin.main,
"init": function () { "init": function () {
$("#loadMsg").text(""); admin.clearTip();
}, },
"refresh": function () { "refresh": function () {
$("#loadMsg").text(""); admin.clearTip();
} }
} };
...@@ -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.0.7, May 3, 2012 * @version 1.0.0.8, May 28, 2013
*/ */
/* oterhs 相关操作 */ /* oterhs 相关操作 */
...@@ -122,6 +122,6 @@ admin.register.others = { ...@@ -122,6 +122,6 @@ admin.register.others = {
"obj": admin.others, "obj": admin.others,
"init":admin.others.init, "init":admin.others.init,
"refresh": function () { "refresh": function () {
$("#loadMsg").text(""); admin.clearTip();
} }
} };
...@@ -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.2.3, Feb 23, 2013 * @version 1.0.2.4, May 28, 2013
*/ */
/* page-list 相关操作 */ /* page-list 相关操作 */
...@@ -114,6 +114,7 @@ admin.pageList = { ...@@ -114,6 +114,7 @@ admin.pageList = {
*/ */
getList: function (pageNum) { getList: function (pageNum) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
var that = this; var that = this;
$.ajax({ $.ajax({
......
...@@ -18,12 +18,12 @@ ...@@ -18,12 +18,12 @@
* *
* @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.3, May 3, 2012 * @version 1.0.1.4, May 28, 2013
*/ */
/* plugin-list 相关操作 */ /* plugin-list 相关操作 */
admin.pluginList = { admin.pluginList = {
tablePagination: new TablePaginate("plugin"), tablePagination: new TablePaginate("plugin"),
pageInfo: { pageInfo: {
currentCount: 1, currentCount: 1,
pageCount: 1, pageCount: 1,
...@@ -32,29 +32,29 @@ admin.pluginList = { ...@@ -32,29 +32,29 @@ admin.pluginList = {
/* /*
* 初始化 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.pluginNameLabel, text: Label.pluginNameLabel,
index: "name", index: "name",
width: 230 width: 230
}, { }, {
style: "padding-left: 12px;", style: "padding-left: 12px;",
text: Label.statusLabel, text: Label.statusLabel,
index: "status", index: "status",
minWidth: 180 minWidth: 180
}, { }, {
style: "padding-left: 12px;", style: "padding-left: 12px;",
text: Label.authorLabel, text: Label.authorLabel,
index: "author", index: "author",
width: 200 width: 200
}, { }, {
style: "padding-left: 12px;", style: "padding-left: 12px;",
text: Label.versionLabel, text: Label.versionLabel,
index: "version", index: "version",
width: 120 width: 120
}]); }]);
this.tablePagination.initPagination(); this.tablePagination.initPagination();
$("#pluginSetting").dialog({ $("#pluginSetting").dialog({
width: 700, width: 700,
...@@ -64,31 +64,31 @@ admin.pluginList = { ...@@ -64,31 +64,31 @@ admin.pluginList = {
}); });
this.getList(page); this.getList(page);
}, },
/* /*
* 根据当前页码获取列表 * 根据当前页码获取列表
* @pagNum 当前页码 * @pagNum 当前页码
*/ */
getList: function (pageNum) { getList: function(pageNum) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
var that = this; var that = this;
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/plugins/" + pageNum + "/" + Label.PAGE_SIZE + "/" + Label.WINDOW_SIZE, url: latkeConfig.servePath + "/console/plugins/" + 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;
} }
admin.pluginList.pageInfo.currentPage = pageNum; admin.pluginList.pageInfo.currentPage = pageNum;
var datas = result.plugins; var datas = result.plugins;
for (var i = 0; i < datas.length; i++) { for (var i = 0; i < datas.length; i++) {
datas[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.pluginList.changeStatus('" + datas[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.pluginList.changeStatus('" +
datas[i].oId + "', '" + datas[i].status + "')\">"; datas[i].oId + "', '" + datas[i].status + "')\">";
if (datas[i].status === "ENABLED") { if (datas[i].status === "ENABLED") {
datas[i].status = Label.enabledLabel; datas[i].status = Label.enabledLabel;
datas[i].expendRow += Label.disableLabel; datas[i].expendRow += Label.disableLabel;
...@@ -97,67 +97,66 @@ admin.pluginList = { ...@@ -97,67 +97,66 @@ admin.pluginList = {
datas[i].expendRow += Label.enableLabel; datas[i].expendRow += Label.enableLabel;
} }
datas[i].expendRow += "</a> "; datas[i].expendRow += "</a> ";
if(datas[i].setting!="{}"){ if (datas[i].setting != "{}") {
datas[i].expendRow +="<a href='javascript:void(0)' onclick=\"admin.pluginList.toSetting('"+datas[i].oId+"')\"> "+Label.settingLabel+" </a> "; datas[i].expendRow += "<a href='javascript:void(0)' onclick=\"admin.pluginList.toSetting('" + datas[i].oId + "')\"> " + Label.settingLabel + " </a> ";
} }
} }
that.tablePagination.updateTablePagination(result.plugins, pageNum, result.pagination); that.tablePagination.updateTablePagination(result.plugins, pageNum, result.pagination);
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
}, },
toSetting: function(pluginId) {
toSetting:function(pluginId){
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
var requestJSONObject = { var requestJSONObject = {
"oId": pluginId "oId": pluginId
}; };
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/plugin/toSetting", url: latkeConfig.servePath + "/console/plugin/toSetting",
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);
$("#pluginSetting").html(result); $("#pluginSetting").html(result);
$("#pluginSetting").dialog("open"); $("#pluginSetting").dialog("open");
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
}, },
changeStatus: function(pluginId, status) {
changeStatus: function (pluginId, status) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
if (status === "ENABLED") { if (status === "ENABLED") {
status = "DISABLED"; status = "DISABLED";
} else { } else {
status = "ENABLED"; status = "ENABLED";
} }
var requestJSONObject = { var requestJSONObject = {
"oId": pluginId, "oId": pluginId,
"status": status "status": status
}; };
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/plugin/status/", url: latkeConfig.servePath + "/console/plugin/status/",
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;
} }
$("#loadMsg").text(""); $("#loadMsg").text("");
window.location.reload(); window.location.reload();
} }
...@@ -166,12 +165,12 @@ admin.pluginList = { ...@@ -166,12 +165,12 @@ admin.pluginList = {
}; };
/* /*
* 注册到 admin 进行管理 * 注册到 admin 进行管理
*/ */
admin.register["plugin-list"] = { admin.register["plugin-list"] = {
"obj": admin.pluginList, "obj": admin.pluginList,
"init": admin.pluginList.init, "init": admin.pluginList.init,
"refresh": function () { "refresh": function() {
$("#loadMsg").text(""); admin.claerTip();
} }
} };
...@@ -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.1.7, Mar 5, 2013 * @version 1.0.1.8, May 28, 2013
*/ */
/* preference 相关操作 */ /* preference 相关操作 */
...@@ -257,6 +257,6 @@ admin.register["preference"] = { ...@@ -257,6 +257,6 @@ admin.register["preference"] = {
"obj": admin.preference, "obj": admin.preference,
"init": admin.preference.init, "init": admin.preference.init,
"refresh": function () { "refresh": function () {
$("#loadMsg").text(""); admin.clearTip();
} }
} };
...@@ -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.1.6, Apr 2, 2013 * @version 1.0.1.7, May 28, 2013
*/ */
/* user-list 相关操作 */ /* user-list 相关操作 */
...@@ -70,6 +70,7 @@ admin.userList = { ...@@ -70,6 +70,7 @@ admin.userList = {
*/ */
getList: function(pageNum) { getList: function(pageNum) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
this.pageInfo.currentPage = pageNum; this.pageInfo.currentPage = pageNum;
var that = this; var that = this;
...@@ -176,6 +177,7 @@ admin.userList = { ...@@ -176,6 +177,7 @@ admin.userList = {
*/ */
get: function(id, userRole) { get: function(id, userRole) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
$("#userUpdate").dialog("open"); $("#userUpdate").dialog("open");
$.ajax({ $.ajax({
...@@ -290,6 +292,7 @@ admin.userList = { ...@@ -290,6 +292,7 @@ admin.userList = {
* @param id * @param id
*/ */
changeRole: function(id) { changeRole: function(id) {
$("#tipMsg").text("");
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/changeRole/" + id, url: latkeConfig.servePath + "/console/changeRole/" + id,
type: "GET", type: "GET",
...@@ -352,6 +355,6 @@ admin.register["user-list"] = { ...@@ -352,6 +355,6 @@ admin.register["user-list"] = {
"obj": admin.userList, "obj": admin.userList,
"init": admin.userList.init, "init": admin.userList.init,
"refresh": function() { "refresh": function() {
$("#loadMsg").text(""); admin.clearTip();
} }
} }
\ No newline at end of file
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