Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo
Commits
dfefaffd
Commit
dfefaffd
authored
Nov 20, 2012
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
评论同步问题
parent
9ff689d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
569 additions
and
569 deletions
+569
-569
core/src/main/java/org/b3log/solo/event/symphony/CommentSender.java
...ain/java/org/b3log/solo/event/symphony/CommentSender.java
+2
-2
war/src/main/webapp/js/admin/latkeAdmin.js
war/src/main/webapp/js/admin/latkeAdmin.js
+567
-567
No files found.
core/src/main/java/org/b3log/solo/event/symphony/CommentSender.java
View file @
dfefaffd
...
...
@@ -40,7 +40,7 @@ import org.json.JSONObject;
* This listener is responsible for sending comment to B3log Symphony.
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.0.
1, Nov 16
, 2012
* @version 1.0.0.
2, Nov 20
, 2012
* @since 0.5.5
*/
public
final
class
CommentSender
extends
AbstractEventListener
<
JSONObject
>
{
...
...
@@ -109,7 +109,7 @@ public final class CommentSender extends AbstractEventListener<JSONObject> {
requestJSONObject
.
put
(
Comment
.
COMMENT
,
comment
);
requestJSONObject
.
put
(
"clientVersion"
,
SoloServletListener
.
VERSION
);
requestJSONObject
.
put
(
"clientRuntimeEnv"
,
Latkes
.
getRuntimeEnv
().
name
());
requestJSONObject
.
put
(
"client
n
Name"
,
"B3log Solo"
);
requestJSONObject
.
put
(
"clientName"
,
"B3log Solo"
);
requestJSONObject
.
put
(
"clientHost"
,
blogHost
);
requestJSONObject
.
put
(
"clientAdminEmail"
,
preference
.
optString
(
Preference
.
ADMIN_EMAIL
));
requestJSONObject
.
put
(
"userB3Key"
,
preference
.
optString
(
Preference
.
KEY_OF_SOLO
));
...
...
war/src/main/webapp/js/admin/latkeAdmin.js
View file @
dfefaffd
/*
* Copyright (c) 2009, 2010, 2011, 2012, 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.
*/
/**
* index for admin
*
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.2.0, Aug 30, 2012
*/
var
Admin
=
function
()
{
this
.
register
=
{};
// 工具栏下的工具
this
.
tools
=
[
'
#page-list
'
,
'
#file-list
'
,
'
#link-list
'
,
'
#preference
'
,
'
#user-list
'
,
'
#plugin-list
'
,
'
#others
'
];
// 多用户时,一般用户不能使用的功能
this
.
adTools
=
[
'
link-list
'
,
'
preference
'
,
'
file-list
'
,
'
page-list
'
,
'
user-list
'
,
'
plugin-list
'
,
'
others
'
];
};
$
.
extend
(
Admin
.
prototype
,
{
/*
* 登出
*/
logout
:
function
()
{
window
.
location
.
href
=
latkeConfig
.
servePath
+
"
/logout?goto=
"
+
latkeConfig
.
servePath
;
},
/*
* 根据当前页数设置 hash
* @currentPage {string} 当前页
*/
setHashByPage
:
function
(
currentPage
)
{
var
hash
=
window
.
location
.
hash
,
hashList
=
hash
.
split
(
"
/
"
);
if
(
/^
\d
*$/
.
test
(
hashList
[
hashList
.
length
-
1
]))
{
hashList
[
hashList
.
length
-
1
]
=
currentPage
;
}
else
{
hashList
.
push
(
currentPage
);
}
window
.
location
.
hash
=
hashList
.
join
(
"
/
"
);
},
/*
* 设置某个 tab 被选择
* @id tab id
*/
selectTab
:
function
(
id
)
{
window
.
location
.
hash
=
"
#
"
+
id
;
},
/*
* 根据当前 hash 解析出当前页数及 hash 数组。
*/
analyseHash
:
function
()
{
var
hash
=
window
.
location
.
hash
;
var
tag
=
hash
.
substr
(
1
,
hash
.
length
-
1
);
var
tagList
=
tag
.
split
(
"
/
"
);
var
tags
=
{};
tags
.
page
=
1
,
tags
.
hashList
=
[];
for
(
var
i
=
0
;
i
<
tagList
.
length
;
i
++
)
{
if
(
i
===
tagList
.
length
-
1
&&
(
/^
\d
+$/
.
test
(
tagList
[
i
])))
{
tags
.
page
=
tagList
[
i
];
}
else
{
tags
.
hashList
.
push
(
tagList
[
i
]);
}
}
return
tags
;
},
/*
* 根据当前 hash 设置当前 tab
*/
setCurByHash
:
function
()
{
var
tags
=
admin
.
analyseHash
();
var
tab
=
tags
.
hashList
[
1
],
subTab
=
tags
.
hashList
[
2
];
if
(
tags
.
hashList
.
length
===
1
)
{
tab
=
tags
.
hashList
[
0
];
}
if
(
tab
===
""
)
{
return
;
}
// 离开编辑器时进行提示
try
{
// 除更新、发布、取消发布文章,编辑器中无内容外,离开编辑器需进行提示。
if
(
tab
!==
"
article
"
&&
admin
.
article
.
isConfirm
&&
admin
.
editorArticle
.
getContent
().
replace
(
/
\s
/g
,
''
)
!==
""
)
{
if
(
!
confirm
(
Label
.
editorLeaveLabel
))
{
window
.
location
.
hash
=
"
#article/article
"
;
return
;
}
}
// 不离开编辑器,hash 需变为 "#article/article",此时不需要做任何处理。
if
(
tab
===
"
article
"
&&
admin
.
article
.
isConfirm
&&
admin
.
editorArticle
.
getContent
().
replace
(
/
\s
/g
,
''
)
!==
""
)
{
return
;
}
}
catch
(
e
)
{
var
$articleContent
=
$
(
'
#articleContent
'
);
if
(
$articleContent
.
length
>
0
)
{
if
(
tab
!==
"
article
"
&&
admin
.
article
.
isConfirm
&&
$articleContent
.
val
().
replace
(
/
\s
/g
,
''
)
!==
""
)
{
if
(
!
confirm
(
Label
.
editorLeaveLabel
))
{
window
.
location
.
hash
=
"
#article/article
"
;
return
;
}
}
// 不离开编辑器,hash 需变为 "#article/article",此时不需要做任何处理。
if
(
tab
===
"
article
"
&&
admin
.
article
.
isConfirm
&&
$articleContent
.
val
().
replace
(
/
\s
/g
,
''
)
!==
""
)
{
return
;
}
}
}
// clear article
if
(
tab
!==
"
article
"
&&
admin
.
editorArticle
.
setContent
)
{
admin
.
article
.
clear
();
}
admin
.
article
.
isConfirm
=
true
;
$
(
"
#tabs
"
).
tabs
(
"
setCurrent
"
,
tab
);
$
(
"
#loadMsg
"
).
text
(
Label
.
loadingLabel
);
if
(
$
(
"
#tabsPanel_
"
+
tab
).
length
===
1
)
{
if
(
$
(
"
#tabsPanel_
"
+
tab
).
html
().
replace
(
/
\s
/g
,
""
)
===
""
)
{
// 还未加载 HTML
$
(
"
#tabsPanel_
"
+
tab
).
load
(
"
admin-
"
+
tab
+
"
.do
"
,
function
()
{
// 页面加载完后,回调初始函数
if
(
tab
===
"
article
"
&&
admin
.
article
.
status
.
id
)
{
// 当文章页面编辑器未初始化时,调用更新文章需先初始化编辑器
admin
.
register
[
tab
].
init
.
call
(
admin
.
register
[
tab
].
obj
,
admin
.
article
.
getAndSet
);
}
else
{
admin
.
register
[
tab
].
init
.
call
(
admin
.
register
[
tab
].
obj
,
tags
.
page
);
}
// 页面包含子 tab,需根据 hash 定位到相应的 tab
if
(
subTab
)
{
$
(
"
#tab
"
+
tab
.
substring
(
0
,
1
).
toUpperCase
()
+
tab
.
substring
(
1
)).
tabs
(
"
setCurrent
"
,
subTab
);
}
// 根据 hash 调用现有的插件函数
admin
.
plugin
.
setCurByHash
(
tags
);
});
}
else
{
if
(
tab
===
"
article
"
&&
admin
.
article
.
status
.
id
)
{
admin
.
article
.
getAndSet
();
}
// 已加载过 HTML,只需调用刷新函数
if
(
admin
.
register
[
tab
]
&&
admin
.
register
[
tab
].
refresh
)
{
admin
.
register
[
tab
].
refresh
.
call
(
admin
.
register
[
tab
].
obj
,
tags
.
page
);
}
// 页面包含子 tab,需根据 hash 定位到相应的 tab
if
(
subTab
)
{
$
(
"
#tab
"
+
tab
.
substring
(
0
,
1
).
toUpperCase
()
+
tab
.
substring
(
1
)).
tabs
(
"
setCurrent
"
,
subTab
);
}
// 根据 hash 调用现有的插件函数
admin
.
plugin
.
setCurByHash
(
tags
);
}
}
else
{
$
(
"
#tipMsg
"
).
text
(
"
Error: No tab!
"
+
Label
.
reportIssueLabel
);
$
(
"
#loadMsg
"
).
text
(
""
);
}
},
/*
* 初始化整个后台
*/
init
:
function
()
{
//window.onerror = Util.error;
Util
.
killIE
();
$
(
"
#loadMsg
"
).
text
(
Label
.
loadingLabel
);
// 构建 tabs
$
(
"
#tabs
"
).
tabs
();
// tipMsg
setInterval
(
function
()
{
if
(
$
(
"
#tipMsg
"
).
text
()
!==
""
)
{
setTimeout
(
function
()
{
$
(
"
#tipMsg
"
).
text
(
""
);
},
7000
);
}
},
6000
);
$
(
"
#loadMsg
"
).
text
(
""
);
},
/*
* @description tools and article collapse
* @param {bom} it 触发事件对象
*/
collapseNav
:
function
(
it
)
{
var
subNav
=
$
(
it
).
next
();
subNav
.
slideToggle
(
"
normal
"
,
function
()
{
if
(
this
.
style
.
display
!==
"
none
"
)
{
$
(
it
).
find
(
"
.ico-arrow-down
"
)[
0
].
className
=
"
ico-arrow-up
"
;
}
else
{
$
(
it
).
find
(
"
.ico-arrow-up
"
)[
0
].
className
=
"
ico-arrow-down
"
;
}
});
},
/*
* 后台及当前页面所需插件初始化完后,对权限进行控制及当前页面属于 tools 时,tools 选项需展开。
*/
inited
:
function
()
{
// Removes functions with the current user role
if
(
Label
.
userRole
!==
"
adminRole
"
)
{
for
(
var
i
=
0
;
i
<
this
.
adTools
.
length
;
i
++
)
{
$
(
"
#tabs
"
).
tabs
(
"
remove
"
,
this
.
adTools
[
i
]);
}
}
else
{
// 当前 tab 属于 Tools 时,设其展开
for
(
var
j
=
0
;
j
<
this
.
tools
.
length
;
j
++
)
{
if
(
"
#
"
+
window
.
location
.
hash
.
split
(
"
/
"
)[
1
]
===
this
.
tools
[
j
])
{
$
(
"
#tabToolsTitle
"
).
click
();
break
;
}
}
}
this
.
setCurByHash
();
}
});
/*
* Copyright (c) 2009, 2010, 2011, 2012, 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.
*/
/**
* index for admin
*
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.2.0, Aug 30, 2012
*/
var
Admin
=
function
()
{
this
.
register
=
{};
// 工具栏下的工具
this
.
tools
=
[
'
#page-list
'
,
'
#file-list
'
,
'
#link-list
'
,
'
#preference
'
,
'
#user-list
'
,
'
#plugin-list
'
,
'
#others
'
];
// 多用户时,一般用户不能使用的功能
this
.
adTools
=
[
'
link-list
'
,
'
preference
'
,
'
file-list
'
,
'
page-list
'
,
'
user-list
'
,
'
plugin-list
'
,
'
others
'
];
};
$
.
extend
(
Admin
.
prototype
,
{
/*
* 登出
*/
logout
:
function
()
{
window
.
location
.
href
=
latkeConfig
.
servePath
+
"
/logout?goto=
"
+
latkeConfig
.
servePath
;
},
/*
* 根据当前页数设置 hash
* @currentPage {string} 当前页
*/
setHashByPage
:
function
(
currentPage
)
{
var
hash
=
window
.
location
.
hash
,
hashList
=
hash
.
split
(
"
/
"
);
if
(
/^
\d
*$/
.
test
(
hashList
[
hashList
.
length
-
1
]))
{
hashList
[
hashList
.
length
-
1
]
=
currentPage
;
}
else
{
hashList
.
push
(
currentPage
);
}
window
.
location
.
hash
=
hashList
.
join
(
"
/
"
);
},
/*
* 设置某个 tab 被选择
* @id tab id
*/
selectTab
:
function
(
id
)
{
window
.
location
.
hash
=
"
#
"
+
id
;
},
/*
* 根据当前 hash 解析出当前页数及 hash 数组。
*/
analyseHash
:
function
()
{
var
hash
=
window
.
location
.
hash
;
var
tag
=
hash
.
substr
(
1
,
hash
.
length
-
1
);
var
tagList
=
tag
.
split
(
"
/
"
);
var
tags
=
{};
tags
.
page
=
1
,
tags
.
hashList
=
[];
for
(
var
i
=
0
;
i
<
tagList
.
length
;
i
++
)
{
if
(
i
===
tagList
.
length
-
1
&&
(
/^
\d
+$/
.
test
(
tagList
[
i
])))
{
tags
.
page
=
tagList
[
i
];
}
else
{
tags
.
hashList
.
push
(
tagList
[
i
]);
}
}
return
tags
;
},
/*
* 根据当前 hash 设置当前 tab
*/
setCurByHash
:
function
()
{
var
tags
=
admin
.
analyseHash
();
var
tab
=
tags
.
hashList
[
1
],
subTab
=
tags
.
hashList
[
2
];
if
(
tags
.
hashList
.
length
===
1
)
{
tab
=
tags
.
hashList
[
0
];
}
if
(
tab
===
""
)
{
return
;
}
// 离开编辑器时进行提示
try
{
// 除更新、发布、取消发布文章,编辑器中无内容外,离开编辑器需进行提示。
if
(
tab
!==
"
article
"
&&
admin
.
article
.
isConfirm
&&
admin
.
editorArticle
.
getContent
().
replace
(
/
\s
/g
,
''
)
!==
""
)
{
if
(
!
confirm
(
Label
.
editorLeaveLabel
))
{
window
.
location
.
hash
=
"
#article/article
"
;
return
;
}
}
// 不离开编辑器,hash 需变为 "#article/article",此时不需要做任何处理。
if
(
tab
===
"
article
"
&&
admin
.
article
.
isConfirm
&&
admin
.
editorArticle
.
getContent
().
replace
(
/
\s
/g
,
''
)
!==
""
)
{
return
;
}
}
catch
(
e
)
{
var
$articleContent
=
$
(
'
#articleContent
'
);
if
(
$articleContent
.
length
>
0
)
{
if
(
tab
!==
"
article
"
&&
admin
.
article
.
isConfirm
&&
$articleContent
.
val
().
replace
(
/
\s
/g
,
''
)
!==
""
)
{
if
(
!
confirm
(
Label
.
editorLeaveLabel
))
{
window
.
location
.
hash
=
"
#article/article
"
;
return
;
}
}
// 不离开编辑器,hash 需变为 "#article/article",此时不需要做任何处理。
if
(
tab
===
"
article
"
&&
admin
.
article
.
isConfirm
&&
$articleContent
.
val
().
replace
(
/
\s
/g
,
''
)
!==
""
)
{
return
;
}
}
}
// clear article
if
(
tab
!==
"
article
"
&&
admin
.
editorArticle
.
setContent
)
{
admin
.
article
.
clear
();
}
admin
.
article
.
isConfirm
=
true
;
$
(
"
#tabs
"
).
tabs
(
"
setCurrent
"
,
tab
);
$
(
"
#loadMsg
"
).
text
(
Label
.
loadingLabel
);
if
(
$
(
"
#tabsPanel_
"
+
tab
).
length
===
1
)
{
if
(
$
(
"
#tabsPanel_
"
+
tab
).
html
().
replace
(
/
\s
/g
,
""
)
===
""
)
{
// 还未加载 HTML
$
(
"
#tabsPanel_
"
+
tab
).
load
(
"
admin-
"
+
tab
+
"
.do
"
,
function
()
{
// 页面加载完后,回调初始函数
if
(
tab
===
"
article
"
&&
admin
.
article
.
status
.
id
)
{
// 当文章页面编辑器未初始化时,调用更新文章需先初始化编辑器
admin
.
register
[
tab
].
init
.
call
(
admin
.
register
[
tab
].
obj
,
admin
.
article
.
getAndSet
);
}
else
{
admin
.
register
[
tab
].
init
.
call
(
admin
.
register
[
tab
].
obj
,
tags
.
page
);
}
// 页面包含子 tab,需根据 hash 定位到相应的 tab
if
(
subTab
)
{
$
(
"
#tab
"
+
tab
.
substring
(
0
,
1
).
toUpperCase
()
+
tab
.
substring
(
1
)).
tabs
(
"
setCurrent
"
,
subTab
);
}
// 根据 hash 调用现有的插件函数
admin
.
plugin
.
setCurByHash
(
tags
);
});
}
else
{
if
(
tab
===
"
article
"
&&
admin
.
article
.
status
.
id
)
{
admin
.
article
.
getAndSet
();
}
// 已加载过 HTML,只需调用刷新函数
if
(
admin
.
register
[
tab
]
&&
admin
.
register
[
tab
].
refresh
)
{
admin
.
register
[
tab
].
refresh
.
call
(
admin
.
register
[
tab
].
obj
,
tags
.
page
);
}
// 页面包含子 tab,需根据 hash 定位到相应的 tab
if
(
subTab
)
{
$
(
"
#tab
"
+
tab
.
substring
(
0
,
1
).
toUpperCase
()
+
tab
.
substring
(
1
)).
tabs
(
"
setCurrent
"
,
subTab
);
}
// 根据 hash 调用现有的插件函数
admin
.
plugin
.
setCurByHash
(
tags
);
}
}
else
{
$
(
"
#tipMsg
"
).
text
(
"
Error: No tab!
"
+
Label
.
reportIssueLabel
);
$
(
"
#loadMsg
"
).
text
(
""
);
}
},
/*
* 初始化整个后台
*/
init
:
function
()
{
//window.onerror = Util.error;
Util
.
killIE
();
$
(
"
#loadMsg
"
).
text
(
Label
.
loadingLabel
);
// 构建 tabs
$
(
"
#tabs
"
).
tabs
();
// tipMsg
setInterval
(
function
()
{
if
(
$
(
"
#tipMsg
"
).
text
()
!==
""
)
{
setTimeout
(
function
()
{
$
(
"
#tipMsg
"
).
text
(
""
);
},
7000
);
}
},
6000
);
$
(
"
#loadMsg
"
).
text
(
""
);
},
/*
* @description tools and article collapse
* @param {bom} it 触发事件对象
*/
collapseNav
:
function
(
it
)
{
var
subNav
=
$
(
it
).
next
();
subNav
.
slideToggle
(
"
normal
"
,
function
()
{
if
(
this
.
style
.
display
!==
"
none
"
)
{
$
(
it
).
find
(
"
.ico-arrow-down
"
)[
0
].
className
=
"
ico-arrow-up
"
;
}
else
{
$
(
it
).
find
(
"
.ico-arrow-up
"
)[
0
].
className
=
"
ico-arrow-down
"
;
}
});
},
/*
* 后台及当前页面所需插件初始化完后,对权限进行控制及当前页面属于 tools 时,tools 选项需展开。
*/
inited
:
function
()
{
// Removes functions with the current user role
if
(
Label
.
userRole
!==
"
adminRole
"
)
{
for
(
var
i
=
0
;
i
<
this
.
adTools
.
length
;
i
++
)
{
$
(
"
#tabs
"
).
tabs
(
"
remove
"
,
this
.
adTools
[
i
]);
}
}
else
{
// 当前 tab 属于 Tools 时,设其展开
for
(
var
j
=
0
;
j
<
this
.
tools
.
length
;
j
++
)
{
if
(
"
#
"
+
window
.
location
.
hash
.
split
(
"
/
"
)[
1
]
===
this
.
tools
[
j
])
{
$
(
"
#tabToolsTitle
"
).
click
();
break
;
}
}
}
this
.
setCurByHash
();
}
});
var
admin
=
new
Admin
();
/*
* Copyright (c) 2009, 2010, 2011, 2012, B3log Team
*
...
...
@@ -3101,326 +3101,326 @@ admin.register["plugin-list"] = {
"
refresh
"
:
function
()
{
$
(
"
#loadMsg
"
).
text
(
""
);
}
}
/*
* Copyright (c) 2009, 2010, 2011, 2012, 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.3, Aug 30, 2012
*/
/* 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
.
administratorLabel
,
index
:
"
isAdmin
"
,
width
:
120
}]);
this
.
tablePagination
.
initPagination
();
this
.
getList
(
page
);
$
(
"
#userUpdate
"
).
dialog
({
width
:
700
,
height
:
190
,
"
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
=
"
"
+
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
+
"
')
\"
>
"
+
Label
.
removeLabel
+
"
</a>
"
;
userData
[
i
].
isAdmin
=
Label
.
commonUserLabel
;
}
}
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
(),
"
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
(
""
);
$
(
"
#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
"
);
}
$
(
"
#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
(),
"
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
*/
del
:
function
(
id
)
{
var
isDelete
=
confirm
(
Label
.
confirmRemoveLabel
);
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
(
""
);
}
});
}
},
/*
* 验证字段
* @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
|
[
!#
\$
%&'
\*\+\-\/
=
\?\^
_`{
\|
}~
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
+
(\.([
a-z
]
|
\d
|
[
!#
\$
%&'
\*\+\-\/
=
\?\^
_`{
\|
}~
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
+
)
*
)
|
((\x
22
)((((\x
20|
\x
09
)
*
(\x
0d
\x
0a
))?(\x
20|
\x
09
)
+
)?(([\x
01-
\x
08
\x
0b
\x
0c
\x
0e-
\x
1f
\x
7f
]
|
\x
21|
[\x
23-
\x
5b
]
|
[\x
5d-
\x
7e
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
|
(\\([\x
01-
\x
09
\x
0b
\x
0c
\x
0d-
\x
7f
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
]))))
*
(((\x
20|
\x
09
)
*
(\x
0d
\x
0a
))?(\x
20|
\x
09
)
+
)?(\x
22
)))
@
((([
a-z
]
|
\d
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
|
(([
a-z
]
|
\d
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])([
a-z
]
|
\d
|-|
\.
|_|~|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
*
([
a-z
]
|
\d
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])))\.)
+
(([
a-z
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
|
(([
a-z
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])([
a-z
]
|
\d
|-|
\.
|_|~|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
*
([
a-z
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])))\.?
$/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, 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.3, Aug 30, 2012
*/
/* 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
.
administratorLabel
,
index
:
"
isAdmin
"
,
width
:
120
}]);
this
.
tablePagination
.
initPagination
();
this
.
getList
(
page
);
$
(
"
#userUpdate
"
).
dialog
({
width
:
700
,
height
:
190
,
"
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
=
"
"
+
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
+
"
')
\"
>
"
+
Label
.
removeLabel
+
"
</a>
"
;
userData
[
i
].
isAdmin
=
Label
.
commonUserLabel
;
}
}
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
(),
"
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
(
""
);
$
(
"
#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
"
);
}
$
(
"
#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
(),
"
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
*/
del
:
function
(
id
)
{
var
isDelete
=
confirm
(
Label
.
confirmRemoveLabel
);
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
(
""
);
}
});
}
},
/*
* 验证字段
* @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
|
[
!#
\$
%&'
\*\+\-\/
=
\?\^
_`{
\|
}~
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
+
(\.([
a-z
]
|
\d
|
[
!#
\$
%&'
\*\+\-\/
=
\?\^
_`{
\|
}~
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
+
)
*
)
|
((\x
22
)((((\x
20|
\x
09
)
*
(\x
0d
\x
0a
))?(\x
20|
\x
09
)
+
)?(([\x
01-
\x
08
\x
0b
\x
0c
\x
0e-
\x
1f
\x
7f
]
|
\x
21|
[\x
23-
\x
5b
]
|
[\x
5d-
\x
7e
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
|
(\\([\x
01-
\x
09
\x
0b
\x
0c
\x
0d-
\x
7f
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
]))))
*
(((\x
20|
\x
09
)
*
(\x
0d
\x
0a
))?(\x
20|
\x
09
)
+
)?(\x
22
)))
@
((([
a-z
]
|
\d
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
|
(([
a-z
]
|
\d
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])([
a-z
]
|
\d
|-|
\.
|_|~|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
*
([
a-z
]
|
\d
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])))\.)
+
(([
a-z
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
|
(([
a-z
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])([
a-z
]
|
\d
|-|
\.
|_|~|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])
*
([
a-z
]
|
[\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
])))\.?
$/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, B3log Team
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment