Merge pull request #576 from carolcoral/main
fix: 修复waline最近评论未自动定位到该评论的位置上
This commit is contained in:
commit
cdc78660af
|
@ -1,16 +1,16 @@
|
||||||
let halo = {
|
let halo = {
|
||||||
darkComment : ()=>{
|
darkComment: () => {
|
||||||
if(document.querySelector('#comment div').shadowRoot.querySelector('.halo-comment-widget').classList != null){
|
if (document.querySelector('#comment div').shadowRoot.querySelector('.halo-comment-widget').classList != null) {
|
||||||
let commentDOMclass = document.querySelector('#comment div').shadowRoot.querySelector('.halo-comment-widget').classList
|
let commentDOMclass = document.querySelector('#comment div').shadowRoot.querySelector('.halo-comment-widget').classList
|
||||||
if(commentDOMclass.contains('light'))
|
if (commentDOMclass.contains('light'))
|
||||||
commentDOMclass.replace('light','dark')
|
commentDOMclass.replace('light', 'dark')
|
||||||
else
|
else
|
||||||
commentDOMclass.replace('dark','light')
|
commentDOMclass.replace('dark', 'light')
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
dataCodeTheme : ()=>{
|
dataCodeTheme: () => {
|
||||||
|
|
||||||
var t = document.documentElement.getAttribute('data-theme')
|
var t = document.documentElement.getAttribute('data-theme')
|
||||||
var e = document.querySelector("link[data-code-theme=light]"),
|
var e = document.querySelector("link[data-code-theme=light]"),
|
||||||
|
@ -23,7 +23,7 @@ let halo = {
|
||||||
* 代码
|
* 代码
|
||||||
* 只适用于halo的代码渲染
|
* 只适用于halo的代码渲染
|
||||||
*/
|
*/
|
||||||
addPrismTool : ()=>{
|
addPrismTool: () => {
|
||||||
if (typeof Prism === 'undefined' || typeof document === 'undefined') {
|
if (typeof Prism === 'undefined' || typeof document === 'undefined') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ let halo = {
|
||||||
customItem.className = 'custom-item absolute top-0'
|
customItem.className = 'custom-item absolute top-0'
|
||||||
|
|
||||||
//复制
|
//复制
|
||||||
if(isEnableCopy){
|
if (isEnableCopy) {
|
||||||
var copy = document.createElement("i");
|
var copy = document.createElement("i");
|
||||||
|
|
||||||
copy.className = 'haofont hao-icon-paste copy-button code-copy cursor-pointer'
|
copy.className = 'haofont hao-icon-paste copy-button code-copy cursor-pointer'
|
||||||
|
@ -181,7 +181,7 @@ let halo = {
|
||||||
};
|
};
|
||||||
|
|
||||||
//折叠
|
//折叠
|
||||||
if(isEnableExpander){
|
if (isEnableExpander) {
|
||||||
var expander = document.createElement("i");
|
var expander = document.createElement("i");
|
||||||
expander.className = 'fa-sharp fa-solid haofont hao-icon-angle-down code-expander cursor-pointer'
|
expander.className = 'fa-sharp fa-solid haofont hao-icon-angle-down code-expander cursor-pointer'
|
||||||
customItem.appendChild(expander)
|
customItem.appendChild(expander)
|
||||||
|
@ -189,7 +189,6 @@ let halo = {
|
||||||
expander.addEventListener('click', prismToolsFn)
|
expander.addEventListener('click', prismToolsFn)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const expandCode = function () {
|
const expandCode = function () {
|
||||||
|
@ -214,12 +213,12 @@ let halo = {
|
||||||
r.classList.toggle("expand-done-expander");
|
r.classList.toggle("expand-done-expander");
|
||||||
if (toolbar.classList.contains('c-expander')) {
|
if (toolbar.classList.contains('c-expander')) {
|
||||||
r.firstElementChild.style.display = "none";
|
r.firstElementChild.style.display = "none";
|
||||||
if($nextEle.contains('code-expand-btn')){
|
if ($nextEle.contains('code-expand-btn')) {
|
||||||
r.offsetParent.lastElementChild.style.display = "none";
|
r.offsetParent.lastElementChild.style.display = "none";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
r.firstElementChild.style.display = "block";
|
r.firstElementChild.style.display = "block";
|
||||||
if($nextEle.contains('code-expand-btn') && !r.classList.contains('expand-done')){
|
if ($nextEle.contains('code-expand-btn') && !r.classList.contains('expand-done')) {
|
||||||
r.offsetParent.lastElementChild.style.display = "block";
|
r.offsetParent.lastElementChild.style.display = "block";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,7 +246,7 @@ let halo = {
|
||||||
Prism.hooks.add("complete", r)
|
Prism.hooks.add("complete", r)
|
||||||
},
|
},
|
||||||
|
|
||||||
addScript: (e,t,n)=>{
|
addScript: (e, t, n) => {
|
||||||
if (document.getElementById(e))
|
if (document.getElementById(e))
|
||||||
return n ? n() : void 0;
|
return n ? n() : void 0;
|
||||||
let a = document.createElement("script");
|
let a = document.createElement("script");
|
||||||
|
@ -257,7 +256,7 @@ let halo = {
|
||||||
document.head.appendChild(a)
|
document.head.appendChild(a)
|
||||||
},
|
},
|
||||||
|
|
||||||
danmu: ()=>{
|
danmu: () => {
|
||||||
const e = new EasyDanmakuMin({
|
const e = new EasyDanmakuMin({
|
||||||
el: "#danmu",
|
el: "#danmu",
|
||||||
line: 10,
|
line: 10,
|
||||||
|
@ -270,7 +269,7 @@ let halo = {
|
||||||
e.batchSend(t, !0);
|
e.batchSend(t, !0);
|
||||||
else {
|
else {
|
||||||
let n = [];
|
let n = [];
|
||||||
if(GLOBAL_CONFIG.source.comments.use == 'Twikoo'){
|
if (GLOBAL_CONFIG.source.comments.use == 'Twikoo') {
|
||||||
fetch(GLOBAL_CONFIG.source.twikoo.twikooUrl, {
|
fetch(GLOBAL_CONFIG.source.twikoo.twikooUrl, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
@ -282,8 +281,8 @@ let halo = {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
}
|
}
|
||||||
}).then((e=>e.json())).then((({data: t})=>{
|
}).then((e => e.json())).then((({data: t}) => {
|
||||||
t.forEach((e=>{
|
t.forEach((e => {
|
||||||
null == e.avatar && (e.avatar = "https://cravatar.cn/avatar/d615d5793929e8c7d70eab5f00f7f5f1?d=mp"),
|
null == e.avatar && (e.avatar = "https://cravatar.cn/avatar/d615d5793929e8c7d70eab5f00f7f5f1?d=mp"),
|
||||||
n.push({
|
n.push({
|
||||||
avatar: e.avatar,
|
avatar: e.avatar,
|
||||||
|
@ -298,7 +297,7 @@ let halo = {
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
if(GLOBAL_CONFIG.source.comments.use == 'Artalk'){
|
if (GLOBAL_CONFIG.source.comments.use == 'Artalk') {
|
||||||
const statheaderList = {
|
const statheaderList = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -308,12 +307,12 @@ let halo = {
|
||||||
body: new URLSearchParams({
|
body: new URLSearchParams({
|
||||||
'site_name': GLOBAL_CONFIG.source.artalk.siteName,
|
'site_name': GLOBAL_CONFIG.source.artalk.siteName,
|
||||||
'limit': '100',
|
'limit': '100',
|
||||||
'type':'latest_comments'
|
'type': 'latest_comments'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
fetch(GLOBAL_CONFIG.source.artalk.artalkUrl + 'api/stat', statheaderList)
|
fetch(GLOBAL_CONFIG.source.artalk.artalkUrl + 'api/stat', statheaderList)
|
||||||
.then((e=>e.json())).then((({data: t})=>{
|
.then((e => e.json())).then((({data: t}) => {
|
||||||
t.forEach((e=>{
|
t.forEach((e => {
|
||||||
n.push({
|
n.push({
|
||||||
avatar: 'https://cravatar.cn/avatar/' + e.email_encrypted + '?d=mp&s=240',
|
avatar: 'https://cravatar.cn/avatar/' + e.email_encrypted + '?d=mp&s=240',
|
||||||
content: e.nick + ":" + btf.changeContent(e.content_marked),
|
content: e.nick + ":" + btf.changeContent(e.content_marked),
|
||||||
|
@ -327,12 +326,12 @@ let halo = {
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
if(GLOBAL_CONFIG.source.comments.use == 'Waline'){
|
if (GLOBAL_CONFIG.source.comments.use == 'Waline') {
|
||||||
const loadWaline = () => {
|
const loadWaline = () => {
|
||||||
Waline.RecentComments({
|
Waline.RecentComments({
|
||||||
serverURL: GLOBAL_CONFIG.source.waline.serverURL,
|
serverURL: GLOBAL_CONFIG.source.waline.serverURL,
|
||||||
count: 50
|
count: 50
|
||||||
}).then(({ comments }) => {
|
}).then(({comments}) => {
|
||||||
const walineArray = comments.map(e => {
|
const walineArray = comments.map(e => {
|
||||||
return {
|
return {
|
||||||
'content': e.nick + ":" + btf.changeContent(e.comment),
|
'content': e.nick + ":" + btf.changeContent(e.comment),
|
||||||
|
@ -375,10 +374,10 @@ let halo = {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderer(values){
|
function renderer(values) {
|
||||||
var data = getArrayItems(values, 1);
|
var data = getArrayItems(values, 1);
|
||||||
let powerStar = document.getElementById("power-star")
|
let powerStar = document.getElementById("power-star")
|
||||||
if (values.length===0){
|
if (values.length === 0) {
|
||||||
powerStar.href = GLOBAL_CONFIG.source.power.powerLink
|
powerStar.href = GLOBAL_CONFIG.source.power.powerLink
|
||||||
powerStar.innerHTML = `
|
powerStar.innerHTML = `
|
||||||
<div id="power-star-image" style="background-image: url('https://redirect.cnkj.site:8099/b/2023/6583b34d95d08.webp?type=blog')">
|
<div id="power-star-image" style="background-image: url('https://redirect.cnkj.site:8099/b/2023/6583b34d95d08.webp?type=blog')">
|
||||||
|
@ -387,7 +386,7 @@ let halo = {
|
||||||
<div id="power-star-title">还没有人赞助~</div>
|
<div id="power-star-title">还没有人赞助~</div>
|
||||||
<div id="power-star-desc">为爱发电,点击赞助</div>
|
<div id="power-star-desc">为爱发电,点击赞助</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
}else {
|
} else {
|
||||||
if (powerStar) {
|
if (powerStar) {
|
||||||
powerStar.href = "https://afdian.net/u/" + data[0].user_id
|
powerStar.href = "https://afdian.net/u/" + data[0].user_id
|
||||||
powerStar.innerHTML = `
|
powerStar.innerHTML = `
|
||||||
|
@ -415,7 +414,8 @@ let halo = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function init(){
|
|
||||||
|
function init() {
|
||||||
const data = saveToLocal.get('power-data')
|
const data = saveToLocal.get('power-data')
|
||||||
if (data) {
|
if (data) {
|
||||||
renderer(JSON.parse(data))
|
renderer(JSON.parse(data))
|
||||||
|
@ -423,7 +423,20 @@ let halo = {
|
||||||
getPower()
|
getPower()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById("power-star") && init()
|
document.getElementById("power-star") && init()
|
||||||
|
},
|
||||||
|
|
||||||
|
checkAd() {
|
||||||
|
var default_enable = GLOBAL_CONFIG.source.footer.default_enable
|
||||||
|
if (default_enable) {
|
||||||
|
var adElement = document.getElementById("footer-banner");
|
||||||
|
if (adElement.offsetWidth <= 0 || adElement.offsetHeight <= 0) {
|
||||||
|
// 元素不可见,可能被拦截
|
||||||
|
console.log("Element may be blocked by AdBlocker Ultimate");
|
||||||
|
alert("页脚信息可能被AdBlocker Ultimate拦截,请检查广告拦截插件!")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
function checkOpen() {
|
||||||
|
}
|
||||||
|
|
||||||
function checkOpen() {}
|
|
||||||
checkOpen.toString = function () {
|
checkOpen.toString = function () {
|
||||||
this.opened = true;
|
this.opened = true;
|
||||||
};
|
};
|
||||||
|
@ -13,7 +14,7 @@ function coverColor() {
|
||||||
// 获取颜色 https://github.com/fast-average-color/fast-average-color
|
// 获取颜色 https://github.com/fast-average-color/fast-average-color
|
||||||
const fac = new FastAverageColor();
|
const fac = new FastAverageColor();
|
||||||
|
|
||||||
fac.getColorAsync(path,{
|
fac.getColorAsync(path, {
|
||||||
// 忽略白色
|
// 忽略白色
|
||||||
ignoredColor: [255, 255, 255, 255]
|
ignoredColor: [255, 255, 255, 255]
|
||||||
})
|
})
|
||||||
|
@ -221,7 +222,7 @@ var getTimeState = () => {
|
||||||
|
|
||||||
},
|
},
|
||||||
//深色模式切换
|
//深色模式切换
|
||||||
switchDarkMode = ()=>{
|
switchDarkMode = () => {
|
||||||
"dark" === document.documentElement.getAttribute("data-theme") ? (activateLightMode(),
|
"dark" === document.documentElement.getAttribute("data-theme") ? (activateLightMode(),
|
||||||
saveToLocal.set("theme", "light", 2),
|
saveToLocal.set("theme", "light", 2),
|
||||||
void 0 !== GLOBAL_CONFIG.Snackbar && btf.snackbarShow(GLOBAL_CONFIG.Snackbar.night_to_day, false, 2000),
|
void 0 !== GLOBAL_CONFIG.Snackbar && btf.snackbarShow(GLOBAL_CONFIG.Snackbar.night_to_day, false, 2000),
|
||||||
|
@ -232,14 +233,14 @@ var getTimeState = () => {
|
||||||
handleCases()
|
handleCases()
|
||||||
heo.darkModeStatus();
|
heo.darkModeStatus();
|
||||||
//代码块
|
//代码块
|
||||||
if(GLOBAL_CONFIG.prism.enable){
|
if (GLOBAL_CONFIG.prism.enable) {
|
||||||
halo.dataCodeTheme();
|
halo.dataCodeTheme();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
, handleCases = ()=>{
|
, handleCases = () => {
|
||||||
"function" == typeof utterancesTheme && utterancesTheme(),
|
"function" == typeof utterancesTheme && utterancesTheme(),
|
||||||
"object" == typeof FB && window.loadFBComment(),
|
"object" == typeof FB && window.loadFBComment(),
|
||||||
window.DISQUS && document.getElementById("disqus_thread").children.length && setTimeout((()=>window.disqusReset()), 200)
|
window.DISQUS && document.getElementById("disqus_thread").children.length && setTimeout((() => window.disqusReset()), 200)
|
||||||
}
|
}
|
||||||
, navFn = {
|
, navFn = {
|
||||||
switchDarkMode: switchDarkMode
|
switchDarkMode: switchDarkMode
|
||||||
|
@ -250,7 +251,7 @@ function rightMenuCommentText(txt) {
|
||||||
if (GLOBAL_CONFIG.rightMenuEnable) {
|
if (GLOBAL_CONFIG.rightMenuEnable) {
|
||||||
rm.hideRightMenu();
|
rm.hideRightMenu();
|
||||||
}
|
}
|
||||||
var input = document.getElementsByClassName(GLOBAL_CONFIG.source.comments.textarea)[0];
|
var input = document.getElementsByClassName(GLOBAL_CONFIG.source.comments.textarea)[0];
|
||||||
let evt = document.createEvent('HTMLEvents');
|
let evt = document.createEvent('HTMLEvents');
|
||||||
evt.initEvent('input', true, true);
|
evt.initEvent('input', true, true);
|
||||||
let inputValue = replaceAll(txt, '\n', '\n> ')
|
let inputValue = replaceAll(txt, '\n', '\n> ')
|
||||||
|
@ -264,6 +265,7 @@ function rightMenuCommentText(txt) {
|
||||||
document.getElementById("comment-tips").classList.add("show");
|
document.getElementById("comment-tips").classList.add("show");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//替换所有内容
|
//替换所有内容
|
||||||
function replaceAll(string, search, replace) {
|
function replaceAll(string, search, replace) {
|
||||||
return string.split(search).join(replace);
|
return string.split(search).join(replace);
|
||||||
|
@ -317,7 +319,8 @@ function travelling() {
|
||||||
renderer(json.items);
|
renderer(json.items);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
function renderer(data){
|
|
||||||
|
function renderer(data) {
|
||||||
var linksData = data
|
var linksData = data
|
||||||
var name = ''
|
var name = ''
|
||||||
var link = ''
|
var link = ''
|
||||||
|
@ -342,7 +345,8 @@ function travelling() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function init(){
|
|
||||||
|
function init() {
|
||||||
const data = saveToLocal.get('links-data')
|
const data = saveToLocal.get('links-data')
|
||||||
if (data) {
|
if (data) {
|
||||||
renderer(JSON.parse(data))
|
renderer(JSON.parse(data))
|
||||||
|
@ -350,6 +354,7 @@ function travelling() {
|
||||||
getLinks()
|
getLinks()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init()
|
init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,12 +375,12 @@ function toforeverblog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//前往开往项目
|
//前往开往项目
|
||||||
function totraveling () {
|
function totraveling() {
|
||||||
btf.snackbarShow("即将跳转到「开往」项目的成员博客,不保证跳转网站的安全性和可用性", function(element) {
|
btf.snackbarShow("即将跳转到「开往」项目的成员博客,不保证跳转网站的安全性和可用性", function (element) {
|
||||||
element.style.opacity = 0,
|
element.style.opacity = 0,
|
||||||
travellingsTimer && clearTimeout(travellingsTimer)
|
travellingsTimer && clearTimeout(travellingsTimer)
|
||||||
}, 5000, "取消"),
|
}, 5000, "取消"),
|
||||||
travellingsTimer = setTimeout(function() {
|
travellingsTimer = setTimeout(function () {
|
||||||
window.open("https://www.travellings.cn/go.html", "_blank")
|
window.open("https://www.travellings.cn/go.html", "_blank")
|
||||||
}, "5000")
|
}, "5000")
|
||||||
}
|
}
|
||||||
|
@ -426,7 +431,7 @@ function getArrayItems(arr, num) {
|
||||||
|
|
||||||
//评论增加放大功能
|
//评论增加放大功能
|
||||||
function owoBig() {
|
function owoBig() {
|
||||||
new MutationObserver((e=>{
|
new MutationObserver((e => {
|
||||||
for (let t of e)
|
for (let t of e)
|
||||||
if ("childList" === t.type)
|
if ("childList" === t.type)
|
||||||
for (let e of t.addedNodes)
|
for (let e of t.addedNodes)
|
||||||
|
@ -437,10 +442,10 @@ function owoBig() {
|
||||||
, a = document.createElement("div");
|
, a = document.createElement("div");
|
||||||
a.id = "owo-big",
|
a.id = "owo-big",
|
||||||
document.querySelector("body").appendChild(a),
|
document.querySelector("body").appendChild(a),
|
||||||
t.addEventListener("contextmenu", (e=>e.preventDefault())),
|
t.addEventListener("contextmenu", (e => e.preventDefault())),
|
||||||
t.addEventListener("mouseover", (e=>{
|
t.addEventListener("mouseover", (e => {
|
||||||
"LI" === e.target.tagName && n && (n = !1,
|
"LI" === e.target.tagName && n && (n = !1,
|
||||||
o = setTimeout((()=>{
|
o = setTimeout((() => {
|
||||||
let t = 3 * e.target.clientWidth
|
let t = 3 * e.target.clientWidth
|
||||||
, o = e.x - e.offsetX - (t - e.target.clientWidth) / 2
|
, o = e.x - e.offsetX - (t - e.target.clientWidth) / 2
|
||||||
, n = e.y - e.offsetY;
|
, n = e.y - e.offsetY;
|
||||||
|
@ -454,7 +459,7 @@ function owoBig() {
|
||||||
), 300))
|
), 300))
|
||||||
}
|
}
|
||||||
)),
|
)),
|
||||||
t.addEventListener("mouseout", (e=>{
|
t.addEventListener("mouseout", (e => {
|
||||||
a.style.display = "none",
|
a.style.display = "none",
|
||||||
n = !0,
|
n = !0,
|
||||||
clearTimeout(o)
|
clearTimeout(o)
|
||||||
|
@ -487,7 +492,7 @@ document.querySelector('#console') && document.querySelector('#console').addEven
|
||||||
// })
|
// })
|
||||||
|
|
||||||
//自动调整即刻短文尺寸
|
//自动调整即刻短文尺寸
|
||||||
window.addEventListener("resize", (function() {
|
window.addEventListener("resize", (function () {
|
||||||
document.querySelector("#waterfall") && heo.reflashEssayWaterFall()
|
document.querySelector("#waterfall") && heo.reflashEssayWaterFall()
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
@ -509,8 +514,8 @@ $(".topGroup").hover(function () {
|
||||||
function initObserver() {
|
function initObserver() {
|
||||||
var e = document.getElementById("post-comment")
|
var e = document.getElementById("post-comment")
|
||||||
, t = document.getElementById("pagination");
|
, t = document.getElementById("pagination");
|
||||||
e && new IntersectionObserver((function(e) {
|
e && new IntersectionObserver((function (e) {
|
||||||
e.forEach((function(e) {
|
e.forEach((function (e) {
|
||||||
e.isIntersecting ? (t && t.classList.add("show-window"),
|
e.isIntersecting ? (t && t.classList.add("show-window"),
|
||||||
document.querySelector(".comment-barrage").style.bottom = "-200px") : (t && t.classList.remove("show-window"),
|
document.querySelector(".comment-barrage").style.bottom = "-200px") : (t && t.classList.remove("show-window"),
|
||||||
document.querySelector(".comment-barrage").style.bottom = "0px")
|
document.querySelector(".comment-barrage").style.bottom = "0px")
|
||||||
|
@ -523,7 +528,8 @@ function initObserver() {
|
||||||
// 页面百分比
|
// 页面百分比
|
||||||
function percent() {
|
function percent() {
|
||||||
let e = document.documentElement.scrollTop || window.pageYOffset
|
let e = document.documentElement.scrollTop || window.pageYOffset
|
||||||
, t = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight) - document.documentElement.clientHeight
|
,
|
||||||
|
t = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight) - document.documentElement.clientHeight
|
||||||
, o = Math.round(e / t * 100)
|
, o = Math.round(e / t * 100)
|
||||||
, n = document.querySelector("#percent");
|
, n = document.querySelector("#percent");
|
||||||
var a = window.scrollY + document.documentElement.clientHeight
|
var a = window.scrollY + document.documentElement.clientHeight
|
||||||
|
@ -549,21 +555,22 @@ function checkUrlAndAddHideBanner() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setBodyDataType(){
|
function setBodyDataType() {
|
||||||
var body = document.body;
|
var body = document.body;
|
||||||
var att = document.createAttribute("data-type");
|
var att = document.createAttribute("data-type");
|
||||||
att.value = GLOBAL_CONFIG.htmlType;
|
att.value = GLOBAL_CONFIG.htmlType;
|
||||||
body.setAttributeNode(att);
|
body.setAttributeNode(att);
|
||||||
}
|
}
|
||||||
|
|
||||||
function listenToPageInputPress() {
|
function listenToPageInputPress() {
|
||||||
var e = document.getElementById("toPageText")
|
var e = document.getElementById("toPageText")
|
||||||
, t = document.getElementById("toPageButton");
|
, t = document.getElementById("toPageButton");
|
||||||
e && (e.addEventListener("keydown", (e=>{
|
e && (e.addEventListener("keydown", (e => {
|
||||||
13 === e.keyCode && (heo.toPage(),
|
13 === e.keyCode && (heo.toPage(),
|
||||||
pjax.loadUrl(t.href))
|
pjax.loadUrl(t.href))
|
||||||
}
|
}
|
||||||
)),
|
)),
|
||||||
e.addEventListener("input", (function() {
|
e.addEventListener("input", (function () {
|
||||||
"" === e.value || "0" === e.value ? t.classList.remove("haveValue") : t.classList.add("haveValue");
|
"" === e.value || "0" === e.value ? t.classList.remove("haveValue") : t.classList.add("haveValue");
|
||||||
var o = document.querySelectorAll(".page-number")
|
var o = document.querySelectorAll(".page-number")
|
||||||
, n = +o[o.length - 1].innerHTML;
|
, n = +o[o.length - 1].innerHTML;
|
||||||
|
@ -571,34 +578,36 @@ function listenToPageInputPress() {
|
||||||
}
|
}
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
function initBlog() {
|
function initBlog() {
|
||||||
// 图片主色
|
// 图片主色
|
||||||
GLOBAL_CONFIG.source.post.dynamicBackground && coverColor(),
|
GLOBAL_CONFIG.source.post.dynamicBackground && coverColor(),
|
||||||
GLOBAL_CONFIG.rightMenuEnable && addRightMenuClickEvent(),
|
GLOBAL_CONFIG.rightMenuEnable && addRightMenuClickEvent(),
|
||||||
percent(),
|
percent(),
|
||||||
listenToPageInputPress(),
|
listenToPageInputPress(),
|
||||||
setBodyDataType(),
|
setBodyDataType(),
|
||||||
heo.topPostScroll(),
|
heo.topPostScroll(),
|
||||||
heo.sayhi(),
|
heo.sayhi(),
|
||||||
heo.stopImgRightDrag(),
|
heo.stopImgRightDrag(),
|
||||||
heo.addPowerLinksInPostRightSide(),
|
heo.addPowerLinksInPostRightSide(),
|
||||||
heo.qrcodeCreate(),
|
heo.qrcodeCreate(),
|
||||||
//右下角 snackbar 弹窗
|
//右下角 snackbar 弹窗
|
||||||
GLOBAL_CONFIG.source.tool.switch && heo.hidecookie(),
|
GLOBAL_CONFIG.source.tool.switch && heo.hidecookie(),
|
||||||
heo.onlyHome(),
|
heo.onlyHome(),
|
||||||
heo.addNavBackgroundInit(),
|
heo.addNavBackgroundInit(),
|
||||||
heo.initIndexEssay(),
|
heo.initIndexEssay(),
|
||||||
heo.reflashEssayWaterFall(),
|
heo.reflashEssayWaterFall(),
|
||||||
heo.darkModeStatus(),
|
heo.darkModeStatus(),
|
||||||
heo.categoriesBarActive(),
|
heo.categoriesBarActive(),
|
||||||
heo.initThemeColor(),
|
heo.initThemeColor(),
|
||||||
heo.topCategoriesBarScroll(),
|
heo.topCategoriesBarScroll(),
|
||||||
//隐藏加载动画
|
//隐藏加载动画
|
||||||
GLOBAL_CONFIG.loadingBox && heo.hideLoading(),
|
GLOBAL_CONFIG.loadingBox && heo.hideLoading(),
|
||||||
heo.tagPageActive(),
|
heo.tagPageActive(),
|
||||||
initObserver(),
|
initObserver(),
|
||||||
checkUrlAndAddHideBanner(),
|
checkUrlAndAddHideBanner(),
|
||||||
halo.getTopSponsors()
|
halo.getTopSponsors(),
|
||||||
|
halo.checkAd()
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -786,11 +795,11 @@ if (getCookie('browsertc') != 1) {
|
||||||
//注入函数
|
//注入函数
|
||||||
document.addEventListener('pjax:click', function () {
|
document.addEventListener('pjax:click', function () {
|
||||||
//显示加载进度条
|
//显示加载进度条
|
||||||
if(GLOBAL_CONFIG.loadProgressBar){
|
if (GLOBAL_CONFIG.loadProgressBar) {
|
||||||
Pace.restart();
|
Pace.restart();
|
||||||
}
|
}
|
||||||
//显示加载动画
|
//显示加载动画
|
||||||
if(GLOBAL_CONFIG.loadingBox){
|
if (GLOBAL_CONFIG.loadingBox) {
|
||||||
heo.showLoading();
|
heo.showLoading();
|
||||||
}
|
}
|
||||||
})
|
})
|
|
@ -8,11 +8,14 @@
|
||||||
isHome: [[${ htmlType == 'index'}]],
|
isHome: [[${ htmlType == 'index'}]],
|
||||||
copyright: undefined,
|
copyright: undefined,
|
||||||
lightbox: 'fancybox',
|
lightbox: 'fancybox',
|
||||||
lazyload: {enable: [[${theme.config.other.vanillaLazyload.enable}]], error: [[@{${theme.config.other.vanillaLazyload.errorImg}}]] },
|
lazyload: {
|
||||||
|
enable: [[${theme.config.other.vanillaLazyload.enable}]],
|
||||||
|
error: [[@{${theme.config.other.vanillaLazyload.errorImg}}]]
|
||||||
|
},
|
||||||
isFriendLinksInFooter: [[${theme.config.footer.footer_group.enable_footer_group}]],
|
isFriendLinksInFooter: [[${theme.config.footer.footer_group.enable_footer_group}]],
|
||||||
loadingBox: [[${theme.config.other.loadingBoxs.loadingBoxEnable}]],
|
loadingBox: [[${theme.config.other.loadingBoxs.loadingBoxEnable}]],
|
||||||
loadProgressBar: [[${theme.config.other.loadingBoxs.loadProgressBar}]],
|
loadProgressBar: [[${theme.config.other.loadingBoxs.loadProgressBar}]],
|
||||||
navMusicEnable:[[${theme.config.tool.nav_music.nav_musicEnable}]],
|
navMusicEnable: [[${theme.config.tool.nav_music.nav_musicEnable}]],
|
||||||
isMusic: [[${ htmlType == 'music'}]],
|
isMusic: [[${ htmlType == 'music'}]],
|
||||||
helloText: [[${#strings.listSplit(theme.config.sidebar.profile.helloText, ',')}]],
|
helloText: [[${#strings.listSplit(theme.config.sidebar.profile.helloText, ',')}]],
|
||||||
profileStyle: [[${theme.config.sidebar.profile.profileStyle}]],
|
profileStyle: [[${theme.config.sidebar.profile.profileStyle}]],
|
||||||
|
@ -34,12 +37,12 @@
|
||||||
position: "top-center",
|
position: "top-center",
|
||||||
},
|
},
|
||||||
translate: {
|
translate: {
|
||||||
defaultEncoding:[[${theme.config.style.translate.defaultEncoding}]],
|
defaultEncoding: [[${theme.config.style.translate.defaultEncoding}]],
|
||||||
translateDelay:0,
|
translateDelay: 0,
|
||||||
msgToTraditionalChinese:"繁",
|
msgToTraditionalChinese: "繁",
|
||||||
msgToSimplifiedChinese:"简",
|
msgToSimplifiedChinese: "简",
|
||||||
rightMenuMsgToTraditionalChinese:"轉為繁體",
|
rightMenuMsgToTraditionalChinese: "轉為繁體",
|
||||||
rightMenuMsgToSimplifiedChinese:"转为简体"
|
rightMenuMsgToSimplifiedChinese: "转为简体"
|
||||||
},
|
},
|
||||||
prism: {
|
prism: {
|
||||||
enable: [[${ theme.config.code.enable }]],
|
enable: [[${ theme.config.code.enable }]],
|
||||||
|
@ -48,15 +51,15 @@
|
||||||
enable_line: [[${ theme.config.code.enable_line }]],
|
enable_line: [[${ theme.config.code.enable_line }]],
|
||||||
enable_copy: [[${ theme.config.code.enable_copy }]],
|
enable_copy: [[${ theme.config.code.enable_copy }]],
|
||||||
enable_expander: [[${ theme.config.code.enable_expander }]],
|
enable_expander: [[${ theme.config.code.enable_expander }]],
|
||||||
prism_limit: Number([[${#strings.isEmpty(theme.config.code.height_limit) ? 300 : theme.config.code.height_limit}]])+30,
|
prism_limit: Number([[${#strings.isEmpty(theme.config.code.height_limit) ? 300 : theme.config.code.height_limit}]]) + 30,
|
||||||
enable_height_limit: [[${theme.config.code.enable_height_limit}]]
|
enable_height_limit: [[${theme.config.code.enable_height_limit}]]
|
||||||
},
|
},
|
||||||
source: {
|
source: {
|
||||||
power:{
|
power: {
|
||||||
powerLink: [[${theme.config.sidebar.power.powerLink}]],
|
powerLink: [[${theme.config.sidebar.power.powerLink}]],
|
||||||
url:[[${theme.config.sidebar.power.url}]],
|
url: [[${theme.config.sidebar.power.url}]],
|
||||||
userId:[[${theme.config.sidebar.power.userId}]],
|
userId: [[${theme.config.sidebar.power.userId}]],
|
||||||
showNum:[[${theme.config.sidebar.power.showNum}]]
|
showNum: [[${theme.config.sidebar.power.showNum}]]
|
||||||
},
|
},
|
||||||
links: {
|
links: {
|
||||||
linksUrl: [[${ theme.config.link.linksUrl }]],
|
linksUrl: [[${ theme.config.link.linksUrl }]],
|
||||||
|
@ -71,7 +74,7 @@
|
||||||
js: 'https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/fancybox/3.5.7/jquery.fancybox.min.js',
|
js: 'https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/fancybox/3.5.7/jquery.fancybox.min.js',
|
||||||
css: '/null'
|
css: '/null'
|
||||||
},
|
},
|
||||||
comments:{
|
comments: {
|
||||||
use: [[${theme.config.comments.use}]],
|
use: [[${theme.config.comments.use}]],
|
||||||
maxBarrage: [[${ theme.config.comments.commentBarrageConfig.maxBarrage }]],
|
maxBarrage: [[${ theme.config.comments.commentBarrageConfig.maxBarrage }]],
|
||||||
barrageTime: [[${ theme.config.comments.commentBarrageConfig.barrageTime }]],
|
barrageTime: [[${ theme.config.comments.commentBarrageConfig.barrageTime }]],
|
||||||
|
@ -81,53 +84,54 @@
|
||||||
theme.config.comments.use == 'Artalk' ? 'atk-textarea' :
|
theme.config.comments.use == 'Artalk' ? 'atk-textarea' :
|
||||||
theme.config.comments.use == 'Waline' ? 'wl-editor' : 'appearance-none' }]]
|
theme.config.comments.use == 'Waline' ? 'wl-editor' : 'appearance-none' }]]
|
||||||
},
|
},
|
||||||
welcome:{
|
welcome: {
|
||||||
key:"[(${theme.config.sidebar.welcome.key})]",
|
key: "[(${theme.config.sidebar.welcome.key})]",
|
||||||
locationLng: [[${theme.config.sidebar.welcome.locationLng}]],
|
locationLng: [[${theme.config.sidebar.welcome.locationLng}]],
|
||||||
locationLat: [[${theme.config.sidebar.welcome.locationLat}]]
|
locationLat: [[${theme.config.sidebar.welcome.locationLat}]]
|
||||||
},
|
},
|
||||||
post:{
|
post: {
|
||||||
dynamicBackground: [[${ theme.config.post.dynamicBackground }]]
|
dynamicBackground: [[${ theme.config.post.dynamicBackground }]]
|
||||||
},
|
},
|
||||||
tool:{
|
tool: {
|
||||||
switch: [[${ theme.config.tool.snackbar.switch }]]
|
switch: [[${ theme.config.tool.snackbar.switch }]]
|
||||||
},
|
},
|
||||||
postAi:{
|
postAi: {
|
||||||
ai : [[${htmlType != 'post' || !theme.config.post.aiDescription.aiDescriptionEnable ? '' :
|
ai: [[${htmlType != 'post' || !theme.config.post.aiDescription.aiDescriptionEnable ? '' :
|
||||||
theme.config.post.aiDescription.mode != 'local' && !theme.config.post.aiDescription.switchBtn ? '' :
|
theme.config.post.aiDescription.mode != 'local' && !theme.config.post.aiDescription.switchBtn ? '' :
|
||||||
post.spec.excerpt.autoGenerate ? '本地模式需要自己填写文章摘要' :
|
post.spec.excerpt.autoGenerate ? '本地模式需要自己填写文章摘要' :
|
||||||
#strings.isEmpty(post.status.excerpt) ? '请填写文章摘要' : post.status.excerpt }]],
|
#strings.isEmpty(post.status.excerpt) ? '请填写文章摘要' : post.status.excerpt }]],
|
||||||
randomNum : [[${theme.config.post.aiDescription.randomNum}]],
|
randomNum: [[${theme.config.post.aiDescription.randomNum}]],
|
||||||
basicWordCount : [[${theme.config.post.aiDescription.basicWordCount}]],
|
basicWordCount: [[${theme.config.post.aiDescription.basicWordCount}]],
|
||||||
btnLink : "[(${theme.config.post.aiDescription.btnLink})]",
|
btnLink: "[(${theme.config.post.aiDescription.btnLink})]",
|
||||||
gptName : "[(${theme.config.post.aiDescription.gptName})]",
|
gptName: "[(${theme.config.post.aiDescription.gptName})]",
|
||||||
modeName : [[${theme.config.post.aiDescription.mode}]],
|
modeName: [[${theme.config.post.aiDescription.mode}]],
|
||||||
switchBtn : [[${theme.config.post.aiDescription.switchBtn}]],
|
switchBtn: [[${theme.config.post.aiDescription.switchBtn}]],
|
||||||
keys : "[(${theme.config.post.aiDescription.key})]",
|
keys: "[(${theme.config.post.aiDescription.key})]",
|
||||||
Referers : "[(${theme.config.post.aiDescription.Referer})]",
|
Referers: "[(${theme.config.post.aiDescription.Referer})]",
|
||||||
},
|
},
|
||||||
img:{
|
img: {
|
||||||
src: [[${isLazyload ? 'data-lazy-src' : 'src' }]]
|
src: [[${isLazyload ? 'data-lazy-src' : 'src' }]]
|
||||||
},
|
},
|
||||||
twikoo:{
|
twikoo: {
|
||||||
js:[[${not #strings.isEmpty(theme.config.comments.twikoos.js) ? theme.config.comments.twikoos.js : assets_link +'/libs/twikoo/twikoo.all.min.js' }]],
|
js: [[${not #strings.isEmpty(theme.config.comments.twikoos.js) ? theme.config.comments.twikoos.js : assets_link +'/libs/twikoo/twikoo.all.min.js' }]],
|
||||||
twikooUrl: "[(${theme.config.comments.twikoos.envId})]",
|
twikooUrl: "[(${theme.config.comments.twikoos.envId})]",
|
||||||
accessToken: "[(${theme.config.comments.twikoos.accessToken})]",
|
accessToken: "[(${theme.config.comments.twikoos.accessToken})]",
|
||||||
|
|
||||||
},
|
},
|
||||||
artalk:{
|
artalk: {
|
||||||
js:[[${not #strings.isEmpty(theme.config.comments.artalks.artalkJs) ? theme.config.comments.artalks.artalkJs : assets_link +'/libs/artalk/Artalk.js' }]],
|
js: [[${not #strings.isEmpty(theme.config.comments.artalks.artalkJs) ? theme.config.comments.artalks.artalkJs : assets_link +'/libs/artalk/Artalk.js' }]],
|
||||||
css:[[${not #strings.isEmpty(theme.config.comments.artalks.artalkCss) ? theme.config.comments.artalks.artalkCss : assets_link +'/libs/artalk/Artalk.css' }]],
|
css: [[${not #strings.isEmpty(theme.config.comments.artalks.artalkCss) ? theme.config.comments.artalks.artalkCss : assets_link +'/libs/artalk/Artalk.css' }]],
|
||||||
artalkUrl: "[(${theme.config.comments.artalks.server})]",
|
artalkUrl: "[(${theme.config.comments.artalks.server})]",
|
||||||
siteName: "[(${theme.config.comments.artalks.siteName})]",
|
siteName: "[(${theme.config.comments.artalks.siteName})]",
|
||||||
},
|
},
|
||||||
waline:{
|
waline: {
|
||||||
js:[[${not #strings.isEmpty(theme.config.comments.walines.walinesJs) ? theme.config.comments.walines.walinesJs : 'https://cdn.cbd.int/@waline/client@2.15.7/dist/waline.js' }]],
|
js: [[${not #strings.isEmpty(theme.config.comments.walines.walinesJs) ? theme.config.comments.walines.walinesJs : 'https://cdn.cbd.int/@waline/client@2.15.7/dist/waline.js' }]],
|
||||||
serverURL: "[(${theme.config.comments.walines.serverURL})]",
|
serverURL: "[(${theme.config.comments.walines.serverURL})]",
|
||||||
locale: [(${not #strings.isEmpty(theme.config.comments.walines.locale) ? theme.config.comments.walines.locale : {} })]
|
locale: [[${not #strings.isEmpty(theme.config.comments.walines.locale) ? theme.config.comments.walines.locale : '' }]]
|
||||||
},
|
},
|
||||||
},
|
footer: {
|
||||||
|
default_enable: [[${theme.config.footer.footerContent.default_enable}]]
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue