Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
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-1
Commits
6b3ef233
Unverified
Commit
6b3ef233
authored
Jun 01, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎨
#12787
parent
97e42803
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
8 deletions
+20
-8
src/main/java/org/b3log/solo/util/Emotions.java
src/main/java/org/b3log/solo/util/Emotions.java
+16
-4
src/main/webapp/js/admin/admin.min.js
src/main/webapp/js/admin/admin.min.js
+1
-1
src/main/webapp/js/page.js
src/main/webapp/js/page.js
+2
-2
src/main/webapp/js/page.min.js
src/main/webapp/js/page.min.js
+1
-1
No files found.
src/main/java/org/b3log/solo/util/Emotions.java
View file @
6b3ef233
...
...
@@ -20,7 +20,9 @@ package org.b3log.solo.util;
import
com.vdurmont.emoji.EmojiParser
;
import
org.apache.commons.lang.StringUtils
;
import
org.b3log.latke.Latkes
;
import
org.b3log.solo.SoloServletListener
;
import
java.util.Set
;
import
java.util.regex.Pattern
;
/**
...
...
@@ -28,11 +30,16 @@ import java.util.regex.Pattern;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://vanessa.b3log.org">Vanessa</a>
* @version 1.1.1.0, Jun
e
1, 2019
* @version 1.1.1.0, Jun 1, 2019
* @since 1.4.0
*/
public
final
class
Emotions
{
/**
* Emoji picture paths.
*/
private
static
final
Set
<
String
>
EMOJI_PIC_PATHS
=
SoloServletListener
.
getServletContext
().
getResourcePaths
(
"/images/emoji/"
);
/**
* Converts the specified content with emotions.
*
...
...
@@ -46,9 +53,14 @@ public final class Emotions {
}
ret
=
toUnicode
(
ret
);
String
repl
=
"<img align=\"absmiddle\" alt=\":huaji:\" class=\"emoji\" src=\""
+
Latkes
.
getStaticServePath
()
+
"/images/emoji/huaji.gif"
+
"\" title=\":huaji:\" width=\"20px\" height=\"20px\"></img>"
;
ret
=
StringUtils
.
replace
(
ret
,
":huaji:"
,
repl
);
for
(
final
String
emojiPic
:
EMOJI_PIC_PATHS
)
{
final
String
emojiPicName
=
StringUtils
.
substringAfter
(
emojiPic
,
"/emoji/"
);
final
String
emoji
=
StringUtils
.
substringBefore
(
emojiPicName
,
"."
);
String
repl
=
"<img align=\"absmiddle\" alt=\""
+
emoji
+
"\" class=\"emoji\" src=\""
+
Latkes
.
getStaticServePath
()
+
"/images/emoji/"
+
emojiPicName
+
"\" title=\""
+
emoji
+
"\" width=\"20px\" height=\"20px\"></img>"
;
ret
=
StringUtils
.
replace
(
ret
,
":"
+
emoji
+
":"
,
repl
);
}
return
ret
;
}
...
...
src/main/webapp/js/admin/admin.min.js
View file @
6b3ef233
Util
.
htmlDecode
=
function
(
t
){
var
e
=
document
.
createElement
(
"
div
"
);
return
e
.
innerHTML
=
decodeURIComponent
(
t
),
e
.
innerText
};
var
Admin
=
function
(){
this
.
register
=
{},
this
.
tools
=
[
"
#page-list
"
,
"
#theme-list
"
,
"
#link-list
"
,
"
#preference
"
,
"
#user-list
"
,
"
#plugin-list
"
,
"
#others
"
,
"
#category-list
"
],
this
.
adTools
=
[
"
link-list
"
,
"
preference
"
,
"
theme-list
"
,
"
page-list
"
,
"
user-list
"
,
"
plugin-list
"
,
"
others
"
,
"
category-list
"
]};
$
.
extend
(
Admin
.
prototype
,{
logout
:
function
(){
window
.
location
.
href
=
Label
.
servePath
+
"
/logout
"
},
toggleMenu
:
function
(){
"
-240px
"
===
$
(
"
#tabs
"
).
css
(
"
left
"
)?(
$
(
"
#tabs
"
).
css
(
"
left
"
,
0
),
$
(
"
.tabs__bg
"
).
show
()):(
$
(
"
#tabs
"
).
css
(
"
left
"
,
"
-240px
"
),
$
(
"
.tabs__bg
"
).
hide
())},
clearTip
:
function
(){
$
(
"
#tipMsg
"
).
text
(
""
),
$
(
"
#loadMsg
"
).
text
(
""
)},
setHashByPage
:
function
(
t
){
var
e
=
window
.
location
.
hash
.
split
(
"
/
"
);
/^
\d
*$/
.
test
(
e
[
e
.
length
-
1
])?
e
[
e
.
length
-
1
]
=
t
:
e
.
push
(
t
),
window
.
location
.
hash
=
e
.
join
(
"
/
"
)},
selectTab
:
function
(
t
){
window
.
location
.
hash
=
"
#
"
+
t
},
analyseHash
:
function
(){
for
(
var
t
=
window
.
location
.
hash
,
e
=
t
.
substr
(
1
,
t
.
length
-
1
).
split
(
"
/
"
),
i
=
{
page
:
1
,
hashList
:[]},
a
=
0
;
a
<
e
.
length
;
a
++
)
a
===
e
.
length
-
1
&&
/^
\d
+$/
.
test
(
e
[
a
])?
i
.
page
=
e
[
a
]:
i
.
hashList
.
push
(
e
[
a
]);
return
i
},
setCurByHash
:
function
(){
$
(
window
).
scrollTop
(
0
),
$
(
"
#tipMsg
"
).
text
(
""
);
var
t
=
admin
.
analyseHash
(),
e
=
t
.
hashList
[
1
],
i
=
t
.
hashList
[
2
];
if
(
1
===
t
.
hashList
.
length
&&
(
e
=
t
.
hashList
[
0
]),
""
!==
e
){
try
{
if
(
admin
.
editors
.
articleEditor
.
getContent
){
if
(
"
article
"
!==
e
&&
admin
.
article
.
isConfirm
&&
""
!==
admin
.
editors
.
articleEditor
.
getContent
().
replace
(
/
\s
/g
,
""
)
&&
admin
.
article
.
content
!==
admin
.
editors
.
articleEditor
.
getContent
()
&&!
confirm
(
Label
.
editorLeaveLabel
))
return
void
(
window
.
location
.
hash
=
"
#article/article
"
);
if
(
"
article
"
===
e
&&
admin
.
article
.
isConfirm
&&
""
!==
admin
.
editors
.
articleEditor
.
getContent
().
replace
(
/
\s
/g
,
""
)
&&
admin
.
article
.
content
!==
admin
.
editors
.
articleEditor
.
getContent
())
return
}}
catch
(
t
){
console
.
log
(
t
)}
"
article
"
!==
e
&&
admin
.
editors
.
articleEditor
.
setContent
&&
admin
.
article
.
clear
(),
admin
.
article
.
isConfirm
=!
0
,
$
(
"
#tabs
"
).
tabs
(
"
setCurrent
"
,
e
),
$
(
"
#loadMsg
"
).
text
(
Label
.
loadingLabel
),
1
===
$
(
"
#tabsPanel_
"
+
e
).
length
?
""
===
$
(
"
#tabsPanel_
"
+
e
).
html
().
replace
(
/
\s
/g
,
""
)?
$
(
"
#tabsPanel_
"
+
e
).
load
(
"
admin-
"
+
e
+
"
.do
"
,
function
(){
"
article
"
===
e
&&
admin
.
article
.
status
.
id
?
admin
.
register
[
e
].
init
.
call
(
admin
.
register
[
e
].
obj
,
admin
.
article
.
getAndSet
):
admin
.
register
[
e
].
init
.
call
(
admin
.
register
[
e
].
obj
,
t
.
page
),
i
&&
$
(
"
#tab
"
+
e
.
substring
(
0
,
1
).
toUpperCase
()
+
e
.
substring
(
1
)).
tabs
(
"
setCurrent
"
,
i
),
admin
.
plugin
.
setCurByHash
(
t
)}):(
"
article
"
===
e
&&
admin
.
article
.
status
.
id
&&
admin
.
article
.
getAndSet
(),
admin
.
register
[
e
]
&&
admin
.
register
[
e
].
refresh
&&
admin
.
register
[
e
].
refresh
.
call
(
admin
.
register
[
e
].
obj
,
t
.
page
),
i
&&
$
(
"
#tab
"
+
e
.
substring
(
0
,
1
).
toUpperCase
()
+
e
.
substring
(
1
)).
tabs
(
"
setCurrent
"
,
i
),
admin
.
plugin
.
setCurByHash
(
t
)):(
$
(
"
#tipMsg
"
).
text
(
"
Error: No tab!
"
+
Label
.
reportIssueLabel
),
$
(
"
#loadMsg
"
).
text
(
""
))}},
init
:
function
(){
Util
.
killIE
(),
$
(
"
#loadMsg
"
).
text
(
Label
.
loadingLabel
),
$
(
"
#tabs
"
).
tabs
(),
setInterval
(
function
(){
""
!==
$
(
"
#tipMsg
"
).
text
()
&&
setTimeout
(
function
(){
$
(
"
#tipMsg
"
).
text
(
""
)},
7
e3
)},
6
e3
),
$
(
"
#loadMsg
"
).
text
(
""
),
window
.
onbeforeunload
=
function
(
t
){
if
(
"
#article/article
"
===
window
.
location
.
hash
)
return
t
&&
(
t
.
returnValue
=
Label
.
editorLeaveLabel
),
Label
.
editorLeaveLabel
},
$
(
document
).
ajaxError
(
function
(
t
,
e
,
i
,
a
){
200
!==
e
.
status
&&
$
(
"
#tipMsg
"
).
text
(
e
.
status
+
"
:
"
+
a
)})},
collapseNav
:
function
(
t
){
$
(
t
).
next
().
slideToggle
(
"
normal
"
,
function
(){
"
none
"
!==
this
.
style
.
display
?(
$
(
t
).
find
(
"
.icon-chevron-down
"
)[
0
].
className
=
"
icon-chevron-up fn__right
"
,
$
(
t
).
addClass
(
"
tab-current
"
)):(
$
(
t
).
find
(
"
.icon-chevron-up
"
)[
0
].
className
=
"
icon-chevron-down fn__right
"
,
$
(
t
).
removeClass
(
"
tab-current
"
)),
$
(
"
#tabs > ul
"
).
height
(
"
auto
"
),
$
(
"
#tabs > ul
"
).
height
(
$
(
"
#tabs > ul
"
).
height
()
+
80
)})},
inited
:
function
(){
if
(
"
adminRole
"
!==
Label
.
userRole
)
for
(
var
t
=
0
;
t
<
this
.
adTools
.
length
;
t
++
)
$
(
"
#tabs
"
).
tabs
(
"
remove
"
,
this
.
adTools
[
t
]);
else
for
(
var
e
=
0
;
e
<
this
.
tools
.
length
;
e
++
)
if
(
"
#
"
+
window
.
location
.
hash
.
split
(
"
/
"
)[
1
]
===
this
.
tools
[
e
]){
$
(
"
#tabToolsTitle
"
).
click
();
break
}
this
.
setCurByHash
()}});
var
admin
=
new
Admin
;
admin
.
editors
=
{};
var
SoloEditor
=
function
(
e
){
this
.
conf
=
e
,
this
.
init
()};
$
.
extend
(
SoloEditor
.
prototype
,{
init
:
function
(){
this
.
editor
=
new
Vditor
(
this
.
conf
.
id
,{
cache
:
!
0
,
tab
:
"
\t
"
,
hint
:{
emojiPath
:
Label
.
staticServePath
+
"
/
js/lib/emojify.js-1.1.0/images/basic
"
},
preview
:{
delay
:
500
,
show
:
this
.
conf
.
previewShow
,
url
:
Label
.
servePath
+
"
/console/markdown/2html
"
,
parse
:
function
(
e
){
"
none
"
!==
e
.
style
.
display
&&
Util
.
parseLanguage
()}},
upload
:{
max
:
10485760
,
url
:
Label
.
uploadURL
,
token
:
Label
.
uploadToken
,
filename
:
function
(
e
){
return
e
.
replace
(
/
[^
(a-zA-Z0-9
\u
4e00-
\u
9fa5
\.
)
]
/g
,
""
).
replace
(
/
[\?\\/
:|<>
\*\[\]\(\)\$
%
\{\}
@~
]
/g
,
""
).
replace
(
"
/
\\
s/g
"
,
""
)}},
height
:
this
.
conf
.
height
,
counter
:
102400
,
resize
:{
enable
:
this
.
conf
.
resize
},
lang
:
Label
.
localeString
}),
"
function
"
==
typeof
this
.
conf
.
fun
&&
this
.
conf
.
fun
()},
getContent
:
function
(){
return
this
.
editor
.
getValue
()},
setContent
:
function
(
e
){
this
.
editor
.
setValue
(
e
)},
remove
:
function
(){
document
.
getElementById
(
this
.
editor
.
vditor
.
id
).
outerHTML
=
""
}}),
admin
.
editors
.
articleEditor
=
{},
admin
.
editors
.
abstractEditor
=
{};
admin
.
editors
=
{};
var
SoloEditor
=
function
(
e
){
this
.
conf
=
e
,
this
.
init
()};
$
.
extend
(
SoloEditor
.
prototype
,{
init
:
function
(){
this
.
editor
=
new
Vditor
(
this
.
conf
.
id
,{
cache
:
!
0
,
tab
:
"
\t
"
,
hint
:{
emojiPath
:
Label
.
staticServePath
+
"
/
images/emoji
"
},
preview
:{
delay
:
500
,
show
:
this
.
conf
.
previewShow
,
url
:
Label
.
servePath
+
"
/console/markdown/2html
"
,
parse
:
function
(
e
){
"
none
"
!==
e
.
style
.
display
&&
Util
.
parseLanguage
()}},
upload
:{
max
:
10485760
,
url
:
Label
.
uploadURL
,
token
:
Label
.
uploadToken
,
filename
:
function
(
e
){
return
e
.
replace
(
/
[^
(a-zA-Z0-9
\u
4e00-
\u
9fa5
\.
)
]
/g
,
""
).
replace
(
/
[\?\\/
:|<>
\*\[\]\(\)\$
%
\{\}
@~
]
/g
,
""
).
replace
(
"
/
\\
s/g
"
,
""
)}},
height
:
this
.
conf
.
height
,
counter
:
102400
,
resize
:{
enable
:
this
.
conf
.
resize
},
lang
:
Label
.
localeString
}),
"
function
"
==
typeof
this
.
conf
.
fun
&&
this
.
conf
.
fun
()},
getContent
:
function
(){
return
this
.
editor
.
getValue
()},
setContent
:
function
(
e
){
this
.
editor
.
setValue
(
e
)},
remove
:
function
(){
document
.
getElementById
(
this
.
editor
.
vditor
.
id
).
outerHTML
=
""
}}),
admin
.
editors
.
articleEditor
=
{},
admin
.
editors
.
abstractEditor
=
{};
var
TablePaginate
=
function
(
a
){
this
.
id
=
a
,
this
.
currentPage
=
1
};
$
.
extend
(
TablePaginate
.
prototype
,{
buildTable
:
function
(
a
,
t
){
var
e
=
{
colModel
:
a
,
noDataTip
:
Label
.
noDataLabel
};
t
||
(
e
.
expendRow
=
{
index
:
"
expendRow
"
}),
$
(
"
#
"
+
this
.
id
+
"
Table
"
).
table
(
e
)},
initPagination
:
function
(){
var
a
=
this
.
id
;
$
(
"
#
"
+
a
+
"
Pagination
"
).
paginate
({
bind
:
function
(
a
,
t
){
t
?
$
(
"
#tipMsg
"
).
text
(
t
):
admin
.
setHashByPage
(
a
)},
currentPage
:
1
,
errorMessage
:
Label
.
inputErrorLabel
,
nextPageText
:
"
>
"
,
previousPageText
:
"
<
"
,
goText
:
Label
.
gotoLabel
,
type
:
"
custom
"
,
custom
:[
1
],
pageCount
:
1
})},
initCommentsDialog
:
function
(){
var
a
=
this
;
$
(
"
#
"
+
this
.
id
+
"
Comments
"
).
dialog
({
modal
:
!
0
,
hideFooter
:
!
0
,
close
:
function
(){
return
admin
[
a
.
id
+
"
List
"
].
getList
(
a
.
currentPage
),
!
0
}})},
updateTablePagination
:
function
(
a
,
t
,
e
){
if
((
t
=
parseInt
(
t
))
>
e
.
paginationPageCount
&&
1
<
t
)
return
$
(
"
#tipMsg
"
).
text
(
Label
.
pageLabel
+
t
+
Label
.
notFoundLabel
),
void
$
(
"
#loadMsg
"
).
text
(
""
);
$
(
"
#
"
+
this
.
id
+
"
Table
"
).
table
(
"
update
"
,{
data
:[{
groupName
:
"
all
"
,
groupData
:
a
}]}),
0
===
e
.
paginationPageCount
&&
(
e
.
paginationPageCount
=
1
),
$
(
"
#
"
+
this
.
id
+
"
Pagination
"
).
paginate
(
"
update
"
,{
pageCount
:
e
.
paginationPageCount
,
currentPage
:
t
,
custom
:
e
.
paginationPageNums
}),
this
.
currentPage
=
t
}});
admin
.
article
=
{
isConfirm
:
!
0
,
status
:{
id
:
void
0
,
isArticle
:
void
0
},
content
:
""
,
get
:
function
(
t
,
e
){
this
.
status
.
id
=
t
,
this
.
status
.
isArticle
=
e
,
admin
.
selectTab
(
"
article/article
"
)},
getAndSet
:
function
(){
$
(
"
#loadMsg
"
).
text
(
Label
.
loadingLabel
),
$
(
"
#tipMsg
"
).
text
(
""
),
$
.
ajax
({
url
:
Label
.
servePath
+
"
/console/article/
"
+
admin
.
article
.
status
.
id
,
type
:
"
GET
"
,
cache
:
!
1
,
success
:
function
(
e
,
t
){
if
(
$
(
"
#tipMsg
"
).
text
(
e
.
msg
),
e
.
sc
){
$
(
"
#title
"
).
val
(
e
.
article
.
articleTitle
),
admin
.
editors
.
articleEditor
.
setContent
(
e
.
article
.
articleContent
),
admin
.
editors
.
abstractEditor
.
setContent
(
e
.
article
.
articleAbstract
),
admin
.
article
.
content
=
admin
.
editors
.
articleEditor
.
getContent
();
for
(
var
i
=
e
.
article
.
articleTags
,
a
=
""
,
l
=
0
;
l
<
i
.
length
;
l
++
)
0
===
l
?
a
=
i
[
l
].
tagTitle
:
a
+=
"
,
"
+
i
[
l
].
tagTitle
;
$
(
"
#tag
"
).
val
(
a
),
$
(
"
#permalink
"
).
val
(
e
.
article
.
articlePermalink
),
$
(
"
#viewPwd
"
).
val
(
e
.
article
.
articleViewPwd
),
$
(
"
#articleCommentable
"
).
prop
(
"
checked
"
,
e
.
article
.
articleCommentable
);
var
s
=
e
.
article
.
signs
;
$
(
"
.signs button
"
).
each
(
function
(
t
){
parseInt
(
e
.
article
.
articleSignId
)
===
parseInt
(
s
[
t
].
oId
)?
$
(
"
#articleSign
"
+
s
[
t
].
oId
).
addClass
(
"
selected
"
):
$
(
"
#articleSign
"
+
s
[
t
].
oId
).
removeClass
(
"
selected
"
)}),
admin
.
article
.
setStatus
(),
$
(
"
#loadMsg
"
).
text
(
""
)}
else
$
(
"
#loadMsg
"
).
text
(
""
)}})},
del
:
function
(
t
,
i
,
e
){
confirm
(
Label
.
confirmRemoveLabel
+
Label
.
articleLabel
+
'
"
'
+
Util
.
htmlDecode
(
e
)
+
'
"?
'
)
&&
(
$
(
"
#loadMsg
"
).
text
(
Label
.
loadingLabel
),
$
(
"
#tipMsg
"
).
text
(
""
),
$
.
ajax
({
url
:
Label
.
servePath
+
"
/console/article/
"
+
t
,
type
:
"
DELETE
"
,
cache
:
!
1
,
success
:
function
(
t
,
e
){
$
(
"
#tipMsg
"
).
text
(
t
.
msg
),
t
.
sc
?
admin
[
i
+
"
List
"
].
getList
(
1
):
$
(
"
#loadMsg
"
).
text
(
""
)}}))},
add
:
function
(
e
){
if
(
admin
.
article
.
validate
()){
var
i
=
this
;
i
.
_addDisabled
(),
$
(
"
#loadMsg
"
).
text
(
Label
.
loadingLabel
),
$
(
"
#tipMsg
"
).
text
(
""
);
var
t
=
""
;
$
(
"
.signs button
"
).
each
(
function
(){
"
selected
"
===
this
.
className
&&
(
t
=
this
.
id
.
substr
(
this
.
id
.
length
-
1
,
1
))});
var
a
=
admin
.
editors
.
articleEditor
.
getContent
(),
l
=
admin
.
editors
.
abstractEditor
.
getContent
();
if
(
$
(
"
#articleThumbnail
"
).
prop
(
"
checked
"
)){
var
s
=
$
(
"
.thumbnail__img
"
).
css
(
"
background-image
"
);
a
=
"
.
replace
(
"
w/768
"
,
"
w/960
"
).
replace
(
"
h/432
"
,
"
h/540
"
)
+
"
)
\n\n
"
+
a
}
var
c
=
{
article
:{
articleTitle
:
$
(
"
#title
"
).
val
(),
articleContent
:
a
,
articleAbstract
:
l
,
articleTags
:
this
.
trimUniqueArray
(
$
(
"
#tag
"
).
val
()).
toString
(),
articlePermalink
:
$
(
"
#permalink
"
).
val
(),
articleStatus
:
e
,
articleSignId
:
t
,
postToCommunity
:
$
(
"
#postToCommunity
"
).
prop
(
"
checked
"
),
articleCommentable
:
$
(
"
#articleCommentable
"
).
prop
(
"
checked
"
),
articleViewPwd
:
$
(
"
#viewPwd
"
).
val
()}};
$
.
ajax
({
url
:
Label
.
servePath
+
"
/console/article/
"
,
type
:
"
POST
"
,
cache
:
!
1
,
data
:
JSON
.
stringify
(
c
),
success
:
function
(
t
){
$
(
"
#tipMsg
"
).
text
(
t
.
msg
),
t
.
sc
&&
(
admin
.
article
.
status
.
id
=
void
0
,
0
===
e
?
admin
.
selectTab
(
"
article/article-list
"
):
admin
.
selectTab
(
"
article/draft-list
"
),
admin
.
article
.
isConfirm
=!
1
)},
complete
:
function
(
t
,
e
){
i
.
_removeDisabled
(),
$
(
"
#loadMsg
"
).
text
(
""
)}})}},
update
:
function
(
i
){
if
(
admin
.
article
.
validate
()){
var
a
=
this
;
a
.
_addDisabled
(),
$
(
"
#loadMsg
"
).
text
(
Label
.
loadingLabel
),
$
(
"
#tipMsg
"
).
text
(
""
);
var
t
=
""
;
$
(
"
.signs button
"
).
each
(
function
(){
"
selected
"
===
this
.
className
&&
(
t
=
this
.
id
.
substr
(
this
.
id
.
length
-
1
,
1
))});
var
e
=
admin
.
editors
.
articleEditor
.
getContent
(),
l
=
admin
.
editors
.
abstractEditor
.
getContent
();
if
(
$
(
"
#articleThumbnail
"
).
prop
(
"
checked
"
)){
var
s
=
$
(
"
.thumbnail__img
"
).
css
(
"
background-image
"
);
e
=
"
.
replace
(
"
w/768
"
,
"
w/960
"
).
replace
(
"
h/432
"
,
"
h/540
"
)
+
"
)
\n\n
"
+
e
}
var
c
=
{
article
:{
oId
:
this
.
status
.
id
,
articleTitle
:
$
(
"
#title
"
).
val
(),
articleContent
:
e
,
articleAbstract
:
l
,
articleTags
:
this
.
trimUniqueArray
(
$
(
"
#tag
"
).
val
()).
toString
(),
articlePermalink
:
$
(
"
#permalink
"
).
val
(),
articleStatus
:
i
,
articleSignId
:
t
,
articleCommentable
:
$
(
"
#articleCommentable
"
).
prop
(
"
checked
"
),
articleViewPwd
:
$
(
"
#viewPwd
"
).
val
(),
postToCommunity
:
$
(
"
#postToCommunity
"
).
prop
(
"
checked
"
)}};
$
.
ajax
({
url
:
Label
.
servePath
+
"
/console/article/
"
,
type
:
"
PUT
"
,
cache
:
!
1
,
data
:
JSON
.
stringify
(
c
),
success
:
function
(
t
,
e
){
$
(
"
#tipMsg
"
).
text
(
t
.
msg
),
t
.
sc
&&
(
0
===
i
?
admin
.
selectTab
(
"
article/article-list
"
):
admin
.
selectTab
(
"
article/draft-list
"
),
$
(
"
#tipMsg
"
).
text
(
Label
.
updateSuccLabel
),
admin
.
article
.
status
.
id
=
void
0
,
admin
.
article
.
isConfirm
=!
1
)},
complete
:
function
(
t
,
e
){
a
.
_removeDisabled
(),
$
(
"
#loadMsg
"
).
text
(
""
)}})}},
setStatus
:
function
(){
$
.
ajax
({
url
:
Label
.
servePath
+
"
/console/tags
"
,
type
:
"
GET
"
,
cache
:
!
1
,
success
:
function
(
t
,
e
){
if
(
$
(
"
#tipMsg
"
).
text
(
t
.
msg
),
t
.
sc
){
if
(
!
(
t
.
tags
.
length
<=
0
)){
$
(
"
#tagCheckboxPanel>span
"
).
remove
(
""
);
for
(
var
i
=
""
,
a
=
0
;
a
<
t
.
tags
.
length
;
a
++
)
i
+=
"
<span>
"
+
t
.
tags
[
a
].
tagTitle
+
"
</span>
"
;
$
(
"
#tagCheckboxPanel
"
).
html
(
i
+
'
<div class="fn__clear"></div>
'
),
$
(
"
#loadMsg
"
).
text
(
""
)}}
else
$
(
"
#loadMsg
"
).
text
(
""
)}}),
this
.
status
?
this
.
status
.
isArticle
?(
$
(
"
#unSubmitArticle
"
).
show
(),
$
(
"
#saveArticle
"
).
hide
(),
$
(
"
#submitArticle
"
).
show
()):(
$
(
"
#submitArticle
"
).
show
(),
$
(
"
#unSubmitArticle
"
).
hide
(),
$
(
"
#saveArticle
"
).
show
()):(
$
(
"
#submitArticle
"
).
show
(),
$
(
"
#unSubmitArticle
"
).
hide
(),
$
(
"
#saveArticle
"
).
show
(),
$
(
"
#postToCommunityPanel
"
).
show
())},
clear
:
function
(){
this
.
status
=
{
id
:
void
0
,
isArticle
:
void
0
},
this
.
setStatus
(),
$
(
"
#title
"
).
val
(
""
),
admin
.
editors
.
articleEditor
.
setContent
(
""
),
admin
.
editors
.
abstractEditor
.
setContent
(
""
),
$
(
"
#tag
"
).
val
(
""
),
$
(
"
#tagCheckboxPanel
"
).
hide
().
find
(
"
span
"
).
removeClass
(
"
selected
"
),
$
(
"
#permalink
"
).
val
(
""
),
$
(
"
#articleCammentable
"
).
prop
(
"
checked
"
,
!
0
),
$
(
"
#postToCommunity
"
).
prop
(
"
checked
"
,
!
1
),
$
(
"
.signs button
"
).
each
(
function
(
t
){
this
.
className
=
0
===
t
?
"
selected
"
:
""
}),
$
(
"
#articleThumbnail
"
).
prop
(
"
checked
"
)
&&
$
(
"
#articleThumbnail
"
).
click
()},
init
:
function
(
t
){
$
(
"
.signs button
"
).
click
(
function
(
t
){
$
(
"
.signs button
"
).
removeClass
(
"
selected
"
),
$
(
this
).
addClass
(
"
selected
"
)}),
$
(
"
#tipMsg
"
).
text
(
Label
.
uploadMsg
),
$
.
ajax
({
url
:
Label
.
servePath
+
"
/console/tags
"
,
type
:
"
GET
"
,
cache
:
!
1
,
success
:
function
(
t
,
e
){
if
(
$
(
"
#tipMsg
"
).
text
(
t
.
msg
),
t
.
sc
){
if
(
!
(
t
.
tags
.
length
<=
0
)){
for
(
var
i
=
[],
a
=
0
;
a
<
t
.
tags
.
length
;
a
++
)
i
.
push
(
t
.
tags
[
a
].
tagTitle
);
$
(
"
#tag
"
).
completed
({
height
:
160
,
buttonText
:
Label
.
selectLabel
,
data
:
i
}),
$
(
"
#loadMsg
"
).
text
(
""
)}}
else
$
(
"
#loadMsg
"
).
text
(
""
)}}),
$
(
"
#submitArticle
"
).
click
(
function
(){
admin
.
article
.
status
.
id
?
admin
.
article
.
update
(
0
):
admin
.
article
.
add
(
0
)}),
$
(
"
#saveArticle
"
).
click
(
function
(){
admin
.
article
.
status
.
id
?
admin
.
article
.
update
(
admin
.
article
.
status
.
isArticle
?
0
:
1
):
admin
.
article
.
add
(
1
)}),
admin
.
editors
.
articleEditor
=
new
SoloEditor
({
id
:
"
articleContent
"
,
height
:
500
,
fun
:
t
,
previewShow
:
!
0
,
resize
:
!
1
}),
admin
.
editors
.
abstractEditor
=
new
SoloEditor
({
id
:
"
abstract
"
,
height
:
200
,
previewShow
:
!
1
,
resize
:
!
0
}),
$
(
"
#articleThumbnailBtn
"
).
click
(
function
(){
$
.
ajax
({
url
:
Label
.
servePath
+
"
/console/thumbs?n=1&w=768&h=432
"
,
type
:
"
GET
"
,
cache
:
!
1
,
success
:
function
(
t
,
e
){
t
.
sc
?
$
(
"
#articleThumbnailBtn
"
).
prev
().
css
(
"
background-image
"
,
"
url(
"
+
t
.
data
[
0
]
+
"
)
"
):
$
(
"
#loadMsg
"
).
text
(
t
.
msg
)}})}).
click
()},
validate
:
function
(){
var
t
=
admin
.
editors
.
articleEditor
.
getContent
();
if
(
""
===
$
(
"
#title
"
).
val
().
replace
(
/
\s
/g
,
""
))
$
(
"
#tipMsg
"
).
text
(
Label
.
titleEmptyLabel
),
$
(
"
#title
"
).
focus
().
val
(
""
);
else
{
if
(
""
!==
t
.
replace
(
/
\s
/g
,
""
))
return
!
0
;
$
(
"
#tipMsg
"
).
text
(
Label
.
contentEmptyLabel
)}
return
!
1
},
unPublish
:
function
(){
var
i
=
this
;
i
.
_addDisabled
(),
$
.
ajax
({
url
:
Label
.
servePath
+
"
/console/article/unpublish/
"
+
admin
.
article
.
status
.
id
,
type
:
"
PUT
"
,
cache
:
!
1
,
success
:
function
(
t
,
e
){
$
(
"
#tipMsg
"
).
text
(
t
.
msg
),
t
.
sc
&&
(
admin
.
selectTab
(
"
article/draft-list
"
),
admin
.
article
.
status
.
id
=
void
0
,
admin
.
article
.
isConfirm
=!
1
)},
complete
:
function
(
t
,
e
){
i
.
_removeDisabled
(),
$
(
"
#loadMsg
"
).
text
(
""
)}})},
trimUniqueArray
:
function
(
t
){
for
(
var
e
=
(
t
=
t
.
toString
()).
split
(
"
,
"
),
i
=
0
;
i
<
e
.
length
;
i
++
)
e
[
i
]
=
e
[
i
].
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
),
""
===
e
[
i
]
&&
(
e
.
splice
(
i
,
1
),
i
--
);
return
$
.
unique
(
e
).
toString
()},
prePost
:
function
(){
if
(
$
(
"
#loadMsg
"
).
text
(
Label
.
loadingLabel
),
admin
.
article
.
content
=
""
,
admin
.
editors
.
articleEditor
.
getContent
){
var
t
=
admin
.
editors
.
articleEditor
.
getContent
();
"
#article/article
"
===
window
.
location
.
hash
&&
""
!==
t
.
replace
(
/
\s
/g
,
""
)
&&
confirm
(
Label
.
editorPostLabel
)
&&
admin
.
article
.
clear
(),
$
(
"
#tipMsg
"
).
text
(
""
),
$
(
"
#loadMsg
"
).
text
(
""
)}},
_addDisabled
:
function
(){
$
(
"
#unSubmitArticle
"
).
attr
(
"
disabled
"
,
"
disabled
"
),
$
(
"
#saveArticle
"
).
attr
(
"
disabled
"
,
"
disabled
"
),
$
(
"
#submitArticle
"
).
attr
(
"
disabled
"
,
"
disabled
"
)},
_removeDisabled
:
function
(){
$
(
"
#unSubmitArticle
"
).
removeAttr
(
"
disabled
"
),
$
(
"
#saveArticle
"
).
removeAttr
(
"
disabled
"
),
$
(
"
#submitArticle
"
).
removeAttr
(
"
disabled
"
)}},
admin
.
register
.
article
=
{
obj
:
admin
.
article
,
init
:
admin
.
article
.
init
,
refresh
:
function
(){
admin
.
editors
.
abstractEditor
.
setContent
(
""
),
admin
.
editors
.
articleEditor
.
setContent
(
""
),
$
(
"
#loadMsg
"
).
text
(
""
),
$
(
"
#tipMsg
"
).
text
(
Label
.
uploadMsg
)}};
admin
.
comment
=
{
open
:
function
(
e
,
t
){
this
.
getList
(
e
,
t
),
$
(
"
#
"
+
t
+
"
Comments
"
).
dialog
(
"
open
"
)},
getList
:
function
(
l
,
c
){
$
(
"
#loadMsg
"
).
text
(
Label
.
loadingLabel
),
$
(
"
#tipMsg
"
).
text
(
""
),
$
(
"
#
"
+
c
+
"
Comments
"
).
html
(
""
);
var
e
=
"
article
"
;
"
page
"
===
c
&&
(
e
=
"
page
"
),
$
.
ajax
({
url
:
Label
.
servePath
+
"
/console/comments/
"
+
e
+
"
/
"
+
l
,
type
:
"
GET
"
,
cache
:
!
1
,
success
:
function
(
e
,
t
){
if
(
$
(
"
#tipMsg
"
).
text
(
e
.
msg
),
e
.
sc
){
for
(
var
a
=
e
.
comments
,
n
=
""
,
m
=
0
;
m
<
a
.
length
;
m
++
){
var
s
=
"
<a target='_blank' href='
"
+
a
[
m
].
commentURL
+
"
'>
"
,
o
=
a
[
m
].
commentContent
;
"
http://
"
===
a
[
m
].
commentURL
&&
(
s
=
"
<a target='_blank'>
"
),
n
+=
"
<div class='comment-title'><span class='fn__left'>
"
+
s
+
a
[
m
].
commentName
+
"
</a>
"
,
a
[
m
].
commentOriginalCommentName
&&
(
n
+=
"
@
"
+
a
[
m
].
commentOriginalCommentName
),
n
+=
"
</span><a title='
"
+
Label
.
removeLabel
+
"
' class='fn__right fn__pointer' href=
\"
javascript:admin.comment.del('
"
+
a
[
m
].
oId
+
"
', '
"
+
c
+
"
', '
"
+
l
+
"
')
\"
>
"
+
Label
.
removeLabel
+
"
</a><span class='fn__right'>
"
+
$
.
bowknot
.
getDate
(
a
[
m
].
commentTime
)
+
"
</span><div class='fn__clear'></div></div><div class='vditor-reset'>
"
+
o
+
"
</div>
"
}
""
===
n
&&
(
n
=
Label
.
noCommentLabel
),
$
(
"
#
"
+
c
+
"
Comments
"
).
html
(
n
),
Util
.
parseMarkdown
(),
Util
.
parseLanguage
(),
$
(
"
#loadMsg
"
).
text
(
""
)}
else
$
(
"
#loadMsg
"
).
text
(
""
)}})},
del
:
function
(
e
,
a
,
n
){
if
(
confirm
(
Label
.
confirmRemoveLabel
+
Label
.
commentLabel
+
"
?
"
)){
$
(
"
#loadMsg
"
).
text
(
Label
.
loadingLabel
);
var
t
=
"
article
"
;
"
page
"
===
a
&&
(
t
=
"
page
"
),
$
.
ajax
({
url
:
Label
.
servePath
+
"
/console/
"
+
t
+
"
/comment/
"
+
e
,
type
:
"
DELETE
"
,
cache
:
!
1
,
success
:
function
(
e
,
t
){
$
(
"
#tipMsg
"
).
text
(
e
.
msg
),
e
.
sc
&&
admin
.
comment
.
getList
(
n
,
a
),
$
(
"
#loadMsg
"
).
text
(
""
)}})}}};
...
...
src/main/webapp/js/page.js
View file @
6b3ef233
...
...
@@ -20,7 +20,7 @@
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.3.0.0, Jun
e
1, 2019
* @version 2.3.0.0, Jun 1, 2019
*/
var
Page
=
function
(
tips
)
{
this
.
currentCommentId
=
''
...
...
@@ -397,4 +397,4 @@ $.extend(Page.prototype, {
Util
.
parseLanguage
()
window
.
location
.
hash
=
'
#comments
'
},
})
\ No newline at end of file
})
src/main/webapp/js/page.min.js
View file @
6b3ef233
var
Page
=
function
(
t
){
this
.
currentCommentId
=
""
,
this
.
tips
=
t
};
$
.
extend
(
Page
.
prototype
,{
share
:
function
(){
var
t
=
$
(
"
.article__share
"
);
if
(
0
!==
t
.
length
){
var
e
=
t
.
find
(
"
.item__qr
"
),
o
=
t
.
data
(
"
url
"
),
i
=
t
.
data
(
"
avatar
"
),
n
=
encodeURIComponent
(
t
.
data
(
"
title
"
)
+
"
-
"
+
t
.
data
(
"
blogtitle
"
)),
r
=
encodeURIComponent
(
o
),
a
=
{};
a
.
tencent
=
"
http://share.v.t.qq.com/index.php?c=share&a=index&title=
"
+
n
+
"
&url=
"
+
r
+
"
&pic=
"
+
i
,
a
.
weibo
=
"
http://v.t.sina.com.cn/share/share.php?title=
"
+
n
+
"
&url=
"
+
r
+
"
&pic=
"
+
i
,
a
.
qqz
=
"
https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=
"
+
r
+
"
&sharesource=qzone&title=
"
+
n
+
"
&pics=
"
+
i
,
a
.
twitter
=
"
https://twitter.com/intent/tweet?status=
"
+
n
+
"
"
+
r
,
t
.
find
(
"
span
"
).
click
(
function
(){
var
t
=
$
(
this
).
data
(
"
type
"
);
if
(
t
)
return
"
wechat
"
===
t
?(
0
===
e
.
find
(
"
canvas
"
).
length
?(
Util
.
addScript
(
Label
.
staticServePath
+
"
/js/lib/jquery.qrcode.min.js
"
,
"
qrcodeScript
"
),
e
.
qrcode
({
width
:
128
,
height
:
128
,
text
:
o
})):
e
.
slideToggle
(),
!
1
):
void
window
.
open
(
a
[
t
],
"
_blank
"
,
"
top=100,left=200,width=648,height=618
"
)})}},
load
:
function
(){
var
t
=
this
;
$
(
"
#comment
"
).
click
(
function
(){
t
.
toggleEditor
()}).
attr
(
"
readonly
"
,
"
readonly
"
),
$
(
"
#soloEditorCancel
"
).
click
(
function
(){
t
.
toggleEditor
()}),
$
(
"
#soloEditorAdd
"
).
click
(
function
(){
t
.
submitComment
()})},
toggleEditor
:
function
(
t
,
e
){
var
o
=
$
(
"
#soloEditor
"
);
if
(
0
!==
o
.
length
){
if
(
!
$
(
"
#soloEditorComment
"
).
hasClass
(
"
vditor
"
)){
Util
.
addScript
(
"
https://cdn.jsdelivr.net/npm/vditor@1.3.5/dist/index.min.js
"
,
"
vditorScript
"
),
window
.
vditor
=
new
Vditor
(
"
soloEditorComment
"
,{
placeholder
:
this
.
tips
.
commentContentCannotEmptyLabel
,
height
:
180
,
tab
:
"
\t
"
,
hint
:{
emojiPath
:
Label
.
staticServePath
+
"
/js/lib/emojify.js-1.1.0/images/basic
"
},
esc
:
function
(){
$
(
"
#soloEditorCancel
"
).
click
()},
ctrlEnter
:
function
(){
$
(
"
#soloEditorAdd
"
).
click
()},
preview
:{
delay
:
500
,
show
:
!
1
,
url
:
Label
.
servePath
+
"
/console/markdown/2html
"
,
hljs
:{
enable
:
!
0
,
style
:
Label
.
hljsStyle
},
parse
:
function
(
t
){
"
none
"
!==
t
.
style
.
display
&&
Util
.
parseLanguage
()}},
counter
:
500
,
resize
:{
enable
:
!
0
,
position
:
"
top
"
,
after
:
function
(){
$
(
"
body
"
).
css
(
"
padding-bottom
"
,
$
(
"
#soloEditor
"
).
outerHeight
())}},
lang
:
Label
.
langLabel
,
toolbar
:[
"
emoji
"
,
"
headings
"
,
"
bold
"
,
"
italic
"
,
"
strike
"
,
"
|
"
,
"
line
"
,
"
quote
"
,
"
|
"
,
"
list
"
,
"
ordered-list
"
,
"
check
"
,
"
|
"
,
"
code
"
,
"
inline-code
"
,
"
|
"
,
"
undo
"
,
"
redo
"
,
"
|
"
,
"
link
"
,
"
table
"
,
"
|
"
,
"
preview
"
,
"
fullscreen
"
,
"
info
"
,
"
help
"
]}),
vditor
.
focus
()}
"
0px
"
===
$
(
"
body
"
).
css
(
"
padding-bottom
"
)
||
t
?(
$
(
"
#soloEditorError
"
).
text
(
""
),
o
.
css
({
bottom
:
"
0
"
,
opacity
:
1
}),
$
(
"
body
"
).
css
(
"
padding-bottom
"
,
"
238px
"
),
this
.
currentCommentId
=
t
,
$
(
"
#soloEditorReplyTarget
"
).
text
(
e
?
"
@
"
+
e
:
""
),
"
undefined
"
!=
typeof
vditor
&&
vditor
.
focus
()):(
o
.
css
({
bottom
:
"
-300px
"
,
opacity
:
0
}),
$
(
"
body
"
).
css
(
"
padding-bottom
"
,
0
))}
else
location
.
href
=
Label
.
servePath
+
"
/start
"
},
loadRandomArticles
:
function
(
s
){
var
c
=
this
.
tips
.
randomArticles1Label
;
$
.
ajax
({
url
:
Label
.
servePath
+
"
/articles/random
"
,
type
:
"
POST
"
,
success
:
function
(
t
,
e
){
var
o
=
t
.
randomArticles
;
if
(
o
&&
0
!==
o
.
length
){
for
(
var
i
=
""
,
n
=
0
;
n
<
o
.
length
;
n
++
){
var
r
=
o
[
n
],
a
=
r
.
articleTitle
;
i
+=
"
<li><a rel='nofollow' title='
"
+
a
+
"
' href='
"
+
Label
.
servePath
+
r
.
articlePermalink
+
"
'>
"
+
a
+
"
</a></li>
"
}
var
l
=
(
s
||
"
<h4>
"
+
c
+
"
</h4>
"
)
+
"
<ul>
"
+
i
+
"
</ul>
"
;
$
(
"
#randomArticles
"
).
append
(
l
)}
else
$
(
"
#randomArticles
"
).
remove
()}})},
loadRelevantArticles
:
function
(
t
,
s
){
$
.
ajax
({
url
:
Label
.
servePath
+
"
/article/id/
"
+
t
+
"
/relevant/articles
"
,
type
:
"
GET
"
,
success
:
function
(
t
,
e
){
var
o
=
t
.
relevantArticles
;
if
(
o
&&
0
!==
o
.
length
){
for
(
var
i
=
""
,
n
=
0
;
n
<
o
.
length
;
n
++
){
var
r
=
o
[
n
],
a
=
r
.
articleTitle
;
i
+=
"
<li><a rel='nofollow' title='
"
+
a
+
"
' href='
"
+
Label
.
servePath
+
r
.
articlePermalink
+
"
'>
"
+
a
+
"
</a></li>
"
}
var
l
=
s
+
"
<ul>
"
+
i
+
"
</ul>
"
;
$
(
"
#relevantArticles
"
).
append
(
l
)}
else
$
(
"
#relevantArticles
"
).
remove
()},
error
:
function
(){
$
(
"
#relevantArticles
"
).
remove
()}})},
loadExternalRelevantArticles
:
function
(
t
,
s
){
var
c
=
this
.
tips
;
try
{
$
.
ajax
({
url
:
"
https://rhythm.b3log.org/get-articles-by-tags.do?tags=
"
+
t
+
"
&blogHost=
"
+
c
.
blogHost
+
"
&paginationPageSize=
"
+
c
.
externalRelevantArticlesDisplayCount
,
type
:
"
GET
"
,
cache
:
!
0
,
dataType
:
"
jsonp
"
,
error
:
function
(){
$
(
"
#externalRelevantArticles
"
).
remove
()},
success
:
function
(
t
,
e
){
var
o
=
t
.
articles
;
if
(
o
&&
0
!==
o
.
length
){
for
(
var
i
=
""
,
n
=
0
;
n
<
o
.
length
;
n
++
){
var
r
=
o
[
n
],
a
=
r
.
articleTitle
;
i
+=
"
<li><a rel='nofollow' title='
"
+
a
+
"
' target='_blank' href='
"
+
r
.
articlePermalink
+
"
'>
"
+
a
+
"
</a></li>
"
}
var
l
=
(
s
||
"
<h4>
"
+
c
.
externalRelevantArticles1Label
+
"
</h4>
"
)
+
"
<ul>
"
+
i
+
"
</ul>
"
;
$
(
"
#externalRelevantArticles
"
).
append
(
l
)}
else
$
(
"
#externalRelevantArticles
"
).
remove
()}})}
catch
(
t
){}},
submitComment
:
function
(){
var
e
=
this
,
t
=
this
.
tips
;
if
(
1
<
vditor
.
getValue
().
length
&&
vditor
.
getValue
().
length
<
500
){
$
(
"
#soloEditorAdd
"
).
attr
(
"
disabled
"
,
"
disabled
"
);
var
o
=
{
oId
:
t
.
oId
,
commentContent
:
vditor
.
getValue
()};
this
.
currentCommentId
&&
(
o
.
commentOriginalCommentId
=
this
.
currentCommentId
),
$
.
ajax
({
type
:
"
POST
"
,
url
:
Label
.
servePath
+
"
/article/comments
"
,
cache
:
!
1
,
contentType
:
"
application/json
"
,
data
:
JSON
.
stringify
(
o
),
success
:
function
(
t
){
$
(
"
#soloEditorAdd
"
).
removeAttr
(
"
disabled
"
),
t
.
sc
?(
e
.
toggleEditor
(),
vditor
.
setValue
(
""
),
e
.
addCommentAjax
(
t
.
cmtTpl
)):
$
(
"
#soloEditorError
"
).
html
(
t
.
msg
)}})}
else
$
(
"
#soloEditorError
"
).
text
(
e
.
tips
.
commentContentCannotEmptyLabel
)},
addReplyForm
:
function
(
t
,
e
){
this
.
currentCommentId
=
t
,
this
.
toggleEditor
(
t
,
e
)},
hideComment
:
function
(
t
){
$
(
"
#commentRef
"
+
t
).
hide
()},
showComment
:
function
(
t
,
e
,
o
,
i
){
var
n
=
parseInt
(
$
(
t
).
position
().
top
);
if
(
i
&&
(
n
=
parseInt
(
$
(
t
).
parents
(
i
).
position
().
top
)),
0
<
$
(
"
#commentRef
"
+
e
).
length
)
$
(
"
#commentRef
"
+
e
).
show
().
css
(
"
top
"
,
n
+
o
+
"
px
"
);
else
{
var
r
=
$
(
"
#
"
+
e
).
clone
();
r
.
addClass
(
"
comment-body-ref
"
).
attr
(
"
id
"
,
"
commentRef
"
+
e
),
r
.
find
(
"
#replyForm
"
).
remove
(),
$
(
"
#comments
"
).
append
(
r
),
$
(
"
#commentRef
"
+
e
).
css
(
"
top
"
,
n
+
o
+
"
px
"
)}},
addCommentAjax
:
function
(
t
){
0
<
$
(
"
#comments
"
).
children
().
length
?
$
(
$
(
"
#comments
"
).
children
()[
0
]).
before
(
t
):
$
(
"
#comments
"
).
html
(
t
),
Util
.
parseMarkdown
(),
Util
.
parseLanguage
(),
window
.
location
.
hash
=
"
#comments
"
}});
\ No newline at end of file
var
Page
=
function
(
t
){
this
.
currentCommentId
=
""
,
this
.
tips
=
t
};
$
.
extend
(
Page
.
prototype
,{
share
:
function
(){
var
t
=
$
(
"
.article__share
"
);
if
(
0
!==
t
.
length
){
var
e
=
t
.
find
(
"
.item__qr
"
),
o
=
t
.
data
(
"
url
"
),
i
=
t
.
data
(
"
avatar
"
),
n
=
encodeURIComponent
(
t
.
data
(
"
title
"
)
+
"
-
"
+
t
.
data
(
"
blogtitle
"
)),
r
=
encodeURIComponent
(
o
),
a
=
{};
a
.
tencent
=
"
http://share.v.t.qq.com/index.php?c=share&a=index&title=
"
+
n
+
"
&url=
"
+
r
+
"
&pic=
"
+
i
,
a
.
weibo
=
"
http://v.t.sina.com.cn/share/share.php?title=
"
+
n
+
"
&url=
"
+
r
+
"
&pic=
"
+
i
,
a
.
qqz
=
"
https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=
"
+
r
+
"
&sharesource=qzone&title=
"
+
n
+
"
&pics=
"
+
i
,
a
.
twitter
=
"
https://twitter.com/intent/tweet?status=
"
+
n
+
"
"
+
r
,
t
.
find
(
"
span
"
).
click
(
function
(){
var
t
=
$
(
this
).
data
(
"
type
"
);
if
(
t
)
return
"
wechat
"
===
t
?(
0
===
e
.
find
(
"
canvas
"
).
length
?(
Util
.
addScript
(
Label
.
staticServePath
+
"
/js/lib/jquery.qrcode.min.js
"
,
"
qrcodeScript
"
),
e
.
qrcode
({
width
:
128
,
height
:
128
,
text
:
o
})):
e
.
slideToggle
(),
!
1
):
void
window
.
open
(
a
[
t
],
"
_blank
"
,
"
top=100,left=200,width=648,height=618
"
)})}},
load
:
function
(){
var
t
=
this
;
$
(
"
#comment
"
).
click
(
function
(){
t
.
toggleEditor
()}).
attr
(
"
readonly
"
,
"
readonly
"
),
$
(
"
#soloEditorCancel
"
).
click
(
function
(){
t
.
toggleEditor
()}),
$
(
"
#soloEditorAdd
"
).
click
(
function
(){
t
.
submitComment
()})},
toggleEditor
:
function
(
t
,
e
){
var
o
=
$
(
"
#soloEditor
"
);
if
(
0
!==
o
.
length
){
if
(
!
$
(
"
#soloEditorComment
"
).
hasClass
(
"
vditor
"
)){
Util
.
addScript
(
"
https://cdn.jsdelivr.net/npm/vditor@1.3.5/dist/index.min.js
"
,
"
vditorScript
"
),
window
.
vditor
=
new
Vditor
(
"
soloEditorComment
"
,{
placeholder
:
this
.
tips
.
commentContentCannotEmptyLabel
,
height
:
180
,
tab
:
"
\t
"
,
hint
:{
emojiPath
:
Label
.
staticServePath
+
"
/images/emoji
"
},
esc
:
function
(){
$
(
"
#soloEditorCancel
"
).
click
()},
ctrlEnter
:
function
(){
$
(
"
#soloEditorAdd
"
).
click
()},
preview
:{
delay
:
500
,
show
:
!
1
,
url
:
Label
.
servePath
+
"
/console/markdown/2html
"
,
hljs
:{
enable
:
!
0
,
style
:
Label
.
hljsStyle
},
parse
:
function
(
t
){
"
none
"
!==
t
.
style
.
display
&&
Util
.
parseLanguage
()}},
counter
:
500
,
resize
:{
enable
:
!
0
,
position
:
"
top
"
,
after
:
function
(){
$
(
"
body
"
).
css
(
"
padding-bottom
"
,
$
(
"
#soloEditor
"
).
outerHeight
())}},
lang
:
Label
.
langLabel
,
toolbar
:[
"
emoji
"
,
"
headings
"
,
"
bold
"
,
"
italic
"
,
"
strike
"
,
"
|
"
,
"
line
"
,
"
quote
"
,
"
|
"
,
"
list
"
,
"
ordered-list
"
,
"
check
"
,
"
|
"
,
"
code
"
,
"
inline-code
"
,
"
|
"
,
"
undo
"
,
"
redo
"
,
"
|
"
,
"
link
"
,
"
table
"
,
"
|
"
,
"
preview
"
,
"
fullscreen
"
,
"
info
"
,
"
help
"
]}),
vditor
.
focus
()}
"
0px
"
===
$
(
"
body
"
).
css
(
"
padding-bottom
"
)
||
t
?(
$
(
"
#soloEditorError
"
).
text
(
""
),
o
.
css
({
bottom
:
"
0
"
,
opacity
:
1
}),
$
(
"
body
"
).
css
(
"
padding-bottom
"
,
"
238px
"
),
this
.
currentCommentId
=
t
,
$
(
"
#soloEditorReplyTarget
"
).
text
(
e
?
"
@
"
+
e
:
""
),
"
undefined
"
!=
typeof
vditor
&&
vditor
.
focus
()):(
o
.
css
({
bottom
:
"
-300px
"
,
opacity
:
0
}),
$
(
"
body
"
).
css
(
"
padding-bottom
"
,
0
))}
else
location
.
href
=
Label
.
servePath
+
"
/start
"
},
loadRandomArticles
:
function
(
s
){
var
c
=
this
.
tips
.
randomArticles1Label
;
$
.
ajax
({
url
:
Label
.
servePath
+
"
/articles/random
"
,
type
:
"
POST
"
,
success
:
function
(
t
,
e
){
var
o
=
t
.
randomArticles
;
if
(
o
&&
0
!==
o
.
length
){
for
(
var
i
=
""
,
n
=
0
;
n
<
o
.
length
;
n
++
){
var
r
=
o
[
n
],
a
=
r
.
articleTitle
;
i
+=
"
<li><a rel='nofollow' title='
"
+
a
+
"
' href='
"
+
Label
.
servePath
+
r
.
articlePermalink
+
"
'>
"
+
a
+
"
</a></li>
"
}
var
l
=
(
s
||
"
<h4>
"
+
c
+
"
</h4>
"
)
+
"
<ul>
"
+
i
+
"
</ul>
"
;
$
(
"
#randomArticles
"
).
append
(
l
)}
else
$
(
"
#randomArticles
"
).
remove
()}})},
loadRelevantArticles
:
function
(
t
,
s
){
$
.
ajax
({
url
:
Label
.
servePath
+
"
/article/id/
"
+
t
+
"
/relevant/articles
"
,
type
:
"
GET
"
,
success
:
function
(
t
,
e
){
var
o
=
t
.
relevantArticles
;
if
(
o
&&
0
!==
o
.
length
){
for
(
var
i
=
""
,
n
=
0
;
n
<
o
.
length
;
n
++
){
var
r
=
o
[
n
],
a
=
r
.
articleTitle
;
i
+=
"
<li><a rel='nofollow' title='
"
+
a
+
"
' href='
"
+
Label
.
servePath
+
r
.
articlePermalink
+
"
'>
"
+
a
+
"
</a></li>
"
}
var
l
=
s
+
"
<ul>
"
+
i
+
"
</ul>
"
;
$
(
"
#relevantArticles
"
).
append
(
l
)}
else
$
(
"
#relevantArticles
"
).
remove
()},
error
:
function
(){
$
(
"
#relevantArticles
"
).
remove
()}})},
loadExternalRelevantArticles
:
function
(
t
,
s
){
var
c
=
this
.
tips
;
try
{
$
.
ajax
({
url
:
"
https://rhythm.b3log.org/get-articles-by-tags.do?tags=
"
+
t
+
"
&blogHost=
"
+
c
.
blogHost
+
"
&paginationPageSize=
"
+
c
.
externalRelevantArticlesDisplayCount
,
type
:
"
GET
"
,
cache
:
!
0
,
dataType
:
"
jsonp
"
,
error
:
function
(){
$
(
"
#externalRelevantArticles
"
).
remove
()},
success
:
function
(
t
,
e
){
var
o
=
t
.
articles
;
if
(
o
&&
0
!==
o
.
length
){
for
(
var
i
=
""
,
n
=
0
;
n
<
o
.
length
;
n
++
){
var
r
=
o
[
n
],
a
=
r
.
articleTitle
;
i
+=
"
<li><a rel='nofollow' title='
"
+
a
+
"
' target='_blank' href='
"
+
r
.
articlePermalink
+
"
'>
"
+
a
+
"
</a></li>
"
}
var
l
=
(
s
||
"
<h4>
"
+
c
.
externalRelevantArticles1Label
+
"
</h4>
"
)
+
"
<ul>
"
+
i
+
"
</ul>
"
;
$
(
"
#externalRelevantArticles
"
).
append
(
l
)}
else
$
(
"
#externalRelevantArticles
"
).
remove
()}})}
catch
(
t
){}},
submitComment
:
function
(){
var
e
=
this
,
t
=
this
.
tips
;
if
(
1
<
vditor
.
getValue
().
length
&&
vditor
.
getValue
().
length
<
500
){
$
(
"
#soloEditorAdd
"
).
attr
(
"
disabled
"
,
"
disabled
"
);
var
o
=
{
oId
:
t
.
oId
,
commentContent
:
vditor
.
getValue
()};
this
.
currentCommentId
&&
(
o
.
commentOriginalCommentId
=
this
.
currentCommentId
),
$
.
ajax
({
type
:
"
POST
"
,
url
:
Label
.
servePath
+
"
/article/comments
"
,
cache
:
!
1
,
contentType
:
"
application/json
"
,
data
:
JSON
.
stringify
(
o
),
success
:
function
(
t
){
$
(
"
#soloEditorAdd
"
).
removeAttr
(
"
disabled
"
),
t
.
sc
?(
e
.
toggleEditor
(),
vditor
.
setValue
(
""
),
e
.
addCommentAjax
(
t
.
cmtTpl
)):
$
(
"
#soloEditorError
"
).
html
(
t
.
msg
)}})}
else
$
(
"
#soloEditorError
"
).
text
(
e
.
tips
.
commentContentCannotEmptyLabel
)},
addReplyForm
:
function
(
t
,
e
){
this
.
currentCommentId
=
t
,
this
.
toggleEditor
(
t
,
e
)},
hideComment
:
function
(
t
){
$
(
"
#commentRef
"
+
t
).
hide
()},
showComment
:
function
(
t
,
e
,
o
,
i
){
var
n
=
parseInt
(
$
(
t
).
position
().
top
);
if
(
i
&&
(
n
=
parseInt
(
$
(
t
).
parents
(
i
).
position
().
top
)),
0
<
$
(
"
#commentRef
"
+
e
).
length
)
$
(
"
#commentRef
"
+
e
).
show
().
css
(
"
top
"
,
n
+
o
+
"
px
"
);
else
{
var
r
=
$
(
"
#
"
+
e
).
clone
();
r
.
addClass
(
"
comment-body-ref
"
).
attr
(
"
id
"
,
"
commentRef
"
+
e
),
r
.
find
(
"
#replyForm
"
).
remove
(),
$
(
"
#comments
"
).
append
(
r
),
$
(
"
#commentRef
"
+
e
).
css
(
"
top
"
,
n
+
o
+
"
px
"
)}},
addCommentAjax
:
function
(
t
){
0
<
$
(
"
#comments
"
).
children
().
length
?
$
(
$
(
"
#comments
"
).
children
()[
0
]).
before
(
t
):
$
(
"
#comments
"
).
html
(
t
),
Util
.
parseMarkdown
(),
Util
.
parseLanguage
(),
window
.
location
.
hash
=
"
#comments
"
}});
\ No newline at end of file
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