2020-04-14 21:18:37 +08:00
|
|
|
<% if(
|
2020-10-29 15:42:58 +08:00
|
|
|
theme.comment.valine.enable
|
|
|
|
&& theme.comment.valine.appid
|
|
|
|
&& theme.comment.valine.appkey
|
2020-04-14 21:18:37 +08:00
|
|
|
) { %>
|
2020-04-01 12:09:06 +08:00
|
|
|
<div class="valine-container">
|
2020-12-30 18:11:46 +08:00
|
|
|
<script <%= theme.pjax.enable === true ? 'data-pjax' : '' %>
|
|
|
|
src="//cdn.jsdelivr.net/npm/valine@latest/dist/Valine.min.js"></script>
|
2020-04-01 12:09:06 +08:00
|
|
|
<div id="vcomments"></div>
|
2020-12-30 18:11:46 +08:00
|
|
|
<script <%= theme.pjax.enable === true ? 'data-pjax' : '' %>>
|
2020-07-22 17:08:07 +08:00
|
|
|
|
2020-12-30 18:11:46 +08:00
|
|
|
function loadValine() {
|
|
|
|
const temp_valine_input_meta = '<%= theme.comment.valine.meta %>';
|
|
|
|
new Valine({
|
|
|
|
el: '#vcomments',
|
|
|
|
appId: '<%= theme.comment.valine.appid %>',
|
|
|
|
appKey: '<%= theme.comment.valine.appkey %>',
|
|
|
|
meta: temp_valine_input_meta ? temp_valine_input_meta.split(',') : ['nick', 'mail', 'link'],
|
|
|
|
avatar: 'wavatar',
|
|
|
|
enableQQ: true,
|
|
|
|
placeholder: '<%= theme.comment.valine.placeholder %>',
|
|
|
|
lang: '<%= config.language %>'.toLowerCase()
|
|
|
|
});
|
2020-10-28 22:25:26 +08:00
|
|
|
|
2020-12-30 18:11:46 +08:00
|
|
|
// Add "Author" identify
|
|
|
|
const getValineDomTimer = setInterval(() => {
|
|
|
|
const vcards = document.querySelectorAll('#vcomments .vcards .vcard');
|
|
|
|
if (vcards.length > 0) {
|
|
|
|
|
|
|
|
let author = '<%= theme.base_info.author || config.author %>';
|
|
|
|
if (author) {
|
|
|
|
author = author.toLocaleLowerCase();
|
|
|
|
}
|
2020-10-28 22:25:26 +08:00
|
|
|
|
2020-12-30 18:11:46 +08:00
|
|
|
for (let vcard of vcards) {
|
|
|
|
const vnick = vcard.querySelector('.vhead .vnick');
|
|
|
|
if (vnick.innerHTML.toLocaleLowerCase() === author) {
|
|
|
|
vcard.classList.add('author');
|
|
|
|
}
|
2020-07-22 17:08:07 +08:00
|
|
|
}
|
2020-12-30 18:11:46 +08:00
|
|
|
clearInterval(getValineDomTimer);
|
|
|
|
} else {
|
|
|
|
clearInterval(getValineDomTimer);
|
2020-07-22 17:08:07 +08:00
|
|
|
}
|
2020-12-30 18:11:46 +08:00
|
|
|
}, 2000);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ('<%= theme.pjax.enable %>') {
|
|
|
|
const loadValineTimeout = setTimeout(() => {
|
|
|
|
loadValine();
|
|
|
|
clearTimeout(loadValineTimeout);
|
|
|
|
}, 1000);
|
|
|
|
} else {
|
|
|
|
window.addEventListener('DOMContentLoaded', loadValine);
|
|
|
|
}
|
2020-04-01 12:09:06 +08:00
|
|
|
</script>
|
|
|
|
</div>
|
|
|
|
<% } %>
|