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
e3088d67
Commit
e3088d67
authored
Nov 29, 2012
by
Vanessa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed #129, fixed #130
parent
c53b3170
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
851 additions
and
820 deletions
+851
-820
war/src/main/webapp/js/admin/editorCodeMirror.js
war/src/main/webapp/js/admin/editorCodeMirror.js
+1
-2
war/src/main/webapp/js/admin/editorKindEditor.js
war/src/main/webapp/js/admin/editorKindEditor.js
+1
-1
war/src/main/webapp/js/page.js
war/src/main/webapp/js/page.js
+725
-720
war/src/main/webapp/skins/mobile/themes/core/core.js
war/src/main/webapp/skins/mobile/themes/core/core.js
+123
-96
war/src/main/webapp/top-bar.ftl
war/src/main/webapp/top-bar.ftl
+1
-1
No files found.
war/src/main/webapp/js/admin/editorCodeMirror.js
View file @
e3088d67
...
@@ -41,8 +41,7 @@ admin.editors.CodeMirror = {
...
@@ -41,8 +41,7 @@ admin.editors.CodeMirror = {
"
<div class='clear'></div>
"
+
"
<div class='clear'></div>
"
+
"
<div class='markdown-preview-main none'></div>
"
+
"
<div class='markdown-preview-main none'></div>
"
+
"
<div class='markdown-help-main'>
"
+
Label
.
markdownHelpLabel
+
"
</div>
"
"
<div class='markdown-help-main'>
"
+
Label
.
markdownHelpLabel
+
"
</div>
"
"
</div>
"
+
+
"
</div><div class='clear'></div>
"
;
"
<div class='clear'></div>
"
;
}
}
$
(
"
#
"
+
conf
.
id
).
after
(
previewHTML
);
$
(
"
#
"
+
conf
.
id
).
after
(
previewHTML
);
...
...
war/src/main/webapp/js/admin/editorKindEditor.js
View file @
e3088d67
...
@@ -39,7 +39,7 @@ admin.editors.KindEditor = {
...
@@ -39,7 +39,7 @@ admin.editors.KindEditor = {
langType
:
language
,
langType
:
language
,
resizeType
:
0
,
resizeType
:
0
,
items
:
[
"
bold
"
,
"
italic
"
,
"
underline
"
,
"
strikethrough
"
,
"
|
"
,
"
undo
"
,
"
redo
"
,
"
|
"
,
items
:
[
"
bold
"
,
"
italic
"
,
"
underline
"
,
"
strikethrough
"
,
"
|
"
,
"
undo
"
,
"
redo
"
,
"
|
"
,
"
insertunorderedlist
"
,
"
insertorderedlist
"
,
"
insertunorderedlist
"
,
"
insertorderedlist
"
,
"
|
"
,
"
source
"
]
]
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
...
war/src/main/webapp/js/page.js
View file @
e3088d67
/*
/*
* Copyright (c) 2009, 2010, 2011, 2012, B3log Team
* Copyright (c) 2009, 2010, 2011, 2012, 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.
*/
*/
/**
/**
* @fileoverview Page util, load heighlight and process comment.
* @fileoverview Page util, load heighlight and process 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.3.1, Jul 5, 2012
* @version 1.0.3.1, Jul 5, 2012
*/
*/
var
Page
=
function
(
tips
)
{
var
Page
=
function
(
tips
)
{
this
.
currentCommentId
=
""
;
this
.
currentCommentId
=
""
;
this
.
tips
=
tips
;
this
.
tips
=
tips
;
};
};
$
.
extend
(
Page
.
prototype
,
{
$
.
extend
(
Page
.
prototype
,
{
/*
/*
* @description 评论时点击表情,在评论内容中插入相关代码
* @description 评论时点击表情,在评论内容中插入相关代码
* @param {String} name 用于区别回复评论还是对文章的评论
* @param {String} name 用于区别回复评论还是对文章的评论
*/
*/
insertEmotions
:
function
(
name
)
{
insertEmotions
:
function
(
name
)
{
var
_it
=
this
;
var
_it
=
this
;
if
(
name
===
undefined
)
{
if
(
name
===
undefined
)
{
name
=
""
;
name
=
""
;
}
}
$
(
"
#emotions
"
+
name
+
"
span
"
).
click
(
function
()
{
$
(
"
#emotions
"
+
name
+
"
span
"
).
click
(
function
()
{
var
$comment
=
$
(
"
#comment
"
+
name
);
var
$comment
=
$
(
"
#comment
"
+
name
);
var
endPosition
=
_it
.
_getCursorEndPosition
(
$comment
[
0
]);
var
endPosition
=
_it
.
_getCursorEndPosition
(
$comment
[
0
]);
var
key
=
"
[
"
+
this
.
className
+
"
]
"
,
var
key
=
"
[
"
+
this
.
className
+
"
]
"
,
textValue
=
$comment
[
0
].
value
;
textValue
=
$comment
[
0
].
value
;
textValue
=
textValue
.
substring
(
0
,
endPosition
)
+
key
+
textValue
.
substring
(
endPosition
,
textValue
.
length
);
textValue
=
textValue
.
substring
(
0
,
endPosition
)
+
key
+
textValue
.
substring
(
endPosition
,
textValue
.
length
);
$
(
"
#comment
"
+
name
).
val
(
textValue
);
$
(
"
#comment
"
+
name
).
val
(
textValue
);
if
(
$
.
browser
.
msie
)
{
if
(
$
.
browser
.
msie
)
{
endPosition
-=
textValue
.
split
(
'
\n
'
).
length
-
1
;
endPosition
-=
textValue
.
split
(
'
\n
'
).
length
-
1
;
var
oR
=
$comment
[
0
].
createTextRange
();
var
oR
=
$comment
[
0
].
createTextRange
();
oR
.
collapse
(
true
);
oR
.
collapse
(
true
);
oR
.
moveStart
(
'
character
'
,
endPosition
+
6
);
oR
.
moveStart
(
'
character
'
,
endPosition
+
6
);
oR
.
select
();
oR
.
select
();
}
else
{
}
else
{
$comment
[
0
].
setSelectionRange
(
endPosition
+
6
,
endPosition
+
6
);
$comment
[
0
].
setSelectionRange
(
endPosition
+
6
,
endPosition
+
6
);
}
}
});
});
},
},
/**
/**
* @description 获取当前光标最后位置
* @description 获取当前光标最后位置
* @param {Dom} textarea 评论框对象
* @param {Dom} textarea 评论框对象
* @returns {Num} 光标位置
* @returns {Num} 光标位置
*/
*/
_getCursorEndPosition
:
function
(
textarea
)
{
_getCursorEndPosition
:
function
(
textarea
)
{
textarea
.
focus
();
textarea
.
focus
();
if
(
textarea
.
setSelectionRange
)
{
// W3C
if
(
textarea
.
setSelectionRange
)
{
// W3C
return
textarea
.
selectionEnd
;
return
textarea
.
selectionEnd
;
}
else
if
(
document
.
selection
)
{
// IE
}
else
if
(
document
.
selection
)
{
// IE
var
i
=
0
,
var
i
=
0
,
oS
=
document
.
selection
.
createRange
(),
oS
=
document
.
selection
.
createRange
(),
oR
=
document
.
body
.
createTextRange
();
oR
=
document
.
body
.
createTextRange
();
oR
.
moveToElementText
(
textarea
);
oR
.
moveToElementText
(
textarea
);
oS
.
getBookmark
();
oS
.
getBookmark
();
for
(
i
=
0
;
oR
.
compareEndPoints
(
'
StartToStart
'
,
oS
)
<
0
&&
oS
.
moveStart
(
"
character
"
,
-
1
)
!==
0
;
i
++
)
{
for
(
i
=
0
;
oR
.
compareEndPoints
(
'
StartToStart
'
,
oS
)
<
0
&&
oS
.
moveStart
(
"
character
"
,
-
1
)
!==
0
;
i
++
)
{
if
(
textarea
.
value
.
charAt
(
i
)
==
'
\n
'
)
{
if
(
textarea
.
value
.
charAt
(
i
)
==
'
\n
'
)
{
i
++
;
i
++
;
}
}
}
}
return
i
;
return
i
;
}
}
},
},
/*
/*
* @description 评论校验
* @description 评论校验
* @param {String} state 用于区别回复评论还是对文章的评论
* @param {String} state 用于区别回复评论还是对文章的评论
*/
*/
validateComment
:
function
(
state
)
{
validateComment
:
function
(
state
)
{
var
commentName
=
$
(
"
#commentName
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
),
var
commentName
=
$
(
"
#commentName
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
),
commenterContent
=
$
(
"
#comment
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
);
commenterContent
=
$
(
"
#comment
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
);
if
(
2
>
commentName
.
length
||
commentName
.
length
>
20
)
{
if
(
2
>
commentName
.
length
||
commentName
.
length
>
20
)
{
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
nameTooLongLabel
);
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
nameTooLongLabel
);
$
(
"
#commentName
"
+
state
).
focus
();
$
(
"
#commentName
"
+
state
).
focus
();
}
else
if
(
$
(
"
#commentEmail
"
+
state
).
val
().
replace
(
/
\s
/g
,
""
)
===
""
)
{
}
else
if
(
$
(
"
#commentEmail
"
+
state
).
val
().
replace
(
/
\s
/g
,
""
)
===
""
)
{
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
mailCannotEmptyLabel
);
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
mailCannotEmptyLabel
);
$
(
"
#commentEmail
"
+
state
).
focus
();
$
(
"
#commentEmail
"
+
state
).
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
(
$
(
"
#commentEmail
"
+
state
).
val
()))
{
}
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
(
$
(
"
#commentEmail
"
+
state
).
val
()))
{
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
mailInvalidLabel
);
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
mailInvalidLabel
);
$
(
"
#commentEmail
"
+
state
).
focus
();
$
(
"
#commentEmail
"
+
state
).
focus
();
}
else
if
(
2
>
commenterContent
.
length
||
commenterContent
.
length
>
500
)
{
}
else
if
(
2
>
commenterContent
.
length
||
commenterContent
.
length
>
500
)
{
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
commentContentCannotEmptyLabel
);
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
commentContentCannotEmptyLabel
);
$
(
"
#comment
"
+
state
).
focus
();
$
(
"
#comment
"
+
state
).
focus
();
}
else
if
(
$
(
"
#commentValidate
"
+
state
).
val
().
replace
(
/
\s
/g
,
""
)
===
""
)
{
}
else
if
(
!
$
(
"
#admin
"
).
data
(
"
login
"
)
&&
$
(
"
#commentValidate
"
+
state
).
val
().
replace
(
/
\s
/g
,
""
)
===
""
)
{
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
captchaCannotEmptyLabel
);
$
(
"
#commentErrorTip
"
+
state
).
html
(
this
.
tips
.
captchaCannotEmptyLabel
);
$
(
"
#commentValidate
"
+
state
).
focus
();
$
(
"
#commentValidate
"
+
state
).
focus
();
}
else
{
}
else
{
return
true
;
return
true
;
}
}
$
(
"
#commentErrorTip
"
+
state
).
show
();
$
(
"
#commentErrorTip
"
+
state
).
show
();
return
false
;
return
false
;
},
},
/*
/*
* @description 把评论中的标识替换为图片
* @description 把评论中的标识替换为图片
* @param {Dom} selector
* @param {Dom} selector
*/
*/
replaceCommentsEm
:
function
(
selector
)
{
replaceCommentsEm
:
function
(
selector
)
{
var
$commentContents
=
$
(
selector
);
var
$commentContents
=
$
(
selector
);
for
(
var
i
=
0
;
i
<
$commentContents
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
$commentContents
.
length
;
i
++
)
{
var
str
=
$commentContents
[
i
].
innerHTML
;
var
str
=
$commentContents
[
i
].
innerHTML
;
$commentContents
[
i
].
innerHTML
=
Util
.
replaceEmString
(
str
);
$commentContents
[
i
].
innerHTML
=
Util
.
replaceEmString
(
str
);
}
}
},
},
/*
/*
* @description 初始化 SyantaxHighlighter
* @description 初始化 SyantaxHighlighter
* @param {Array} languages 需要加载的语言
* @param {Array} languages 需要加载的语言
*/
*/
_initSyntaxHighlighter
:
function
(
languages
)
{
_initSyntaxHighlighter
:
function
(
languages
)
{
// load brush js
// load brush js
for
(
var
i
=
0
;
i
<
languages
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
languages
.
length
;
i
++
)
{
switch
(
languages
[
i
])
{
switch
(
languages
[
i
])
{
case
"
groovy
"
:
case
"
groovy
"
:
languages
[
i
]
=
'
groovy
'
+
languages
[
i
]
=
'
groovy
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushGroovy.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushGroovy.js
'
;
break
;
break
;
case
"
java
"
:
case
"
java
"
:
languages
[
i
]
=
'
java
'
+
languages
[
i
]
=
'
java
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushJava.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushJava.js
'
;
break
;
break
;
case
"
php
"
:
case
"
php
"
:
languages
[
i
]
=
'
php
'
+
languages
[
i
]
=
'
php
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushPhp.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushPhp.js
'
;
break
;
break
;
case
"
scala
"
:
case
"
scala
"
:
languages
[
i
]
=
'
scala
'
+
languages
[
i
]
=
'
scala
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushScala.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushScala.js
'
;
break
;
break
;
case
"
sql
"
:
case
"
sql
"
:
languages
[
i
]
=
'
sql
'
+
languages
[
i
]
=
'
sql
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushSql.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushSql.js
'
;
break
;
break
;
case
"
applescript
"
:
case
"
applescript
"
:
languages
[
i
]
=
'
applescript
'
+
languages
[
i
]
=
'
applescript
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushAppleScript.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushAppleScript.js
'
;
break
;
break
;
case
"
as3
"
:
case
"
as3
"
:
case
"
actionscript3
"
:
case
"
actionscript3
"
:
languages
[
i
]
=
'
actionscript3 as3
'
+
languages
[
i
]
=
'
actionscript3 as3
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushAS3.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushAS3.js
'
;
break
;
break
;
case
"
bash
"
:
case
"
bash
"
:
case
"
shell
"
:
case
"
shell
"
:
languages
[
i
]
=
'
bash shell
'
+
languages
[
i
]
=
'
bash shell
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushBash.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushBash.js
'
;
break
;
break
;
case
"
coldfusion
"
:
case
"
coldfusion
"
:
case
"
cf
"
:
case
"
cf
"
:
languages
[
i
]
=
'
coldfusion cf
'
+
languages
[
i
]
=
'
coldfusion cf
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushColdFusion.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushColdFusion.js
'
;
break
;
break
;
case
"
c#
"
:
case
"
c#
"
:
case
"
c-sharp
"
:
case
"
c-sharp
"
:
case
"
csharp
"
:
case
"
csharp
"
:
languages
[
i
]
=
'
c# c-sharp csharp
'
+
languages
[
i
]
=
'
c# c-sharp csharp
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushCSharp.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushCSharp.js
'
;
break
;
break
;
case
"
cpp
"
:
case
"
cpp
"
:
case
"
c
"
:
case
"
c
"
:
languages
[
i
]
=
'
cpp c
'
+
languages
[
i
]
=
'
cpp c
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushCpp.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushCpp.js
'
;
break
;
break
;
case
"
css
"
:
case
"
css
"
:
languages
[
i
]
=
'
css
'
+
languages
[
i
]
=
'
css
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushCss.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushCss.js
'
;
break
;
break
;
case
"
delphi
"
:
case
"
delphi
"
:
case
"
pascal
"
:
case
"
pascal
"
:
languages
[
i
]
=
'
delphi pascal
'
+
languages
[
i
]
=
'
delphi pascal
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushDelphi.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushDelphi.js
'
;
break
;
break
;
case
"
diff
"
:
case
"
diff
"
:
case
"
patch
"
:
case
"
patch
"
:
case
"
pas
"
:
case
"
pas
"
:
languages
[
i
]
=
'
diff patch pas
'
+
languages
[
i
]
=
'
diff patch pas
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushDiff.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushDiff.js
'
;
break
;
break
;
case
"
erl
"
:
case
"
erl
"
:
case
"
erlang
"
:
case
"
erlang
"
:
languages
[
i
]
=
'
erl erlang
'
+
languages
[
i
]
=
'
erl erlang
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushErlang.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushErlang.js
'
;
break
;
break
;
case
"
js
"
:
case
"
js
"
:
case
"
jscript
"
:
case
"
jscript
"
:
case
"
javascript
"
:
case
"
javascript
"
:
languages
[
i
]
=
'
js jscript javascript
'
+
languages
[
i
]
=
'
js jscript javascript
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushJScript.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushJScript.js
'
;
break
;
break
;
case
"
jfx
"
:
case
"
jfx
"
:
case
"
javafx
"
:
case
"
javafx
"
:
languages
[
i
]
=
'
jfx javafx
'
+
languages
[
i
]
=
'
jfx javafx
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushJavaFX.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushJavaFX.js
'
;
break
;
break
;
case
"
perl
"
:
case
"
perl
"
:
case
"
pl
"
:
case
"
pl
"
:
languages
[
i
]
=
'
perl pl
'
+
languages
[
i
]
=
'
perl pl
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushPerl.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushPerl.js
'
;
break
;
break
;
case
"
plain
"
:
case
"
plain
"
:
case
"
text
"
:
case
"
text
"
:
languages
[
i
]
=
'
text plain
'
+
languages
[
i
]
=
'
text plain
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushPlain.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushPlain.js
'
;
break
;
break
;
case
"
ps
"
:
case
"
ps
"
:
case
"
powershell
"
:
case
"
powershell
"
:
languages
[
i
]
=
'
ps powershell
'
+
languages
[
i
]
=
'
ps powershell
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushPowerShell.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushPowerShell.js
'
;
break
;
break
;
case
"
py
"
:
case
"
py
"
:
case
"
python
"
:
case
"
python
"
:
languages
[
i
]
=
'
py python
'
+
languages
[
i
]
=
'
py python
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushPython.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushPython.js
'
;
break
;
break
;
case
"
rails
"
:
case
"
rails
"
:
case
"
ror
"
:
case
"
ror
"
:
case
"
ruby
"
:
case
"
ruby
"
:
case
"
rb
"
:
case
"
rb
"
:
languages
[
i
]
=
'
ruby rails ror rb
'
+
languages
[
i
]
=
'
ruby rails ror rb
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushRuby.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushRuby.js
'
;
break
;
break
;
case
"
sass
"
:
case
"
sass
"
:
case
"
scss
"
:
case
"
scss
"
:
languages
[
i
]
=
'
sass scss
'
+
languages
[
i
]
=
'
sass scss
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushSass.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushSass.js
'
;
break
;
break
;
case
"
vb
"
:
case
"
vb
"
:
case
"
vbnet
"
:
case
"
vbnet
"
:
languages
[
i
]
=
'
vb vbnet
'
+
languages
[
i
]
=
'
vb vbnet
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushVb.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushVb.js
'
;
break
;
break
;
case
"
xml
"
:
case
"
xml
"
:
case
"
xhtml
"
:
case
"
xhtml
"
:
case
"
xslt
"
:
case
"
xslt
"
:
case
"
html
"
:
case
"
html
"
:
languages
[
i
]
=
'
xml xhtml xslt html
'
+
languages
[
i
]
=
'
xml xhtml xslt html
'
+
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushXml.js
'
;
latkeConfig
.
staticServePath
+
'
/js/lib/SyntaxHighlighter/scripts/shBrushXml.js
'
;
break
;
break
;
default
:
default
:
break
;
break
;
}
}
}
}
// code high lighter
// code high lighter
SyntaxHighlighter
.
autoloader
.
apply
(
null
,
languages
);
SyntaxHighlighter
.
autoloader
.
apply
(
null
,
languages
);
SyntaxHighlighter
.
config
.
stripBrs
=
true
;
SyntaxHighlighter
.
config
.
stripBrs
=
true
;
SyntaxHighlighter
.
all
();
SyntaxHighlighter
.
all
();
},
},
/*
/*
* @description 加载 SyntaxHighlighter
* @description 加载 SyntaxHighlighter
* @param {String} SHTheme SyntaxHighLighter 样式
* @param {String} SHTheme SyntaxHighLighter 样式
*/
*/
_loadSyntaxHighlighter
:
function
(
SHTheme
)
{
_loadSyntaxHighlighter
:
function
(
SHTheme
)
{
var
cssName
=
SHTheme
?
SHTheme
:
"
shCoreEclipse
"
,
var
cssName
=
SHTheme
?
SHTheme
:
"
shCoreEclipse
"
,
that
=
this
;
that
=
this
;
// load css
// load css
if
(
document
.
createStyleSheet
)
{
if
(
document
.
createStyleSheet
)
{
document
.
createStyleSheet
(
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/styles/
"
+
cssName
+
"
.css
"
);
document
.
createStyleSheet
(
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/styles/
"
+
cssName
+
"
.css
"
);
}
else
{
}
else
{
$
(
"
head
"
).
append
(
$
(
"
<link rel='stylesheet' href='
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/styles/
"
$
(
"
head
"
).
append
(
$
(
"
<link rel='stylesheet' href='
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/styles/
"
+
cssName
+
"
.css' type='text/css' charset='utf-8' />
"
));
+
cssName
+
"
.css' type='text/css' charset='utf-8' />
"
));
}
}
// load js
// load js
$
.
ajax
({
$
.
ajax
({
url
:
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shCore.js
"
,
url
:
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shCore.js
"
,
dataType
:
"
script
"
,
dataType
:
"
script
"
,
cache
:
true
,
cache
:
true
,
success
:
function
()
{
success
:
function
()
{
// get brush settings
// get brush settings
var
languages
=
[],
var
languages
=
[],
isScrip
=
false
;
isScrip
=
false
;
$
(
"
.article-body pre
"
).
each
(
function
()
{
$
(
"
.article-body pre
"
).
each
(
function
()
{
var
name
=
this
.
className
.
split
(
"
;
"
)[
0
];
var
name
=
this
.
className
.
split
(
"
;
"
)[
0
];
var
language
=
name
.
substr
(
7
,
name
.
length
-
1
);
var
language
=
name
.
substr
(
7
,
name
.
length
-
1
);
if
(
this
.
className
.
indexOf
(
"
html-script: true
"
)
>
-
1
&&
if
(
this
.
className
.
indexOf
(
"
html-script: true
"
)
>
-
1
&&
(
language
!==
"
xml
"
&&
language
!==
"
xhtml
"
&&
(
language
!==
"
xml
"
&&
language
!==
"
xhtml
"
&&
language
!==
"
xslt
"
&&
language
!=
"
html
"
))
{
language
!==
"
xslt
"
&&
language
!=
"
html
"
))
{
isScrip
=
true
;
isScrip
=
true
;
}
}
languages
.
push
(
language
);
languages
.
push
(
language
);
});
});
// when html-script is true, need shBrushXml.js
// when html-script is true, need shBrushXml.js
if
(
isScrip
)
{
if
(
isScrip
)
{
$
.
ajax
({
$
.
ajax
({
url
:
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushXml.js
"
,
url
:
latkeConfig
.
staticServePath
+
"
/js/lib/SyntaxHighlighter/scripts/shBrushXml.js
"
,
dataType
:
"
script
"
,
dataType
:
"
script
"
,
cache
:
true
,
cache
:
true
,
success
:
function
()
{
success
:
function
()
{
that
.
_initSyntaxHighlighter
(
languages
);
that
.
_initSyntaxHighlighter
(
languages
);
}
}
});
});
}
else
{
}
else
{
that
.
_initSyntaxHighlighter
(
languages
);
that
.
_initSyntaxHighlighter
(
languages
);
}
}
}
}
});
});
},
},
/*
/*
* @description 解析语法高亮
* @description 解析语法高亮
* @param {Obj} obj 语法高亮配置参数
* @param {Obj} obj 语法高亮配置参数
* @param {Obj} obj.SHTheme 语法高亮 SyntaxHighLighter 样式
* @param {Obj} obj.SHTheme 语法高亮 SyntaxHighLighter 样式
*/
*/
parseLanguage
:
function
(
obj
)
{
parseLanguage
:
function
(
obj
)
{
var
isPrettify
=
false
,
var
isPrettify
=
false
,
isSH
=
false
;
isSH
=
false
;
$
(
"
.article-body pre
"
).
each
(
function
()
{
$
(
"
.article-body pre
"
).
each
(
function
()
{
if
(
this
.
className
.
indexOf
(
"
brush
"
)
>
-
1
)
{
if
(
this
.
className
.
indexOf
(
"
brush
"
)
>
-
1
)
{
isSH
=
true
;
isSH
=
true
;
}
}
if
(
this
.
className
.
indexOf
(
"
prettyprint
"
)
>
-
1
)
{
if
(
this
.
className
.
indexOf
(
"
prettyprint
"
)
>
-
1
)
{
isPrettify
=
true
;
isPrettify
=
true
;
}
}
});
});
if
(
isSH
)
{
if
(
isSH
)
{
this
.
_loadSyntaxHighlighter
(
obj
?
(
obj
.
SHTheme
?
obj
.
SHTheme
:
undefined
)
:
undefined
);
this
.
_loadSyntaxHighlighter
(
obj
?
(
obj
.
SHTheme
?
obj
.
SHTheme
:
undefined
)
:
undefined
);
}
}
if
(
isPrettify
)
{
if
(
isPrettify
)
{
// load css
// load css
if
(
document
.
createStyleSheet
)
{
if
(
document
.
createStyleSheet
)
{
document
.
createStyleSheet
(
latkeConfig
.
staticServePath
+
"
/js/lib/google-code-prettify/prettify.css
"
);
document
.
createStyleSheet
(
latkeConfig
.
staticServePath
+
"
/js/lib/google-code-prettify/prettify.css
"
);
}
else
{
}
else
{
$
(
"
head
"
).
append
(
$
(
"
<link rel='stylesheet' href='
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/google-code-prettify/prettify.css'>
"
));
$
(
"
head
"
).
append
(
$
(
"
<link rel='stylesheet' href='
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/google-code-prettify/prettify.css'>
"
));
}
}
// load js
// load js
document
.
write
(
"
<script src=
\"
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/google-code-prettify/prettify.js
\"
><
\
/script>
"
);
document
.
write
(
"
<script src=
\"
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/google-code-prettify/prettify.js
\"
><
\
/script>
"
);
// load function
// load function
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
prettyPrint
();
prettyPrint
();
});
});
}
}
},
},
/*
/*
* @description 文章/自定义页面加载
* @description 文章/自定义页面加载
* @param {Obj} obj 配置设定
* @param {Obj} obj 配置设定
* @param {Obj} obj.language 代码高亮配置
* @param {Obj} obj.language 代码高亮配置
*/
*/
load
:
function
(
obj
)
{
load
:
function
(
obj
)
{
var
that
=
this
;
var
that
=
this
;
// emotions
// if login, remove captcha
that
.
insertEmotions
();
if
(
$
(
"
#admin
"
).
data
(
"
login
"
))
{
$
(
"
#commentValidate
"
).
parent
().
parent
().
hide
();
// language
}
that
.
parseLanguage
(
obj
?
(
obj
.
language
?
obj
.
language
:
undefined
)
:
undefined
);
// emotions
// submit comment
that
.
insertEmotions
();
$
(
"
#commentValidate
"
).
keypress
(
function
(
event
)
{
if
(
event
.
keyCode
===
13
)
{
// language
that
.
submitComment
();
that
.
parseLanguage
(
obj
?
(
obj
.
language
?
obj
.
language
:
undefined
)
:
undefined
);
}
});
// submit comment
$
(
"
#commentValidate
"
).
keypress
(
function
(
event
)
{
// captcha
if
(
event
.
keyCode
===
13
)
{
$
(
"
#captcha
"
).
click
(
function
()
{
that
.
submitComment
();
$
(
this
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
());
}
});
});
// cookie
// captcha
var
$top
=
$
(
"
#top #admin
"
);
$
(
"
#captcha
"
).
click
(
function
()
{
if
(
$top
.
length
===
1
)
{
$
(
this
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
());
if
(
$top
.
find
(
"
a
"
).
length
>
2
)
{
});
Cookie
.
createCookie
(
"
commentName
"
,
$top
.
find
(
"
span
"
).
text
(),
365
);
Cookie
.
createCookie
(
"
commentURL
"
,
window
.
location
.
host
,
365
);
// cookie
}
var
$top
=
$
(
"
#top #admin
"
);
}
if
(
$top
.
length
===
1
)
{
if
(
$top
.
find
(
"
a
"
).
length
>
2
)
{
$
(
"
#commentEmail
"
).
val
(
Cookie
.
readCookie
(
"
commentEmail
"
));
Cookie
.
createCookie
(
"
commentName
"
,
$top
.
find
(
"
span
"
).
text
(),
365
);
$
(
"
#commentURL
"
).
val
(
Cookie
.
readCookie
(
"
commentURL
"
));
Cookie
.
createCookie
(
"
commentURL
"
,
window
.
location
.
host
,
365
);
$
(
"
#commentName
"
).
val
(
Cookie
.
readCookie
(
"
commentName
"
));
}
}
// if no JSON, add it.
try
{
$
(
"
#commentEmail
"
).
val
(
Cookie
.
readCookie
(
"
commentEmail
"
));
JSON
$
(
"
#commentURL
"
).
val
(
Cookie
.
readCookie
(
"
commentURL
"
));
}
catch
(
e
)
{
$
(
"
#commentName
"
).
val
(
Cookie
.
readCookie
(
"
commentName
"
));
document
.
write
(
"
<script src=
\"
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/json2.js
\"
><
\
/script>
"
);
}
// if no JSON, add it.
try
{
},
JSON
}
catch
(
e
)
{
/*
document
.
write
(
"
<script src=
\"
"
+
latkeConfig
.
staticServePath
+
"
/js/lib/json2.js
\"
><
\
/script>
"
);
* @description 加载随机文章
}
* @param {String} headTitle 随机文章标题
*/
},
loadRandomArticles
:
function
(
headTitle
)
{
var
randomArticles1Label
=
this
.
tips
.
randomArticles1Label
;
/*
// getRandomArticles
* @description 加载随机文章
$
.
ajax
({
* @param {String} headTitle 随机文章标题
url
:
latkeConfig
.
servePath
+
"
/get-random-articles.do
"
,
*/
type
:
"
POST
"
,
loadRandomArticles
:
function
(
headTitle
)
{
success
:
function
(
result
,
textStatus
){
var
randomArticles1Label
=
this
.
tips
.
randomArticles1Label
;
var
randomArticles
=
result
.
randomArticles
;
// getRandomArticles
if
(
!
randomArticles
||
0
===
randomArticles
.
length
)
{
$
.
ajax
({
$
(
"
#randomArticles
"
).
remove
();
url
:
latkeConfig
.
servePath
+
"
/get-random-articles.do
"
,
return
;
type
:
"
POST
"
,
}
success
:
function
(
result
,
textStatus
){
var
randomArticles
=
result
.
randomArticles
;
var
listHtml
=
""
;
if
(
!
randomArticles
||
0
===
randomArticles
.
length
)
{
for
(
var
i
=
0
;
i
<
randomArticles
.
length
;
i
++
)
{
$
(
"
#randomArticles
"
).
remove
();
var
article
=
randomArticles
[
i
];
return
;
var
title
=
article
.
articleTitle
;
}
var
randomArticleLiHtml
=
"
<li>
"
+
"
<a rel='nofollow' title='
"
+
title
+
"
' href='
"
+
article
.
articlePermalink
+
"
'>
"
+
title
+
"
</a></li>
"
;
var
listHtml
=
""
;
listHtml
+=
randomArticleLiHtml
;
for
(
var
i
=
0
;
i
<
randomArticles
.
length
;
i
++
)
{
}
var
article
=
randomArticles
[
i
];
var
title
=
article
.
articleTitle
;
var
titleHTML
=
headTitle
?
headTitle
:
"
<h4>
"
+
randomArticles1Label
+
"
</h4>
"
;
var
randomArticleLiHtml
=
"
<li>
"
+
"
<a rel='nofollow' title='
"
+
title
+
"
' href='
"
+
var
randomArticleListHtml
=
titleHTML
+
"
<ul class='marginLeft12'>
"
+
listHtml
+
"
</ul>
"
;
article
.
articlePermalink
+
"
'>
"
+
title
+
"
</a></li>
"
;
$
(
"
#randomArticles
"
).
append
(
randomArticleListHtml
);
listHtml
+=
randomArticleLiHtml
;
}
}
});
},
var
titleHTML
=
headTitle
?
headTitle
:
"
<h4>
"
+
randomArticles1Label
+
"
</h4>
"
;
var
randomArticleListHtml
=
titleHTML
+
"
<ul class='marginLeft12'>
"
+
listHtml
+
"
</ul>
"
;
/*
$
(
"
#randomArticles
"
).
append
(
randomArticleListHtml
);
* @description 加载相关文章
}
* @param {String} id 文章 id
});
* @param {String} headTitle 相关文章标题
},
*/
loadRelevantArticles
:
function
(
id
,
headTitle
)
{
/*
$
.
ajax
({
* @description 加载相关文章
url
:
latkeConfig
.
servePath
+
"
/article/id/
"
+
id
+
"
/relevant/articles
"
,
* @param {String} id 文章 id
type
:
"
GET
"
,
* @param {String} headTitle 相关文章标题
success
:
function
(
data
,
textStatus
){
*/
var
articles
=
data
.
relevantArticles
;
loadRelevantArticles
:
function
(
id
,
headTitle
)
{
if
(
!
articles
||
0
===
articles
.
length
)
{
$
.
ajax
({
$
(
"
#relevantArticles
"
).
remove
();
url
:
latkeConfig
.
servePath
+
"
/article/id/
"
+
id
+
"
/relevant/articles
"
,
return
;
type
:
"
GET
"
,
}
success
:
function
(
data
,
textStatus
){
var
listHtml
=
""
;
var
articles
=
data
.
relevantArticles
;
for
(
var
i
=
0
;
i
<
articles
.
length
;
i
++
)
{
if
(
!
articles
||
0
===
articles
.
length
)
{
var
article
=
articles
[
i
];
$
(
"
#relevantArticles
"
).
remove
();
var
title
=
article
.
articleTitle
;
return
;
var
articleLiHtml
=
"
<li>
"
}
+
"
<a rel='nofollow' title='
"
+
title
+
"
' href='
"
+
article
.
articlePermalink
+
"
'>
"
var
listHtml
=
""
;
+
title
+
"
</a></li>
"
for
(
var
i
=
0
;
i
<
articles
.
length
;
i
++
)
{
listHtml
+=
articleLiHtml
var
article
=
articles
[
i
];
}
var
title
=
article
.
articleTitle
;
var
articleLiHtml
=
"
<li>
"
var
relevantArticleListHtml
=
headTitle
+
"
<a rel='nofollow' title='
"
+
title
+
"
' href='
"
+
article
.
articlePermalink
+
"
'>
"
+
"
<ul class='marginLeft12'>
"
+
title
+
"
</a></li>
"
+
listHtml
+
"
</ul>
"
;
listHtml
+=
articleLiHtml
$
(
"
#relevantArticles
"
).
append
(
relevantArticleListHtml
);
}
},
error
:
function
()
{
var
relevantArticleListHtml
=
headTitle
$
(
"
#relevantArticles
"
).
remove
();
+
"
<ul class='marginLeft12'>
"
}
+
listHtml
+
"
</ul>
"
;
});
$
(
"
#relevantArticles
"
).
append
(
relevantArticleListHtml
);
},
},
error
:
function
()
{
/*
$
(
"
#relevantArticles
"
).
remove
();
* @description 加载站外相关文章
}
* @param {String} tags 文章 tags
});
* @param {String} headTitle 站外相关文章标题
},
*/
loadExternalRelevantArticles
:
function
(
tags
,
headTitle
)
{
/*
var
tips
=
this
.
tips
;
* @description 加载站外相关文章
try
{
* @param {String} tags 文章 tags
$
.
ajax
({
* @param {String} headTitle 站外相关文章标题
url
:
"
http://rhythm.b3log.org:80/get-articles-by-tags.do?tags=
"
+
tags
*/
+
"
&blogHost=
"
+
tips
.
blogHost
+
"
&paginationPageSize=
"
+
tips
.
externalRelevantArticlesDisplayCount
,
loadExternalRelevantArticles
:
function
(
tags
,
headTitle
)
{
type
:
"
GET
"
,
var
tips
=
this
.
tips
;
cache
:
true
,
try
{
dataType
:
"
jsonp
"
,
$
.
ajax
({
error
:
function
(){
url
:
"
http://rhythm.b3log.org:80/get-articles-by-tags.do?tags=
"
+
tags
$
(
"
#externalRelevantArticles
"
).
remove
();
+
"
&blogHost=
"
+
tips
.
blogHost
+
"
&paginationPageSize=
"
+
tips
.
externalRelevantArticlesDisplayCount
,
},
type
:
"
GET
"
,
success
:
function
(
data
,
textStatus
){
cache
:
true
,
var
articles
=
data
.
articles
;
dataType
:
"
jsonp
"
,
if
(
!
articles
||
0
===
articles
.
length
)
{
error
:
function
(){
$
(
"
#externalRelevantArticles
"
).
remove
();
$
(
"
#externalRelevantArticles
"
).
remove
();
return
;
},
}
success
:
function
(
data
,
textStatus
){
var
listHtml
=
""
;
var
articles
=
data
.
articles
;
for
(
var
i
=
0
;
i
<
articles
.
length
;
i
++
)
{
if
(
!
articles
||
0
===
articles
.
length
)
{
var
article
=
articles
[
i
];
$
(
"
#externalRelevantArticles
"
).
remove
();
var
title
=
article
.
articleTitle
;
return
;
var
articleLiHtml
=
"
<li>
"
}
+
"
<a rel='nofollow' title='
"
+
title
+
"
' target='_blank' href='
"
+
article
.
articlePermalink
+
"
'>
"
var
listHtml
=
""
;
+
title
+
"
</a></li>
"
for
(
var
i
=
0
;
i
<
articles
.
length
;
i
++
)
{
listHtml
+=
articleLiHtml
var
article
=
articles
[
i
];
}
var
title
=
article
.
articleTitle
;
var
articleLiHtml
=
"
<li>
"
var
titleHTML
=
headTitle
?
headTitle
:
"
<h4>
"
+
tips
.
externalRelevantArticles1Label
+
"
</h4>
"
;
+
"
<a rel='nofollow' title='
"
+
title
+
"
' target='_blank' href='
"
+
article
.
articlePermalink
+
"
'>
"
var
randomArticleListHtml
=
titleHTML
+
title
+
"
</a></li>
"
+
"
<ul class='marginLeft12'>
"
listHtml
+=
articleLiHtml
+
listHtml
+
"
</ul>
"
;
}
$
(
"
#externalRelevantArticles
"
).
append
(
randomArticleListHtml
);
}
var
titleHTML
=
headTitle
?
headTitle
:
"
<h4>
"
+
tips
.
externalRelevantArticles1Label
+
"
</h4>
"
;
});
var
randomArticleListHtml
=
titleHTML
}
catch
(
e
)
{
+
"
<ul class='marginLeft12'>
"
// 忽略相关文章加载异常:load script error
+
listHtml
+
"
</ul>
"
;
}
$
(
"
#externalRelevantArticles
"
).
append
(
randomArticleListHtml
);
},
}
});
/*
}
catch
(
e
)
{
* @description 提交评论
// 忽略相关文章加载异常:load script error
* @param {String} commentId 回复评论时的评论 id
}
* @param {String} state 区分回复文章还是回复评论的标识
},
*/
submitComment
:
function
(
commentId
,
state
)
{
/*
if
(
!
state
)
{
* @description 提交评论
state
=
''
;
* @param {String} commentId 回复评论时的评论 id
}
* @param {String} state 区分回复文章还是回复评论的标识
var
that
=
this
,
*/
tips
=
this
.
tips
,
submitComment
:
function
(
commentId
,
state
)
{
type
=
"
article
"
;
if
(
!
state
)
{
if
(
tips
.
externalRelevantArticlesDisplayCount
===
undefined
)
{
state
=
''
;
type
=
"
page
"
;
}
}
var
that
=
this
,
tips
=
this
.
tips
,
if
(
this
.
validateComment
(
state
))
{
type
=
"
article
"
;
$
(
"
#submitCommentButton
"
+
state
).
attr
(
"
disabled
"
,
"
disabled
"
);
if
(
tips
.
externalRelevantArticlesDisplayCount
===
undefined
)
{
$
(
"
#commentErrorTip
"
+
state
).
show
().
html
(
this
.
tips
.
loadingLabel
);
type
=
"
page
"
;
}
var
requestJSONObject
=
{
"
oId
"
:
tips
.
oId
,
if
(
this
.
validateComment
(
state
))
{
"
commentContent
"
:
$
(
"
#comment
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
),
$
(
"
#submitCommentButton
"
+
state
).
attr
(
"
disabled
"
,
"
disabled
"
);
"
commentEmail
"
:
$
(
"
#commentEmail
"
+
state
).
val
(),
$
(
"
#commentErrorTip
"
+
state
).
show
().
html
(
this
.
tips
.
loadingLabel
);
"
commentURL
"
:
Util
.
proessURL
(
$
(
"
#commentURL
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
)),
"
commentName
"
:
$
(
"
#commentName
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
),
var
requestJSONObject
=
{
"
captcha
"
:
$
(
"
#commentValidate
"
+
state
).
val
()
"
oId
"
:
tips
.
oId
,
};
"
commentContent
"
:
$
(
"
#comment
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
),
"
commentEmail
"
:
$
(
"
#commentEmail
"
+
state
).
val
(),
if
(
state
===
"
Reply
"
)
{
"
commentURL
"
:
Util
.
proessURL
(
$
(
"
#commentURL
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
)),
requestJSONObject
.
commentOriginalCommentId
=
commentId
;
"
commentName
"
:
$
(
"
#commentName
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
),
}
"
captcha
"
:
$
(
"
#commentValidate
"
+
state
).
val
()
$
.
ajax
({
};
type
:
"
POST
"
,
url
:
latkeConfig
.
servePath
+
"
/add-
"
+
type
+
"
-comment.do
"
,
if
(
state
===
"
Reply
"
)
{
cache
:
false
,
requestJSONObject
.
commentOriginalCommentId
=
commentId
;
contentType
:
"
application/json
"
,
}
data
:
JSON
.
stringify
(
requestJSONObject
),
$
.
ajax
({
success
:
function
(
result
){
type
:
"
POST
"
,
if
(
!
result
.
sc
)
{
url
:
latkeConfig
.
servePath
+
"
/add-
"
+
type
+
"
-comment.do
"
,
$
(
"
#commentErrorTip
"
+
state
).
html
(
result
.
msg
);
cache
:
false
,
$
(
"
#commentValidate
"
+
state
).
val
(
""
).
focus
();
contentType
:
"
application/json
"
,
data
:
JSON
.
stringify
(
requestJSONObject
),
$
(
"
#submitCommentButton
"
+
state
).
removeAttr
(
"
disabled
"
);
success
:
function
(
result
){
$
(
"
#captcha
"
+
state
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
());
if
(
!
result
.
sc
)
{
$
(
"
#commentErrorTip
"
+
state
).
html
(
result
.
msg
);
return
;
$
(
"
#commentValidate
"
+
state
).
val
(
""
).
focus
();
}
$
(
"
#submitCommentButton
"
+
state
).
removeAttr
(
"
disabled
"
);
result
.
replyNameHTML
=
""
;
$
(
"
#captcha
"
+
state
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
());
if
(
$
(
"
#commentURL
"
+
state
).
val
().
replace
(
/
\s
/g
,
""
)
===
""
)
{
result
.
replyNameHTML
=
'
<a>
'
+
$
(
"
#commentName
"
+
state
).
val
()
+
'
</a>
'
;
return
;
}
else
{
}
result
.
replyNameHTML
=
'
<a href="
'
+
Util
.
proessURL
(
$
(
"
#commentURL
"
+
state
).
val
())
+
'
" target="_blank">
'
+
$
(
"
#commentName
"
+
state
).
val
()
+
'
</a>
'
;
result
.
replyNameHTML
=
""
;
}
if
(
$
(
"
#commentURL
"
+
state
).
val
().
replace
(
/
\s
/g
,
""
)
===
""
)
{
result
.
replyNameHTML
=
'
<a>
'
+
$
(
"
#commentName
"
+
state
).
val
()
+
'
</a>
'
;
that
.
addCommentAjax
(
addComment
(
result
,
state
),
state
);
}
else
{
result
.
replyNameHTML
=
'
<a href="
'
+
Util
.
proessURL
(
$
(
"
#commentURL
"
+
state
).
val
())
+
$
(
"
#submitCommentButton
"
+
state
).
removeAttr
(
"
disabled
"
);
'
" target="_blank">
'
+
$
(
"
#commentName
"
+
state
).
val
()
+
'
</a>
'
;
$
(
"
#captcha
"
+
state
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
());
}
}
});
that
.
addCommentAjax
(
addComment
(
result
,
state
),
state
);
Cookie
.
createCookie
(
"
commentName
"
,
requestJSONObject
.
commentName
,
365
);
$
(
"
#submitCommentButton
"
+
state
).
removeAttr
(
"
disabled
"
);
Cookie
.
createCookie
(
"
commentEmail
"
,
requestJSONObject
.
commentEmail
,
365
);
$
(
"
#captcha
"
+
state
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
());
Cookie
.
createCookie
(
"
commentURL
"
,
$
(
"
#commentURL
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
),
365
);
}
}
});
},
Cookie
.
createCookie
(
"
commentName
"
,
requestJSONObject
.
commentName
,
365
);
/*
Cookie
.
createCookie
(
"
commentEmail
"
,
requestJSONObject
.
commentEmail
,
365
);
* @description 添加回复评论表单
Cookie
.
createCookie
(
"
commentURL
"
,
$
(
"
#commentURL
"
+
state
).
val
().
replace
(
/
(
^
\s
*
)
|
(\s
*$
)
/g
,
""
),
365
);
* @param {String} id 被回复的评论 id
}
* @param {String} commentFormHTML 评论表单HTML
},
* @param {String} endHTML 判断该表单使用 table 还是 div 标签,然后进行构造
*/
/*
addReplyForm
:
function
(
id
,
commentFormHTML
,
endHTML
)
{
* @description 添加回复评论表单
var
that
=
this
;
* @param {String} id 被回复的评论 id
if
(
id
===
this
.
currentCommentId
)
{
* @param {String} commentFormHTML 评论表单HTML
if
(
Cookie
.
readCookie
(
"
commentName
"
)
===
""
)
{
* @param {String} endHTML 判断该表单使用 table 还是 div 标签,然后进行构造
$
(
"
#commentNameReply
"
).
focus
();
*/
}
else
{
addReplyForm
:
function
(
id
,
commentFormHTML
,
endHTML
)
{
$
(
"
#commentReply
"
).
focus
();
var
that
=
this
;
}
if
(
id
===
this
.
currentCommentId
)
{
return
;
if
(
Cookie
.
readCookie
(
"
commentName
"
)
===
""
)
{
}
else
{
$
(
"
#commentNameReply
"
).
focus
();
$
(
"
#replyForm
"
).
remove
();
}
else
{
endHTML
=
endHTML
?
endHTML
:
""
;
$
(
"
#commentReply
"
).
focus
();
if
(
endHTML
===
"
</div>
"
)
{
}
$
(
"
#
"
+
id
).
append
(
commentFormHTML
+
$
(
"
#commentForm
"
).
html
()
+
endHTML
);
return
;
}
else
{
}
else
{
$
(
"
#
"
+
id
).
append
(
commentFormHTML
+
$
(
"
#commentForm
"
).
html
()
+
"
</table>
"
+
endHTML
);
$
(
"
#replyForm
"
).
remove
();
}
endHTML
=
endHTML
?
endHTML
:
""
;
if
(
endHTML
===
"
</div>
"
)
{
// change id, bind event and set value
$
(
"
#
"
+
id
).
append
(
commentFormHTML
+
$
(
"
#commentForm
"
).
html
()
+
endHTML
);
$
(
"
#replyForm input, #replyForm textarea
"
).
each
(
function
()
{
}
else
{
this
.
id
=
this
.
id
+
"
Reply
"
;
$
(
"
#
"
+
id
).
append
(
commentFormHTML
+
$
(
"
#commentForm
"
).
html
()
+
"
</table>
"
+
endHTML
);
});
}
$
(
"
#commentNameReply
"
).
val
(
Cookie
.
readCookie
(
"
commentName
"
));
// change id, bind event and set value
$
(
"
#replyForm input, #replyForm textarea
"
).
each
(
function
()
{
$
(
"
#commentEmailReply
"
).
val
(
Cookie
.
readCookie
(
"
commentEmail
"
));
this
.
id
=
this
.
id
+
"
Reply
"
;
});
var
$label
=
$
(
"
#replyForm #commentURLLabel
"
);
if
(
$label
.
length
===
1
)
{
$
(
"
#commentNameReply
"
).
val
(
Cookie
.
readCookie
(
"
commentName
"
));
$label
.
attr
(
"
id
"
,
"
commentURLLabelReply
"
);
}
$
(
"
#commentEmailReply
"
).
val
(
Cookie
.
readCookie
(
"
commentEmail
"
));
$
(
"
#commentURLReply
"
).
val
(
Cookie
.
readCookie
(
"
commentURL
"
));
var
$label
=
$
(
"
#replyForm #commentURLLabel
"
);
if
(
$label
.
length
===
1
)
{
$
(
"
#replyForm #emotions
"
).
attr
(
"
id
"
,
"
emotionsReply
"
);
$label
.
attr
(
"
id
"
,
"
commentURLLabelReply
"
);
}
this
.
insertEmotions
(
"
Reply
"
);
$
(
"
#commentURLReply
"
).
val
(
Cookie
.
readCookie
(
"
commentURL
"
));
$
(
"
#commentValidateReply
"
).
unbind
().
keypress
(
function
(
event
)
{
if
(
event
.
keyCode
===
13
)
{
$
(
"
#replyForm #emotions
"
).
attr
(
"
id
"
,
"
emotionsReply
"
);
that
.
submitComment
(
id
,
'
Reply
'
);
event
.
preventDefault
();
this
.
insertEmotions
(
"
Reply
"
);
}
});
$
(
"
#commentValidateReply
"
).
unbind
().
keypress
(
function
(
event
)
{
$
(
"
#replyForm #captcha
"
).
attr
(
"
id
"
,
"
captchaReply
"
).
if
(
event
.
keyCode
===
13
)
{
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?
"
+
new
Date
().
getTime
()).
click
(
function
()
{
that
.
submitComment
(
id
,
'
Reply
'
);
$
(
this
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
());
event
.
preventDefault
();
});
}
});
$
(
"
#replyForm #commentErrorTip
"
).
attr
(
"
id
"
,
"
commentErrorTipReply
"
).
html
(
""
).
hide
();
$
(
"
#replyForm #captcha
"
).
attr
(
"
id
"
,
"
captchaReply
"
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?
"
+
new
Date
().
getTime
()).
click
(
function
()
{
$
(
"
#replyForm #submitCommentButton
"
).
attr
(
"
id
"
,
"
submitCommentButtonReply
"
);
$
(
this
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
());
$
(
"
#replyForm #submitCommentButtonReply
"
).
unbind
(
"
click
"
).
removeAttr
(
"
onclick
"
).
click
(
function
()
{
});
that
.
submitComment
(
id
,
'
Reply
'
);
});
$
(
"
#replyForm #commentErrorTip
"
).
attr
(
"
id
"
,
"
commentErrorTipReply
"
).
html
(
""
).
hide
();
if
(
Cookie
.
readCookie
(
"
commentName
"
)
===
""
)
{
$
(
"
#replyForm #submitCommentButton
"
).
attr
(
"
id
"
,
"
submitCommentButtonReply
"
);
$
(
"
#commentNameReply
"
).
focus
();
$
(
"
#replyForm #submitCommentButtonReply
"
).
unbind
(
"
click
"
).
removeAttr
(
"
onclick
"
).
click
(
function
()
{
}
else
{
that
.
submitComment
(
id
,
'
Reply
'
);
$
(
"
#commentReply
"
).
focus
();
});
}
}
if
(
Cookie
.
readCookie
(
"
commentName
"
)
===
""
)
{
this
.
currentCommentId
=
id
;
$
(
"
#commentNameReply
"
).
focus
();
},
}
else
{
$
(
"
#commentReply
"
).
focus
();
/*
}
* @description 隐藏回复评论的浮出层
}
* @parma {String} id 被回复的评论 id
this
.
currentCommentId
=
id
;
*/
},
hideComment
:
function
(
id
)
{
$
(
"
#commentRef
"
+
id
).
hide
();
/*
},
* @description 隐藏回复评论的浮出层
* @parma {String} id 被回复的评论 id
/*
*/
* @description 显示回复评论的浮出层
hideComment
:
function
(
id
)
{
* @parma {Dom} it 触发事件的 dom
$
(
"
#commentRef
"
+
id
).
hide
();
* @param {String} id 被回复的评论 id
},
* @param {Int} top 位置相对浮出层的高度
* @param {String} [parentTag] it 如果嵌入在 position 为 relative 的元素 A 中时,需取到 A 元素
/*
*/
* @description 显示回复评论的浮出层
showComment
:
function
(
it
,
id
,
top
,
parentTag
)
{
* @parma {Dom} it 触发事件的 dom
var
positionTop
=
parseInt
(
$
(
it
).
position
().
top
);
* @param {String} id 被回复的评论 id
if
(
parentTag
)
{
* @param {Int} top 位置相对浮出层的高度
positionTop
=
parseInt
(
$
(
it
).
parents
(
parentTag
).
position
().
top
);
* @param {String} [parentTag] it 如果嵌入在 position 为 relative 的元素 A 中时,需取到 A 元素
}
*/
if
(
$
(
"
#commentRef
"
+
id
).
length
>
0
)
{
showComment
:
function
(
it
,
id
,
top
,
parentTag
)
{
// 此处重复设置 top 是由于评论为异步,原有回复评论的显示位置应往下移动
var
positionTop
=
parseInt
(
$
(
it
).
position
().
top
);
$
(
"
#commentRef
"
+
id
).
show
().
css
(
"
top
"
,
(
positionTop
+
top
)
+
"
px
"
);
if
(
parentTag
)
{
}
else
{
positionTop
=
parseInt
(
$
(
it
).
parents
(
parentTag
).
position
().
top
);
var
$refComment
=
$
(
"
#
"
+
id
).
clone
();
}
$refComment
.
addClass
(
"
comment-body-ref
"
).
attr
(
"
id
"
,
"
commentRef
"
+
id
);
if
(
$
(
"
#commentRef
"
+
id
).
length
>
0
)
{
$refComment
.
find
(
"
#replyForm
"
).
remove
();
// 此处重复设置 top 是由于评论为异步,原有回复评论的显示位置应往下移动
$
(
"
#comments
"
).
append
(
$refComment
);
$
(
"
#commentRef
"
+
id
).
show
().
css
(
"
top
"
,
(
positionTop
+
top
)
+
"
px
"
);
$
(
"
#commentRef
"
+
id
).
css
(
"
top
"
,
(
positionTop
+
top
)
+
"
px
"
);
}
else
{
}
var
$refComment
=
$
(
"
#
"
+
id
).
clone
();
},
$refComment
.
addClass
(
"
comment-body-ref
"
).
attr
(
"
id
"
,
"
commentRef
"
+
id
);
$refComment
.
find
(
"
#replyForm
"
).
remove
();
/*
$
(
"
#comments
"
).
append
(
$refComment
);
* @description 回复不刷新,将回复内容异步添加到评论列表中
$
(
"
#commentRef
"
+
id
).
css
(
"
top
"
,
(
positionTop
+
top
)
+
"
px
"
);
* @parma {String} commentHTML 回复内容 HTML
}
* @param {String} state 用于区分评论文章还是回复评论
},
*/
addCommentAjax
:
function
(
commentHTML
,
state
)
{
/*
if
(
$
(
"
#comments
"
).
children
().
length
>
0
)
{
* @description 回复不刷新,将回复内容异步添加到评论列表中
$
(
$
(
"
#comments
"
).
children
()[
0
]).
before
(
commentHTML
);
* @parma {String} commentHTML 回复内容 HTML
}
else
{
* @param {String} state 用于区分评论文章还是回复评论
$
(
"
#comments
"
).
html
(
commentHTML
);
*/
}
addCommentAjax
:
function
(
commentHTML
,
state
)
{
if
(
$
(
"
#comments
"
).
children
().
length
>
0
)
{
if
(
state
===
""
)
{
$
(
$
(
"
#comments
"
).
children
()[
0
]).
before
(
commentHTML
);
$
(
"
#commentErrorTip
"
).
html
(
""
).
hide
();
}
else
{
$
(
"
#comment
"
).
val
(
""
);
$
(
"
#comments
"
).
html
(
commentHTML
);
$
(
"
#commentValidate
"
).
val
(
""
);
}
$
(
"
#captcha
"
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
());
}
else
{
if
(
state
===
""
)
{
$
(
"
#replyForm
"
).
remove
();
$
(
"
#commentErrorTip
"
).
html
(
""
).
hide
();
}
$
(
"
#comment
"
).
val
(
""
);
window
.
location
.
hash
=
"
#comments
"
;
$
(
"
#commentValidate
"
).
val
(
""
);
}
$
(
"
#captcha
"
).
attr
(
"
src
"
,
latkeConfig
.
servePath
+
"
/captcha.do?code=
"
+
Math
.
random
());
}
else
{
$
(
"
#replyForm
"
).
remove
();
}
window
.
location
.
hash
=
"
#comments
"
;
}
});
});
\ No newline at end of file
war/src/main/webapp/skins/mobile/themes/core/core.js
View file @
e3088d67
...
@@ -5,134 +5,161 @@
...
@@ -5,134 +5,161 @@
var
$wpt
=
jQuery
.
noConflict
();
var
$wpt
=
jQuery
.
noConflict
();
if
(
(
navigator
.
platform
==
'
iPhone
'
||
navigator
.
platform
==
'
iPod
'
)
&&
typeof
orientation
!=
'
undefined
'
)
{
if
(
(
navigator
.
platform
==
'
iPhone
'
||
navigator
.
platform
==
'
iPod
'
)
&&
typeof
orientation
!=
'
undefined
'
)
{
var
touchStartOrClick
=
'
touchstart
'
;
var
touchStartOrClick
=
'
touchstart
'
;
}
else
{
}
else
{
var
touchStartOrClick
=
'
click
'
;
var
touchStartOrClick
=
'
click
'
;
};
};
/* Try to get out of frames! */
/* Try to get out of frames! */
if
(
window
.
top
!=
window
.
self
)
{
if
(
window
.
top
!=
window
.
self
)
{
window
.
top
.
location
=
self
.
location
.
href
window
.
top
.
location
=
self
.
location
.
href
}
}
$wpt
.
fn
.
wptouchFadeToggle
=
function
(
speed
,
easing
,
callback
)
{
$wpt
.
fn
.
wptouchFadeToggle
=
function
(
speed
,
easing
,
callback
)
{
return
this
.
animate
(
{
opacity
:
'
toggle
'
},
speed
,
easing
,
callback
);
return
this
.
animate
(
{
opacity
:
'
toggle
'
},
speed
,
easing
,
callback
);
};
};
/**
* @description Cookie 相关操作
* @static
*/
var
Cookie
=
{
var
Cookie
=
{
/**
* @description 读取 cookie
* @param {String} name cookie key
* @returns {String} 对应 key 的值,如 key 不存在则返回 ""
*/
readCookie
:
function
(
name
)
{
readCookie
:
function
(
name
)
{
var
nameEQ
=
name
+
"
=
"
;
var
nameEQ
=
name
+
"
=
"
;
var
ca
=
document
.
cookie
.
split
(
'
;
'
);
var
ca
=
document
.
cookie
.
split
(
'
;
'
);
for
(
var
i
=
0
;
i
<
ca
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
ca
.
length
;
i
++
)
{
var
c
=
ca
[
i
];
var
c
=
ca
[
i
];
while
(
c
.
charAt
(
0
)
==
'
'
)
c
=
c
.
substring
(
1
,
c
.
length
);
while
(
c
.
charAt
(
0
)
==
'
'
)
c
=
c
.
substring
(
1
,
c
.
length
);
if
(
c
.
indexOf
(
nameEQ
)
==
0
)
return
c
.
substring
(
nameEQ
.
length
,
c
.
length
);
if
(
c
.
indexOf
(
nameEQ
)
==
0
)
return
decodeURIComponent
(
c
.
substring
(
nameEQ
.
length
,
c
.
length
)
);
}
}
return
""
;
return
""
;
},
},
/**
* @description 清除 Cookie
* @param {String} name 清除 key 为 name 的该条 Cookie
*/
eraseCookie
:
function
(
name
)
{
eraseCookie
:
function
(
name
)
{
this
.
createCookie
(
name
,
""
,
-
1
);
this
.
createCookie
(
name
,
""
,
-
1
);
},
},
createCookie
:
function
(
name
,
value
,
days
)
{
/**
* @description 创建 Cookie
* @param {String} name 每条 Cookie 唯一的 key
* @param {String} value 每条 Cookie 对应的值,将被 UTF-8 编码
* @param {Int} days Cookie 保存时间
*/
createCookie
:
function
(
name
,
value
,
days
)
{
var
expires
=
""
;
var
expires
=
""
;
if
(
days
)
{
if
(
days
)
{
var
date
=
new
Date
();
var
date
=
new
Date
();
date
.
setTime
(
date
.
getTime
()
+
(
days
*
24
*
60
*
60
*
1000
));
date
.
setTime
(
date
.
getTime
()
+
(
days
*
24
*
60
*
60
*
1000
));
expires
=
"
; expires=
"
+
date
.
toGMTString
();
expires
=
"
; expires=
"
+
date
.
toGMTString
();
}
}
document
.
cookie
=
name
+
"
=
"
+
value
+
expires
+
"
; path=/
"
;
document
.
cookie
=
name
+
"
=
"
+
encodeURIComponent
(
value
)
+
expires
+
"
; path=/
"
;
}
}
};
};
function
wptouch_switch_confirmation
(
skin
,
e
)
{
function
wptouch_switch_confirmation
(
skin
,
e
)
{
if
(
document
.
cookie
&&
document
.
cookie
.
indexOf
(
'
btouch_switch_toggle
'
)
>
-
1
)
{
if
(
document
.
cookie
&&
document
.
cookie
.
indexOf
(
'
btouch_switch_toggle
'
)
>
-
1
)
{
// just switch
// just switch
Cookie
.
createCookie
(
"
btouch_switch_toggle
"
,
skin
,
365
);
Cookie
.
createCookie
(
"
btouch_switch_toggle
"
,
skin
,
365
);
$wpt
(
'
a#switch-link
'
).
toggleClass
(
'
offimg
'
);
$wpt
(
'
a#switch-link
'
).
toggleClass
(
'
offimg
'
);
setTimeout
(
'
switch_delayer()
'
,
1250
);
setTimeout
(
'
switch_delayer()
'
,
1250
);
}
else
{
}
else
{
// ask first
// ask first
Cookie
.
createCookie
(
"
btouch_switch_toggle
"
,
skin
,
365
);
Cookie
.
createCookie
(
"
btouch_switch_toggle
"
,
skin
,
365
);
if
(
confirm
(
"
Switch to regular view?
\n
\n
You can switch back again in the top bar.
"
)
)
{
if
(
confirm
(
"
Switch to regular view?
\n
\n
You can switch back again in the top bar.
"
)
)
{
$wpt
(
'
a#switch-link
'
).
toggleClass
(
'
offimg
'
);
$wpt
(
'
a#switch-link
'
).
toggleClass
(
'
offimg
'
);
setTimeout
(
'
switch_delayer()
'
,
1350
);
setTimeout
(
'
switch_delayer()
'
,
1350
);
}
else
{
}
else
{
e
.
preventDefault
();
e
.
preventDefault
();
e
.
stopImmediatePropagation
();
e
.
stopImmediatePropagation
();
}
}
}
}
}
}
if
(
$wpt
(
'
#prowl-success
'
).
length
)
{
if
(
$wpt
(
'
#prowl-success
'
).
length
)
{
setTimeout
(
function
()
{
$wpt
(
'
#prowl-success
'
).
fadeOut
(
350
);
},
5250
);
setTimeout
(
function
()
{
$wpt
(
'
#prowl-success
'
).
fadeOut
(
350
);
},
5250
);
}
}
if
(
$wpt
(
'
#prowl-fail
'
).
length
)
{
if
(
$wpt
(
'
#prowl-fail
'
).
length
)
{
setTimeout
(
function
()
{
$wpt
(
'
#prowl-fail
'
).
fadeOut
(
350
);
},
5250
);
setTimeout
(
function
()
{
$wpt
(
'
#prowl-fail
'
).
fadeOut
(
350
);
},
5250
);
}
}
$wpt
(
function
()
{
$wpt
(
function
()
{
var
tabContainers
=
$wpt
(
'
#menu-head > ul
'
);
var
tabContainers
=
$wpt
(
'
#menu-head > ul
'
);
$wpt
(
'
#tabnav a
'
).
bind
(
touchStartOrClick
,
function
()
{
$wpt
(
'
#tabnav a
'
).
bind
(
touchStartOrClick
,
function
()
{
tabContainers
.
hide
().
filter
(
this
.
hash
).
show
();
tabContainers
.
hide
().
filter
(
this
.
hash
).
show
();
$wpt
(
'
#tabnav a
'
).
removeClass
(
'
selected
'
);
$wpt
(
'
#tabnav a
'
).
removeClass
(
'
selected
'
);
$wpt
(
this
).
addClass
(
'
selected
'
);
$wpt
(
this
).
addClass
(
'
selected
'
);
return
false
;
return
false
;
}).
filter
(
'
:first
'
).
trigger
(
touchStartOrClick
);
}).
filter
(
'
:first
'
).
trigger
(
touchStartOrClick
);
});
});
function
bnc_showhide_coms_toggle
()
{
function
bnc_showhide_coms_toggle
()
{
$wpt
(
'
#commentlist
'
).
wptouchFadeToggle
(
350
);
$wpt
(
'
#commentlist
'
).
wptouchFadeToggle
(
350
);
$wpt
(
'
img#com-arrow
'
).
toggleClass
(
'
com-arrow-down
'
);
$wpt
(
'
img#com-arrow
'
).
toggleClass
(
'
com-arrow-down
'
);
$wpt
(
'
h3#com-head
'
).
toggleClass
(
'
comhead-open
'
);
$wpt
(
'
h3#com-head
'
).
toggleClass
(
'
comhead-open
'
);
}
}
function
doWPtouchReady
()
{
function
doWPtouchReady
()
{
$wpt
(
'
#headerbar-menu a
'
).
bind
(
touchStartOrClick
,
function
(
e
){
$wpt
(
'
#headerbar-menu a
'
).
bind
(
touchStartOrClick
,
function
(
e
){
$wpt
(
'
#wptouch-menu
'
).
wptouchFadeToggle
(
350
);
$wpt
(
'
#wptouch-menu
'
).
wptouchFadeToggle
(
350
);
$wpt
(
'
#headerbar-menu a
'
).
toggleClass
(
'
open
'
);
$wpt
(
'
#headerbar-menu a
'
).
toggleClass
(
'
open
'
);
});
});
$wpt
(
'
a#searchopen, #wptouch-search-inner a
'
).
bind
(
touchStartOrClick
,
function
(
e
){
$wpt
(
'
a#searchopen, #wptouch-search-inner a
'
).
bind
(
touchStartOrClick
,
function
(
e
){
$wpt
(
'
#wptouch-search
'
).
wptouchFadeToggle
(
350
);
$wpt
(
'
#wptouch-search
'
).
wptouchFadeToggle
(
350
);
});
});
$wpt
(
'
a#prowlopen
'
).
bind
(
touchStartOrClick
,
function
(
e
){
$wpt
(
'
a#prowlopen
'
).
bind
(
touchStartOrClick
,
function
(
e
){
$wpt
(
'
#prowl-message
'
).
wptouchFadeToggle
(
350
);
$wpt
(
'
#prowl-message
'
).
wptouchFadeToggle
(
350
);
});
});
$wpt
(
'
a#wordtwitopen
'
).
bind
(
touchStartOrClick
,
function
(
e
){
$wpt
(
'
a#wordtwitopen
'
).
bind
(
touchStartOrClick
,
function
(
e
){
$wpt
(
'
#wptouch-wordtwit
'
).
wptouchFadeToggle
(
350
);
$wpt
(
'
#wptouch-wordtwit
'
).
wptouchFadeToggle
(
350
);
});
});
$wpt
(
'
a#gigpressopen
'
).
bind
(
touchStartOrClick
,
function
(
e
){
$wpt
(
'
a#gigpressopen
'
).
bind
(
touchStartOrClick
,
function
(
e
){
$wpt
(
'
#wptouch-gigpress
'
).
wptouchFadeToggle
(
350
);
$wpt
(
'
#wptouch-gigpress
'
).
wptouchFadeToggle
(
350
);
});
});
$wpt
(
'
a#loginopen, #wptouch-login-inner a
'
).
bind
(
touchStartOrClick
,
function
(
e
){
$wpt
(
'
a#loginopen, #wptouch-login-inner a
'
).
bind
(
touchStartOrClick
,
function
(
e
){
$wpt
(
'
#wptouch-login
'
).
wptouchFadeToggle
(
350
);
$wpt
(
'
#wptouch-login
'
).
wptouchFadeToggle
(
350
);
});
});
$wpt
(
'
a#obook
'
).
bind
(
touchStartOrClick
,
function
()
{
$wpt
(
'
a#obook
'
).
bind
(
touchStartOrClick
,
function
()
{
$wpt
(
'
#bookmark-box
'
).
wptouchFadeToggle
(
350
);
$wpt
(
'
#bookmark-box
'
).
wptouchFadeToggle
(
350
);
});
});
$wpt
(
'
.singlentry img, .singlentry .wp-caption
'
).
each
(
function
()
{
$wpt
(
'
.singlentry img, .singlentry .wp-caption
'
).
each
(
function
()
{
if
(
$wpt
(
this
).
width
()
<=
250
)
{
if
(
$wpt
(
this
).
width
()
<=
250
)
{
$wpt
(
this
).
addClass
(
'
aligncenter
'
);
$wpt
(
this
).
addClass
(
'
aligncenter
'
);
}
}
});
});
if
(
$wpt
(
'
#FollowMeTabLeftSm
'
).
length
)
{
if
(
$wpt
(
'
#FollowMeTabLeftSm
'
).
length
)
{
$wpt
(
'
#FollowMeTabLeftSm
'
).
remove
();
$wpt
(
'
#FollowMeTabLeftSm
'
).
remove
();
}
}
$wpt
(
'
.post
'
).
fitVids
();
$wpt
(
'
.post
'
).
fitVids
();
}
}
$wpt
(
document
).
ready
(
function
()
{
doWPtouchReady
();
}
);
$wpt
(
document
).
ready
(
function
()
{
doWPtouchReady
();
}
);
/*!
/*!
* FitVids 1.0
* FitVids 1.0
...
@@ -142,14 +169,14 @@ $wpt( document ).ready( function() { doWPtouchReady(); } );
...
@@ -142,14 +169,14 @@ $wpt( document ).ready( function() { doWPtouchReady(); } );
* Date: Thu Sept 01 18:00:00 2011 -0500
* Date: Thu Sept 01 18:00:00 2011 -0500
*/
*/
(
function
(
$
){
(
function
(
$
){
$
.
fn
.
fitVids
=
function
(
options
)
{
$
.
fn
.
fitVids
=
function
(
options
)
{
var
settings
=
{
var
settings
=
{
customSelector
:
null
customSelector
:
null
}
}
var
div
=
document
.
createElement
(
'
div
'
),
var
div
=
document
.
createElement
(
'
div
'
),
ref
=
document
.
getElementsByTagName
(
'
base
'
)[
0
]
||
document
.
getElementsByTagName
(
'
script
'
)[
0
];
ref
=
document
.
getElementsByTagName
(
'
base
'
)[
0
]
||
document
.
getElementsByTagName
(
'
script
'
)[
0
];
div
.
className
=
'
fit-vids-style
'
;
div
.
className
=
'
fit-vids-style
'
;
div
.
innerHTML
=
'
­<style>
\
div
.
innerHTML
=
'
­<style>
\
.fluid-width-video-wrapper {
\
.fluid-width-video-wrapper {
\
width: 100%;
\
width: 100%;
\
position: relative;
\
position: relative;
\
...
@@ -166,29 +193,29 @@ width: 100%; \
...
@@ -166,29 +193,29 @@ width: 100%; \
height: 100%;
\
height: 100%;
\
}
\
}
\
</style>
'
;
</style>
'
;
ref
.
parentNode
.
insertBefore
(
div
,
ref
);
ref
.
parentNode
.
insertBefore
(
div
,
ref
);
if
(
options
)
{
if
(
options
)
{
$
.
extend
(
settings
,
options
);
$
.
extend
(
settings
,
options
);
}
}
return
this
.
each
(
function
(){
return
this
.
each
(
function
(){
var
selectors
=
[
var
selectors
=
[
"
iframe[src^='http://player.vimeo.com']
"
,
"
iframe[src^='http://player.vimeo.com']
"
,
"
iframe[src^='http://www.youtube.com']
"
,
"
iframe[src^='http://www.youtube.com']
"
,
"
iframe[src^='http://www.kickstarter.com']
"
,
"
iframe[src^='http://www.kickstarter.com']
"
,
"
object
"
,
"
object
"
,
"
embed
"
"
embed
"
];
];
if
(
settings
.
customSelector
)
{
if
(
settings
.
customSelector
)
{
selectors
.
push
(
settings
.
customSelector
);
selectors
.
push
(
settings
.
customSelector
);
}
}
var
$allVideos
=
$
(
this
).
find
(
selectors
.
join
(
'
,
'
));
var
$allVideos
=
$
(
this
).
find
(
selectors
.
join
(
'
,
'
));
$allVideos
.
each
(
function
(){
$allVideos
.
each
(
function
(){
var
$this
=
$
(
this
),
var
$this
=
$
(
this
),
height
=
this
.
tagName
==
'
OBJECT
'
?
$this
.
attr
(
'
height
'
)
:
$this
.
height
(),
height
=
this
.
tagName
==
'
OBJECT
'
?
$this
.
attr
(
'
height
'
)
:
$this
.
height
(),
aspectRatio
=
height
/
$this
.
width
();
aspectRatio
=
height
/
$this
.
width
();
$this
.
wrap
(
'
<div class="fluid-width-video-wrapper" />
'
).
parent
(
'
.fluid-width-video-wrapper
'
).
css
(
'
padding-top
'
,
(
aspectRatio
*
100
)
+
"
%
"
);
$this
.
wrap
(
'
<div class="fluid-width-video-wrapper" />
'
).
parent
(
'
.fluid-width-video-wrapper
'
).
css
(
'
padding-top
'
,
(
aspectRatio
*
100
)
+
"
%
"
);
$this
.
removeAttr
(
'
height
'
).
removeAttr
(
'
width
'
);
$this
.
removeAttr
(
'
height
'
).
removeAttr
(
'
width
'
);
});
});
});
});
}
}
})(
jQuery
);
})(
jQuery
);
\ No newline at end of file
war/src/main/webapp/top-bar.ftl
View file @
e3088d67
...
@@ -68,7 +68,7 @@
...
@@ -68,7 +68,7 @@
B3log Solo
B3log Solo
</a>
</a>
<span class="left"> ${onlineVisitor1Label}${onlineVisitorCnt}</span>
<span class="left"> ${onlineVisitor1Label}${onlineVisitorCnt}</span>
<span class="right" id="admin">
<span class="right" id="admin"
data-login="${isLoggedIn?string}"
>
<#if isLoggedIn>
<#if isLoggedIn>
<span>${userName}</span>
<span>${userName}</span>
<#if isAdmin>
<#if isAdmin>
...
...
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