49 lines
1.6 KiB
Plaintext
49 lines
1.6 KiB
Plaintext
<script>
|
|
function getEmojiMaps() {
|
|
function emoji(path, idx, ext) {
|
|
return path + "/" + path + "-" + idx + "." + ext;
|
|
}
|
|
var emojiMaps = {};
|
|
for (var i = 1; i <= 54; i++) {
|
|
emojiMaps['tieba-' + i] = emoji('tieba', i, 'png');
|
|
}
|
|
for (var i = 1; i <= 101; i++) {
|
|
emojiMaps['qq-' + i] = emoji('qq', i, 'gif');
|
|
}
|
|
for (var i = 1; i <= 116; i++) {
|
|
emojiMaps['aru-' + i] = emoji('aru', i, 'gif');
|
|
}
|
|
for (var i = 1; i <= 125; i++) {
|
|
emojiMaps['twemoji-' + i] = emoji('twemoji', i, 'png');
|
|
}
|
|
for (var i = 1; i <= 4; i++) {
|
|
emojiMaps['weibo-' + i] = emoji('weibo', i, 'png');
|
|
}
|
|
return emojiMaps;
|
|
}
|
|
function load_comment(){
|
|
if(!document.getElementById("valine_container"))return;
|
|
stellar.loadScript('<%- theme.comments.valine.js %>', {defer:true}).then(function () {
|
|
const el = document.getElementById("valine_container");
|
|
var path = el.getAttribute('comment_id');
|
|
const placeholder = "<%= theme.comments.valine.placeholder %>";
|
|
if (!path) {
|
|
path = decodeURI(window.location.pathname);
|
|
}
|
|
var valine = new Valine();
|
|
valine.init(Object.assign(<%- JSON.stringify(theme.comments.valine) %>, {
|
|
el: '#valine_container',
|
|
path: path,
|
|
placeholder: placeholder,
|
|
emojiCDN: 'https://fastly.jsdelivr.net/gh/volantis-x/cdn-emoji/valine/',
|
|
emojiMaps: getEmojiMaps(),
|
|
}));
|
|
});
|
|
}
|
|
window.addEventListener('DOMContentLoaded', (event) => {
|
|
console.log('DOM fully loaded and parsed');
|
|
load_comment();
|
|
});
|
|
|
|
</script>
|