js 格式化,需要重新整理

This commit is contained in:
liuzhihang 2022-10-25 09:20:13 +08:00
parent f1494b23e2
commit a83d08df13
5 changed files with 2032 additions and 728 deletions

View File

@ -1,126 +1,309 @@
"use strict";
var heo_keyboard = !0, heo = {
darkModeStatus: function () {
"light" == ("dark" === document.documentElement.getAttribute("data-theme") ? "dark" : "light") ? $(".menu-darkmode-text").text("深色模式") : $(".menu-darkmode-text").text("浅色模式")
},
onlyHome: function () {
var e = window.location.pathname;
"/" == (e = decodeURIComponent(e)) ? $(".only-home").attr("style", "display: flex") : $(".only-home").attr("style", "display: none")
},
is_Post: function () {
return 0 <= window.location.href.indexOf("/p/")
},
addNavBackgroundInit: function () {
var e, t = 0, o = 0;
document.body && (t = document.body.scrollTop), document.documentElement && (o = document.documentElement.scrollTop), e = 0 < t - o ? t : o, 0 != e && (document.getElementById("page-header").classList.add("nav-fixed"), document.getElementById("page-header").classList.add("nav-visible"), $("#cookies-window").hide(), console.log("已添加class"))
},
tagPageActive: function () {
var e = window.location.pathname, e = decodeURIComponent(e);
console.log(e);
var t, o, n = /\/tags\/.*?\//.test(e);
console.log(n), n && (t = e.split("/"), console.log(t[2]), o = t[2], document.querySelector("#tag-page-tags") && document.getElementById(o).classList.add("select"))
},
categoriesBarActive: function () {
document.querySelector("#category-bar") && $(".category-bar-item").removeClass("select");
var e, t = window.location.pathname, t = decodeURIComponent(t);
"/" == t ? document.querySelector("#category-bar") && document.getElementById("category-bar-home").classList.add("select") : /\/categories\/.*?\//.test(t) && (e = t.split("/")[2], document.querySelector("#category-bar") && document.getElementById(e).classList.add("select"))
},
stopImgRightDrag: function () {
$("img").on("dragstart", function () {
return !1
})
},
topPostScroll: function () {
var o;
document.getElementById("recent-post-top") && (o = document.getElementById("recent-post-top")).addEventListener("mousewheel", function (e) {
var t = -e.wheelDelta / 2;
o.scrollLeft += t, document.body.clientWidth < 1300 && e.preventDefault()
}, !1)
},
topCategoriesBarScroll: function () {
var o;
document.getElementById("category-bar-items") && (o = document.getElementById("category-bar-items")).addEventListener("mousewheel", function (e) {
var t = -e.wheelDelta / 2;
o.scrollLeft += t, e.preventDefault()
}, !1)
},
sayhi: function () {
document.querySelector("#author-info__sayhi") && (document.getElementById("author-info__sayhi").innerHTML = getTimeState() + "!我是")
},
addTag: function () {
document.querySelector(".heo-tag-new") && $(".heo-tag-new").append('<sup class="heo-tag heo-tag-new-view">N</sup>'), document.querySelector(".heo-tag-hot") && $(".heo-tag-hot").append('<sup class="heo-tag heo-tag-hot-view">H</sup>')
},
qrcodeCreate: function () {
document.getElementById("qrcode") && new QRCode(document.getElementById("qrcode"), {
text: window.location.href,
width: 250,
height: 250,
colorDark: "#000",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.H
})
},
reflashEssayWaterFall: function () {
document.querySelector("#waterfall") && setTimeout(function () {
waterfall("#waterfall"), document.getElementById("waterfall").classList.add("show")
}, 500)
},
addMediumInEssay: function () {
document.querySelector("#waterfall") && mediumZoom(document.querySelectorAll("[data-zoomable]"))
},
downloadImage: function (e, c) {
rm.hideRightMenu(), 0 == rm.downloadimging ? (rm.downloadimging = !0, btf.snackbarShow("正在下载中,请稍后", !1, 1e4), setTimeout(function () {
var a = new Image;
a.setAttribute("crossOrigin", "anonymous"), a.onload = function () {
var e = document.createElement("canvas");
e.width = a.width, e.height = a.height, e.getContext("2d").drawImage(a, 0, 0, a.width, a.height);
var t = e.toDataURL("image/png"), o = document.createElement("a"), n = new MouseEvent("click");
o.download = c || "photo", o.href = t, o.dispatchEvent(n)
}, a.src = e, btf.snackbarShow("图片已添加盲水印,请遵守版权协议"), rm.downloadimging = !1
}, "10000")) : btf.snackbarShow("有正在进行中的下载,请稍后再试")
},
changeThemeColor: function (e) {
null !== document.querySelector('meta[name="theme-color"]') && document.querySelector('meta[name="theme-color"]').setAttribute("content", e)
},
initThemeColor: function () {
var e, t, o;
heo.is_Post() ? 0 === (window.scrollY || document.documentElement.scrollTop) ? (e = getComputedStyle(document.documentElement).getPropertyValue("--heo-main"), heo.changeThemeColor(e)) : (t = getComputedStyle(document.documentElement).getPropertyValue("--heo-background"), heo.changeThemeColor(t)) : (o = getComputedStyle(document.documentElement).getPropertyValue("--heo-background"), heo.changeThemeColor(o))
},
showLoading: function () {
document.querySelector("#loading-box").classList.remove("loaded")
},
hideLoading: function () {
document.querySelector("#loading-box").classList.add("loaded")
},
showConsole: function () {
document.querySelector("#console").classList.add("show")
},
hideConsole: function () {
document.querySelector("#console").classList.remove("show")
},
keyboardToggle: function () {
heo_keyboard ? (heo_keyboard = !1, document.querySelector("#consoleKeyboard").classList.remove("on"), localStorage.setItem("keyboardToggle", "false")) : (heo_keyboard = !0, document.querySelector("#consoleKeyboard").classList.add("on"), localStorage.setItem("keyboardToggle", "true"))
}
};
var heo_cookiesTime = null,
heo_musicPlaying = !1,
heo_keyboard = !0,
heo_intype = !1,
heo = {
darkModeStatus: function () {
"light" ==
("dark" === document.documentElement.getAttribute("data-theme")
? "dark"
: "light")
? $(".menu-darkmode-text").text("深色模式")
: $(".menu-darkmode-text").text("浅色模式");
},
changeTimeInEssay: function () {
document.querySelector("#bber") &&
document.querySelectorAll("#bber time").forEach(function (e) {
var t = e,
o = t.getAttribute("datetime");
(t.innerText = btf.diffDate(o, !0)), (t.style.display = "inline");
});
},
initIndexEssay: function () {
document.querySelector("#bber-talk") &&
new Swiper(".swiper-container", {
direction: "vertical",
loop: !0,
autoplay: {delay: 3e3, pauseOnMouseEnter: !0},
});
},
onlyHome: function () {
var e = window.location.pathname;
"/" == (e = decodeURIComponent(e))
? $(".only-home").attr("style", "display: flex")
: $(".only-home").attr("style", "display: none");
},
is_Post: function () {
return 0 <= window.location.href.indexOf("/p/");
},
addNavBackgroundInit: function () {
var e,
t = 0,
o = 0;
document.body && (t = document.body.scrollTop),
document.documentElement && (o = document.documentElement.scrollTop),
(e = 0 < t - o ? t : o),
console.log("滚动高度" + e),
0 != e &&
(document.getElementById("page-header").classList.add("nav-fixed"),
document.getElementById("page-header").classList.add("nav-visible"),
$("#cookies-window").hide(),
console.log("已添加class"));
},
tagPageActive: function () {
var e = window.location.pathname,
e = decodeURIComponent(e);
console.log(e);
var t,
o,
n = /\/tags\/.*?\//.test(e);
console.log(n),
n &&
((t = e.split("/")),
console.log(t[2]),
(o = t[2]),
document.querySelector("#tag-page-tags") &&
document.getElementById(o).classList.add("select"));
},
categoriesBarActive: function () {
document.querySelector("#category-bar") &&
$(".category-bar-item").removeClass("select");
var e,
t = window.location.pathname,
t = decodeURIComponent(t);
console.log(t),
"/" == t
? document.querySelector("#category-bar") &&
document.getElementById("category-bar-home").classList.add("select")
: /\/categories\/.*?\//.test(t) &&
((e = t.split("/")[2]),
document.querySelector("#category-bar") &&
document.getElementById(e).classList.add("select"));
},
addFriendLinksInFooter: function () {
fetch("https://moments.zhheo.com/randomfriend?num=3")
.then(function (e) {
return e.json();
})
.then(function (e) {
for (var t = getArrayItems(e, 3), o = "", n = 0; n < t.length; ++n) {
var a = t[n];
o += "<a class='footer-item' href='"
.concat(a.link, '\' target="_blank" rel="noopener nofollow">')
.concat(a.name, "</a>");
}
(o += "<a class='footer-item' href='/link/'>更多</a>"),
(document.getElementById("friend-links-in-footer").innerHTML = o);
});
},
stopImgRightDrag: function () {
$("img").on("dragstart", function () {
return !1;
});
},
topPostScroll: function () {
var o;
document.getElementById("recent-post-top") &&
(o = document.getElementById("recent-post-top")).addEventListener(
"mousewheel",
function (e) {
var t = -e.wheelDelta / 2;
(o.scrollLeft += t),
document.body.clientWidth < 1300 && e.preventDefault();
},
!1
);
},
topCategoriesBarScroll: function () {
var o;
document.getElementById("category-bar-items") &&
(o = document.getElementById("category-bar-items")).addEventListener(
"mousewheel",
function (e) {
var t = -e.wheelDelta / 2;
(o.scrollLeft += t), e.preventDefault();
},
!1
);
},
sayhi: function () {
document.querySelector("#author-info__sayhi") &&
(document.getElementById("author-info__sayhi").innerHTML =
getTimeState() + "!我是");
},
addTag: function () {
document.querySelector(".heo-tag-new") &&
$(".heo-tag-new").append(
'<sup class="heo-tag heo-tag-new-view">N</sup>'
),
document.querySelector(".heo-tag-hot") &&
$(".heo-tag-hot").append(
'<sup class="heo-tag heo-tag-hot-view">H</sup>'
);
},
qrcodeCreate: function () {
document.getElementById("qrcode") &&
((document.getElementById("qrcode").innerHTML = ""),
new QRCode(document.getElementById("qrcode"), {
text: window.location.href,
width: 250,
height: 250,
colorDark: "#000",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.H,
}));
},
reflashEssayWaterFall: function () {
document.querySelector("#waterfall") &&
setTimeout(function () {
waterfall("#waterfall"),
document.getElementById("waterfall").classList.add("show");
}, 500);
},
addMediumInEssay: function () {
document.querySelector("#waterfall") &&
mediumZoom(document.querySelectorAll("[data-zoomable]"));
},
downloadImage: function (e, c) {
rm.hideRightMenu(),
0 == rm.downloadimging
? ((rm.downloadimging = !0),
btf.snackbarShow("正在下载中,请稍后", !1, 1e4),
setTimeout(function () {
var a = new Image();
a.setAttribute("crossOrigin", "anonymous"),
(a.onload = function () {
var e = document.createElement("canvas");
(e.width = a.width),
(e.height = a.height),
e.getContext("2d").drawImage(a, 0, 0, a.width, a.height);
var t = e.toDataURL("image/png"),
o = document.createElement("a"),
n = new MouseEvent("click");
(o.download = c || "photo"), (o.href = t), o.dispatchEvent(n);
}),
(a.src = e),
btf.snackbarShow("图片已添加盲水印,请遵守版权协议"),
(rm.downloadimging = !1);
}, "10000"))
: btf.snackbarShow("有正在进行中的下载,请稍后再试");
},
switchCommentBarrage: function () {
document.querySelector(".comment-barrage") &&
($(".comment-barrage").is(":visible")
? ($(".comment-barrage").hide(),
$(".menu-commentBarrage-text").text("显示热评"),
document
.querySelector("#consoleCommentBarrage")
.classList.remove("on"),
localStorage.setItem("commentBarrageSwitch", "false"))
: $(".comment-barrage").is(":hidden") &&
($(".comment-barrage").show(),
$(".menu-commentBarrage-text").text("关闭热评"),
document
.querySelector("#consoleCommentBarrage")
.classList.add("on"),
localStorage.removeItem("commentBarrageSwitch"))),
rm.hideRightMenu();
},
hidecookie: function () {
heo_cookiesTime = setTimeout(function () {
document.getElementById("cookies-window").classList.add("cw-hide"),
setTimeout(function () {
$("#cookies-window").hide();
}, 1e3);
}, 3e3);
},
hideTodayCard: function () {
document.getElementById("todayCard") &&
document.getElementById("todayCard").classList.add("hide");
},
changeThemeColor: function (e) {
null !== document.querySelector('meta[name="theme-color"]') &&
document
.querySelector('meta[name="theme-color"]')
.setAttribute("content", e);
},
initThemeColor: function () {
var e, t, o;
heo.is_Post()
? 0 === (window.scrollY || document.documentElement.scrollTop)
? ((e = getComputedStyle(document.documentElement).getPropertyValue(
"--heo-main"
)),
heo.changeThemeColor(e))
: ((t = getComputedStyle(document.documentElement).getPropertyValue(
"--heo-background"
)),
heo.changeThemeColor(t))
: ((o = getComputedStyle(document.documentElement).getPropertyValue(
"--heo-background"
)),
heo.changeThemeColor(o));
},
jumpTo: function (e) {
$(document).ready(function () {
$("html,body").animate({scrollTop: $(e).eq(i).offset().top}, 500);
});
},
showLoading: function () {
document.querySelector("#loading-box").classList.remove("loaded");
var e = getComputedStyle(document.documentElement).getPropertyValue(
"--heo-card-bg"
);
heo.changeThemeColor(e);
},
hideLoading: function () {
document.querySelector("#loading-box").classList.add("loaded");
},
musicToggle: function () {
(heo_musicPlaying = heo_musicPlaying
? (document.querySelector("#nav-music").classList.remove("playing"),
(document.getElementById("menu-music-toggle").innerHTML =
'<i class="fa-solid fa-play"></i><span>播放音乐</span>'),
(document.getElementById("nav-music-hoverTips").innerHTML =
"音乐已暂停"),
document.querySelector("#consoleMusic").classList.remove("on"),
!1)
: (document.querySelector("#nav-music").classList.add("playing"),
(document.getElementById("menu-music-toggle").innerHTML =
'<i class="fa-solid fa-pause"></i><span>暂停音乐</span>'),
document.querySelector("#consoleMusic").classList.add("on"),
!0)),
document.querySelector("meting-js").aplayer.toggle(),
rm.hideRightMenu();
},
musicSkipBack: function () {
document.querySelector("meting-js").aplayer.skipBack(),
rm.hideRightMenu();
},
musicSkipForward: function () {
document.querySelector("meting-js").aplayer.skipForward(),
rm.hideRightMenu();
},
musicGetName: function () {
for (var e = $(".aplayer-title"), t = [], o = e.length - 1; 0 <= o; o--)
t[o] = e[o].innerText;
return t[0];
},
showConsole: function () {
document.querySelector("#console").classList.add("show");
},
hideConsole: function () {
document.querySelector("#console").classList.remove("show");
},
keyboardToggle: function () {
heo_keyboard
? ((heo_keyboard = !1),
document.querySelector("#consoleKeyboard").classList.remove("on"),
localStorage.setItem("keyboardToggle", "false"))
: ((heo_keyboard = !0),
document.querySelector("#consoleKeyboard").classList.add("on"),
localStorage.setItem("keyboardToggle", "true"));
},
scrollTo: function (e) {
var t = document.querySelector(e).offsetTop;
window.scrollTo(0, t - 80);
},
};

View File

@ -1,232 +1,765 @@
"use strict";
function _typeof(t) {
return (_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (t) {
return typeof t
} : function (t) {
return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t
})(t)
return (_typeof =
"function" == typeof Symbol && "symbol" == typeof Symbol.iterator
? function (t) {
return typeof t;
}
: function (t) {
return t &&
"function" == typeof Symbol &&
t.constructor === Symbol &&
t !== Symbol.prototype
? "symbol"
: typeof t;
})(t);
}
function _toConsumableArray(t) {
return _arrayWithoutHoles(t) || _iterableToArray(t) || _unsupportedIterableToArray(t) || _nonIterableSpread()
return (
_arrayWithoutHoles(t) ||
_iterableToArray(t) ||
_unsupportedIterableToArray(t) ||
_nonIterableSpread()
);
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
throw new TypeError(
"Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
);
}
function _unsupportedIterableToArray(t, e) {
if (t) {
if ("string" == typeof t) return _arrayLikeToArray(t, e);
var n = Object.prototype.toString.call(t).slice(8, -1);
return "Object" === n && t.constructor && (n = t.constructor.name), "Map" === n || "Set" === n ? Array.from(t) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? _arrayLikeToArray(t, e) : void 0
return (
"Object" === n && t.constructor && (n = t.constructor.name),
"Map" === n || "Set" === n
? Array.from(t)
: "Arguments" === n ||
/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)
? _arrayLikeToArray(t, e)
: void 0
);
}
}
function _iterableToArray(t) {
if ("undefined" != typeof Symbol && null != t[Symbol.iterator] || null != t["@@iterator"]) return Array.from(t)
if (
("undefined" != typeof Symbol && null != t[Symbol.iterator]) ||
null != t["@@iterator"]
)
return Array.from(t);
}
function _arrayWithoutHoles(t) {
if (Array.isArray(t)) return _arrayLikeToArray(t)
if (Array.isArray(t)) return _arrayLikeToArray(t);
}
function _arrayLikeToArray(t, e) {
(null == e || e > t.length) && (e = t.length);
for (var n = 0, o = new Array(e); n < e; n++) o[n] = t[n];
return o
return o;
}
document.addEventListener("DOMContentLoaded", function () {
function L(t) {
0 < arguments.length && void 0 !== t && t && (i = o && o.offsetWidth, c = a && a.offsetWidth, s = r && r.offsetWidth);
var e = document.getElementById("nav"), n = window.innerWidth < 768 || i + c + s > e.offsetWidth - 120;
n ? e.classList.add("hide-menu") : e.classList.remove("hide-menu")
0 < arguments.length &&
void 0 !== t &&
t &&
((i = o && o.offsetWidth),
(c = a && a.offsetWidth),
(s = r && r.offsetWidth));
var e = document.getElementById("nav"),
n = window.innerWidth < 768 || i + c + s > e.offsetWidth - 120;
n ? e.classList.add("hide-menu") : e.classList.remove("hide-menu");
}
var o = document.getElementById("site-name"), i = o && o.offsetWidth,
a = document.querySelector("#menus .menus_items"), c = a && a.offsetWidth,
r = document.querySelector("#search-button"), s = r && r.offsetWidth;
function E() {
var t,
e,
n,
c,
r,
o,
s,
l,
d,
u,
i,
f,
m,
a = GLOBAL_CONFIG.highlight;
function h(t, e, n) {
var o,
i,
a = document.createDocumentFragment();
r &&
(((o = document.createElement("div")).className =
"highlight-tools ".concat(u)),
(o.innerHTML = l + t + d),
o.addEventListener("click", f),
a.appendChild(o)),
c &&
e.offsetHeight > c + 30 &&
(((i = document.createElement("div")).className = "code-expand-btn"),
(i.innerHTML = '<i class="fas fa-angle-double-down"></i>'),
i.addEventListener("click", m),
a.appendChild(i)),
"hl" === n
? e.insertBefore(a, e.firstChild)
: e.parentNode.insertBefore(a, e);
}
a &&
((t = a.highlightCopy),
(e = a.highlightLang),
(n = GLOBAL_CONFIG_SITE.isHighlightShrink),
(c = a.highlightHeightLimit),
(r = t || e || void 0 !== n),
(o =
"highlighjs" === a.plugin
? document.querySelectorAll("figure.highlight")
: document.querySelectorAll('pre[class*="language-"]')),
(r || c) &&
o.length &&
((s = "prismjs" === a.plugin),
(u = !(d = l = "") === n ? "closed" : ""),
void 0 !== n &&
(l = '<i class="fas fa-angle-down expand '.concat(u, '"></i>')),
t &&
(d =
'<div class="copy-notice"></div><i class="fas fa-paste copy-button"></i>'),
(i = function (t) {
var e = t.parentNode;
e.classList.add("copy-true");
var n = window.getSelection(),
o = document.createRange();
s
? o.selectNodeContents(e.querySelectorAll("pre code")[0])
: o.selectNodeContents(e.querySelectorAll("table .code pre")[0]),
n.removeAllRanges(),
n.addRange(o);
var i, a;
n.toString();
(i = t.lastChild),
document.queryCommandSupported &&
document.queryCommandSupported("copy")
? (document.execCommand("copy"),
void 0 !== GLOBAL_CONFIG.Snackbar
? btf.snackbarShow(GLOBAL_CONFIG.copy.success)
: (((a = i.previousElementSibling).innerText =
GLOBAL_CONFIG.copy.success),
(a.style.opacity = 1),
setTimeout(function () {
a.style.opacity = 0;
}, 700)))
: void 0 !== GLOBAL_CONFIG.Snackbar
? btf.snackbarShow(GLOBAL_CONFIG.copy.noSupport)
: (i.previousElementSibling.innerText =
GLOBAL_CONFIG.copy.noSupport),
n.removeAllRanges(),
e.classList.remove("copy-true");
}),
(f = function (t) {
var e,
n,
o = t.target.classList;
o.contains("expand")
? ((n = _toConsumableArray((e = this).parentNode.children).slice(
1
)),
e.firstChild.classList.toggle("closed"),
btf.isHidden(n[n.length - 1])
? n.forEach(function (t) {
t.style.display = "block";
})
: n.forEach(function (t) {
t.style.display = "none";
}))
: o.contains("copy-button") && i(this);
}),
(m = function () {
this.classList.toggle("expand-done");
}),
e
? s
? o.forEach(function (t) {
var e = t.getAttribute("data-language")
? t.getAttribute("data-language")
: "Code",
n = '<div class="code-lang">'.concat(e, "</div>");
btf.wrap(t, "figure", "", "highlight"), h(n, t);
})
: o.forEach(function (t) {
var e = t.getAttribute("class").split(" ")[1];
("plain" !== e && void 0 !== e) || (e = "Code"),
h('<div class="code-lang">'.concat(e, "</div>"), t, "hl");
})
: s
? o.forEach(function (t) {
btf.wrap(t, "figure", "", "highlight"), h("", t);
})
: o.forEach(function (t) {
h("", t, "hl");
})));
}
var o = document.getElementById("site-name"),
i = o && o.offsetWidth,
a = document.querySelector("#menus .menus_items"),
c = a && a.offsetWidth,
r = document.querySelector("#search-button"),
s = r && r.offsetWidth;
function l(t) {
function e(t) {
t.each(function (t, e) {
var n = $(e), o = n.attr("data-lazy-src") || n.attr("src"), i = o + "_1600w", a = n.attr("alt") || "";
-1 != o.indexOf("!blogimg") ? n.wrap('<a href="'.concat(o, '" data-fancybox="images" data-caption="').concat(a, '" class="fancybox" data-srcset="').concat(i, ' 1600w"></a>')) : n.wrap('<a href="'.concat(o, '" data-fancybox="images" data-caption="').concat(a, '" class="fancybox" data-srcset="').concat(o, ' 1600w"></a>'))
}), $().fancybox({
selector: "[data-fancybox]",
loop: !0,
transitionEffect: "slide",
protect: !0,
buttons: ["slideShow", "fullScreen", "thumbs", "close"],
hash: !1
})
var n = $(e),
o = n.attr("data-lazy-src") || n.attr("src"),
i = o + "_1600w",
a = n.attr("alt") || "";
-1 != o.indexOf("!blogimg")
? n.wrap(
'<a href="'
.concat(o, '" data-fancybox="images" data-caption="')
.concat(a, '" class="fancybox" data-srcset="')
.concat(i, ' 1600w"></a>')
)
: n.wrap(
'<a href="'
.concat(o, '" data-fancybox="images" data-caption="')
.concat(a, '" class="fancybox" data-srcset="')
.concat(o, ' 1600w"></a>')
);
}),
$().fancybox({
selector: "[data-fancybox]",
loop: !0,
transitionEffect: "slide",
protect: !0,
buttons: ["slideShow", "fullScreen", "thumbs", "close"],
hash: !1,
});
}
void 0 === $.fancybox ? ($("head").append('<link rel="stylesheet" type="text/css" href="'.concat(GLOBAL_CONFIG.source.fancybox.css, '">')), $.getScript("".concat(GLOBAL_CONFIG.source.fancybox.js), function () {
e($(t))
})) : e($(t))
void 0 === $.fancybox
? ($("head").append(
'<link rel="stylesheet" type="text/css" href="'.concat(
GLOBAL_CONFIG.source.fancybox.css,
'">'
)
),
$.getScript("".concat(GLOBAL_CONFIG.source.fancybox.js), function () {
e($(t));
}))
: e($(t));
}
function w() {
var n = "fancybox" === GLOBAL_CONFIG.lightbox ? document.querySelectorAll("#article-container :not(a):not(.gallery-group) > img, #article-container > img,.bber-content-img > img") : [],
o = 0 < n.length, i = document.querySelectorAll("#article-container .justified-gallery"), a = 0 < i.length;
(a || o) && btf.isJqueryLoad(function () {
var n =
"fancybox" === GLOBAL_CONFIG.lightbox
? document.querySelectorAll(
"#article-container :not(a):not(.gallery-group) > img, #article-container > img,.bber-content-img > img"
)
: [],
o = 0 < n.length,
i = document.querySelectorAll("#article-container .justified-gallery"),
a = 0 < i.length;
(a || o) &&
btf.isJqueryLoad(function () {
var t, e;
a && (t = $(i), (e = t.find("img")).unwrap(), e.length && e.each(function (t, e) {
$(e).attr("data-lazy-src") && $(e).attr("src", $(e).attr("data-lazy-src")), $(e).wrap("<div></div>")
}), d ? btf.initJustifiedGallery(t) : ($("head").append('<link rel="stylesheet" type="text/css" href="'.concat(GLOBAL_CONFIG.source.justifiedGallery.css, '">')), $.getScript("".concat(GLOBAL_CONFIG.source.justifiedGallery.js), function () {
btf.initJustifiedGallery(t)
}), d = !0)), o && l(n)
})
a &&
((t = $(i)),
(e = t.find("img")).unwrap(),
e.length &&
e.each(function (t, e) {
$(e).attr("data-lazy-src") &&
$(e).attr("src", $(e).attr("data-lazy-src")),
$(e).wrap("<div></div>");
}),
d
? btf.initJustifiedGallery(t)
: ($("head").append(
'<link rel="stylesheet" type="text/css" href="'.concat(
GLOBAL_CONFIG.source.justifiedGallery.css,
'">'
)
),
$.getScript(
"".concat(GLOBAL_CONFIG.source.justifiedGallery.js),
function () {
btf.initJustifiedGallery(t);
}
),
(d = !0))),
o && l(n);
});
}
function A() {
var a,
c,
r,
s,
l,
d,
u = document.getElementById("rightside"),
f = window.innerHeight + 56;
document.body.scrollHeight <= f
? (u.style.cssText = "opacity: 1; transform: translateX(-38px)")
: ((c = !(a = 0)),
(r = document.getElementById("page-header")),
document.getElementById("guli_top"),
(s = document.getElementById("cookies-window")),
(l = "function" == typeof chatBtnHide),
(d = "function" == typeof chatBtnShow),
window.addEventListener(
"scroll",
btf.throttle(function (t) {
var e,
n,
o = window.scrollY || document.documentElement.scrollTop,
i = ((n = a < (e = o)), (a = e), n);
56 < o
? (i
? (r.classList.contains("nav-visible") &&
r.classList.remove("nav-visible"),
d && !0 === c && (chatBtnHide(), (c = !1)))
: (r.classList.contains("nav-visible") ||
r.classList.add("nav-visible"),
l && !1 === c && (chatBtnShow(), (c = !0))),
r.classList.add("nav-fixed"),
s.classList.add("cw-hide"),
"0" ===
window.getComputedStyle(u).getPropertyValue("opacity") &&
(u.style.cssText =
"opacity: 1; transform: translateX(-38px)"))
: (0 === o && r.classList.remove("nav-fixed", "nav-visible"),
(u.style.cssText = "opacity: ''; transform: ''")),
document.body.scrollHeight <= f &&
(u.style.cssText = "opacity: 1; transform: translateX(-38px)");
}, 200)
));
}
function S() {
var t = document.getElementById("card-toc"), r = t.getElementsByClassName("toc-content")[0],
s = r.querySelectorAll(".toc-link"), c = document.getElementById("article-container");
window.tocScrollFn = function () {
var t = document.getElementById("card-toc"),
r = t.getElementsByClassName("toc-content")[0],
s = r.querySelectorAll(".toc-link"),
c = document.getElementById("article-container");
(window.tocScrollFn = function () {
return btf.throttle(function () {
var t = window.scrollY || document.documentElement.scrollTop;
e(t), i(t)
}, 100)()
}, window.addEventListener("scroll", tocScrollFn);
e(t), i(t);
}, 100)();
}),
window.addEventListener("scroll", tocScrollFn);
var e = function (t) {
var e = c.clientHeight, n = document.documentElement.clientHeight,
o = (t - c.offsetTop) / (n < e ? e - n : document.documentElement.scrollHeight - n),
i = Math.round(100 * o), a = 100 < i ? 100 : i <= 0 ? 0 : i;
r.setAttribute("progress-percentage", a)
}, o = function () {
t.style.animation = "toc-close .2s", setTimeout(function () {
t.style.cssText = "opacity:''; animation: ''; right: ''"
}, 100)
};
document.getElementById("mobile-toc-button").addEventListener("click", function () {
("0" === window.getComputedStyle(t).getPropertyValue("opacity") ? n : o)()
}), r.addEventListener("click", function (t) {
t.preventDefault();
var e = t.target.classList.contains("toc-link") ? t.target : t.target.parentElement;
btf.scrollToDest(btf.getEleTop(document.getElementById(decodeURI(e.getAttribute("href")).replace("#", ""))), 300), window.innerWidth < 900 && o()
});
var d = c.querySelectorAll("h1,h2,h3,h4,h5,h6"), u = "", i = function (n) {
if (0 === s.length || 0 === n) return !1;
var t, e, o = "", i = "";
if (d.forEach(function (t, e) {
n > btf.getEleTop(t) - 80 && (o = "#" + encodeURI(t.getAttribute("id")), i = e)
}), u !== i) {
if (l && (t = o, window.history.replaceState && t !== window.location.hash && (t = t || location.pathname, e = GLOBAL_CONFIG_SITE.title, window.history.replaceState({
url: location.href, title: e
}, e, t))), "" === o) return r.querySelectorAll(".active").forEach(function (t) {
t.classList.remove("active")
}), void (u = i);
u = i, r.querySelectorAll(".active").forEach(function (t) {
t.classList.remove("active")
});
var a = s[i];
a.classList.add("active"), setTimeout(function () {
var t, e;
t = a.getBoundingClientRect().top, e = r.scrollTop, t > document.documentElement.clientHeight - 100 && (r.scrollTop = e + 150), t < 100 && (r.scrollTop = e - 150)
}, 0);
for (var c = a.parentNode; !c.matches(".toc"); c = c.parentNode) c.matches("li") && c.classList.add("active")
}
}
var e = c.clientHeight,
n = document.documentElement.clientHeight,
o =
(t - c.offsetTop) /
(n < e ? e - n : document.documentElement.scrollHeight - n),
i = Math.round(100 * o),
a = 100 < i ? 100 : i <= 0 ? 0 : i;
r.setAttribute("progress-percentage", a);
},
l = GLOBAL_CONFIG.isanchor,
n = function () {
t.style.cssText = "animation: toc-open .3s; opacity: 1; right: 45px";
},
o = function () {
(t.style.animation = "toc-close .2s"),
setTimeout(function () {
t.style.cssText = "opacity:''; animation: ''; right: ''";
}, 100);
};
document
.getElementById("mobile-toc-button")
.addEventListener("click", function () {
("0" === window.getComputedStyle(t).getPropertyValue("opacity")
? n
: o)();
}),
r.addEventListener("click", function (t) {
t.preventDefault();
var e = t.target.classList.contains("toc-link")
? t.target
: t.target.parentElement;
btf.scrollToDest(
btf.getEleTop(
document.getElementById(
decodeURI(e.getAttribute("href")).replace("#", "")
)
),
300
),
window.innerWidth < 900 && o();
});
var d = c.querySelectorAll("h1,h2,h3,h4,h5,h6"),
u = "",
i = function (n) {
if (0 === s.length || 0 === n) return !1;
var t,
e,
o = "",
i = "";
if (
(d.forEach(function (t, e) {
n > btf.getEleTop(t) - 80 &&
((o = "#" + encodeURI(t.getAttribute("id"))), (i = e));
}),
u !== i)
) {
if (
(l &&
((t = o),
window.history.replaceState &&
t !== window.location.hash &&
((t = t || location.pathname),
(e = GLOBAL_CONFIG_SITE.title),
window.history.replaceState(
{ url: location.href, title: e },
e,
t
))),
"" === o)
)
return (
r.querySelectorAll(".active").forEach(function (t) {
t.classList.remove("active");
}),
void (u = i)
);
(u = i),
r.querySelectorAll(".active").forEach(function (t) {
t.classList.remove("active");
});
var a = s[i];
a.classList.add("active"),
setTimeout(function () {
var t, e;
(t = a.getBoundingClientRect().top),
(e = r.scrollTop),
t > document.documentElement.clientHeight - 100 &&
(r.scrollTop = e + 150),
t < 100 && (r.scrollTop = e - 150);
}, 0);
for (var c = a.parentNode; !c.matches(".toc"); c = c.parentNode)
c.matches("li") && c.classList.add("active");
}
};
}
var d = !1, n = function () {
"light" == ("dark" === document.documentElement.getAttribute("data-theme") ? "dark" : "light") ? (activateDarkMode(), saveToLocal.set("theme", "dark", 2), void 0 !== GLOBAL_CONFIG.Snackbar && btf.snackbarShow(GLOBAL_CONFIG.Snackbar.day_to_night, !1, 2e3)) : (activateLightMode(), saveToLocal.set("theme", "light", 2), void 0 !== GLOBAL_CONFIG.Snackbar && btf.snackbarShow(GLOBAL_CONFIG.Snackbar.night_to_day, !1, 2e3)), "function" == typeof utterancesTheme && utterancesTheme(), "object" === ("undefined" == typeof FB ? "undefined" : _typeof(FB)) && window.loadFBComment(), window.DISQUS && document.getElementById("disqus_thread").children.length && setTimeout(function () {
return window.disqusReset()
}, 200)
};
var d = !1,
e = function () {
var e = document.body;
e.classList.add("read-mode");
var n = document.createElement("button");
(n.type = "button"),
(n.className = "fas fa-sign-out-alt exit-readmode"),
e.appendChild(n),
n.addEventListener("click", function t() {
e.classList.remove("read-mode"),
n.remove(),
n.removeEventListener("click", t);
});
},
n = function () {
"light" ==
("dark" === document.documentElement.getAttribute("data-theme")
? "dark"
: "light")
? (activateDarkMode(),
saveToLocal.set("theme", "dark", 2),
void 0 !== GLOBAL_CONFIG.Snackbar &&
btf.snackbarShow(GLOBAL_CONFIG.Snackbar.day_to_night, !1, 2e3))
: (activateLightMode(),
saveToLocal.set("theme", "light", 2),
void 0 !== GLOBAL_CONFIG.Snackbar &&
btf.snackbarShow(GLOBAL_CONFIG.Snackbar.night_to_day, !1, 2e3)),
"function" == typeof utterancesTheme && utterancesTheme(),
"object" === ("undefined" == typeof FB ? "undefined" : _typeof(FB)) &&
window.loadFBComment(),
window.DISQUS &&
document.getElementById("disqus_thread").children.length &&
setTimeout(function () {
return window.disqusReset();
}, 200);
},
u = function () {
document.getElementById("rightside-config-hide").classList.toggle("show");
},
f = function () {
btf.scrollToDest(0, 500);
},
m = function () {
var t = document.documentElement.classList;
t.contains("hide-aside")
? saveToLocal.set("aside-status", "show", 2)
: saveToLocal.set("aside-status", "hide", 2),
t.toggle("hide-aside");
},
h = function (t) {
var e = parseInt(
window
.getComputedStyle(document.documentElement)
.getPropertyValue("--global-font-size")
),
n = "";
if (t) {
if (20 <= e) return;
(n = e + 1),
document.documentElement.style.setProperty(
"--global-font-size",
n + "px"
),
document.getElementById("nav").classList.contains("hide-menu") ||
L(!0);
} else {
if (e <= 10) return;
(n = e - 1),
document.documentElement.style.setProperty(
"--global-font-size",
n + "px"
),
document.getElementById("nav").classList.contains("hide-menu") &&
L(!0);
}
saveToLocal.set("global-font-size", n, 2);
};
document.getElementById("rightside").addEventListener("click", function (t) {
switch (t.target.id || t.target.parentNode.id) {
case "go-up":
f();
break;
case "rightside_config":
u();
break;
case "readmode":
e();
break;
case "darkmode":
n();
break;
case "hide-aside-btn":
m();
break;
case "font-plus":
h(!0);
break;
case "font-minus":
h();
}
});
function I(t) {
t.forEach(function (t) {
var e = t, n = e.getAttribute("datetime");
e.innerText = btf.diffDate(n, !0), e.style.display = "inline"
})
var e = t,
n = e.getAttribute("datetime");
(e.innerText = btf.diffDate(n, !0)), (e.style.display = "inline");
});
}
var g, O = function () {
document.querySelectorAll("#article-container .tab > button").forEach(function (t) {
t.addEventListener("click", function (t) {
var e, n, o, i, a = this.parentNode;
a.classList.contains("active") || (e = a.parentNode.nextElementSibling, (n = btf.siblings(a, ".active")[0]) && n.classList.remove("active"), a.classList.add("active"), o = this.getAttribute("data-href").replace("#", ""), _toConsumableArray(e.children).forEach(function (t) {
t.id === o ? t.classList.add("active") : t.classList.remove("active")
}), 0 < (i = e.querySelectorAll("#".concat(o, " .justified-gallery"))).length && btf.initJustifiedGallery(i))
})
})
}, G = function () {
document.querySelectorAll("#article-container .tabs .tab-to-top").forEach(function (t) {
t.addEventListener("click", function () {
btf.scrollToDest(btf.getEleTop(btf.getParents(this, ".tabs")), 300)
})
})
};
window.refreshFn = function () {
var g,
O = function () {
document
.querySelectorAll("#article-container .tab > button")
.forEach(function (t) {
t.addEventListener("click", function (t) {
var e,
n,
o,
i,
a = this.parentNode;
a.classList.contains("active") ||
((e = a.parentNode.nextElementSibling),
(n = btf.siblings(a, ".active")[0]) &&
n.classList.remove("active"),
a.classList.add("active"),
(o = this.getAttribute("data-href").replace("#", "")),
_toConsumableArray(e.children).forEach(function (t) {
t.id === o
? t.classList.add("active")
: t.classList.remove("active");
}),
0 <
(i = e.querySelectorAll("#".concat(o, " .justified-gallery")))
.length && btf.initJustifiedGallery(i));
});
});
},
G = function () {
document
.querySelectorAll("#article-container .tabs .tab-to-top")
.forEach(function (t) {
t.addEventListener("click", function () {
btf.scrollToDest(btf.getEleTop(btf.getParents(this, ".tabs")), 300);
});
});
};
(window.refreshFn = function () {
var t, e, n, o, i, a, c, r, s, l, d, u, f, m, h, g, y, p, b;
function v() {
f.style.overflow = "", f.style.paddingRight = "", btf.fadeOut(u, .5), d.classList.remove("open")
(f.style.overflow = ""),
(f.style.paddingRight = ""),
btf.fadeOut(u, 0.5),
d.classList.remove("open");
}
L(), document.getElementById("nav").classList.add("show"), GLOBAL_CONFIG_SITE.isPost ? (GLOBAL_CONFIG_SITE.isToc && S(), void 0 !== GLOBAL_CONFIG.noticeOutdate && (r = GLOBAL_CONFIG.noticeOutdate, (s = btf.diffDate(GLOBAL_CONFIG_SITE.postUpdate)) >= r.limitDay && ((a = document.createElement("div")).className = "post-outdate-notice", a.textContent = r.messagePrev + " " + s + " " + r.messageNext, c = document.getElementById("article-container"), "top" === r.position ? c.insertBefore(a, c.firstChild) : c.appendChild(a))), GLOBAL_CONFIG.relativeDate.post && I(document.querySelectorAll("#post-meta time"))) : (GLOBAL_CONFIG.relativeDate.homepage && I(document.querySelectorAll("#recent-posts time")), !GLOBAL_CONFIG.runtime || (i = document.getElementById("runtimeshow")) && (o = i.getAttribute("data-publishDate"), i.innerText = btf.diffDate(o) + " " + GLOBAL_CONFIG.runtime), (n = document.getElementById("last-push-date")) && (e = n.getAttribute("data-lastPushDate"), n.innerText = btf.diffDate(e, !0)), (t = document.querySelectorAll("#aside-cat-list .card-category-list-item.parent i")).length && t.forEach(function (t) {
t.addEventListener("click", function (t) {
t.preventDefault();
this.classList.toggle("expand");
var e = this.parentNode.nextElementSibling;
btf.isHidden(e) ? e.style.display = "block" : e.style.display = "none"
})
})), l = document.getElementById("toggle-menu"), d = document.getElementById("sidebar-menus"), u = document.getElementById("menu-mask"), f = document.body, l.addEventListener("click", function () {
btf.sidebarPaddingR(), f.style.overflow = "hidden", btf.fadeIn(u, .5), d.classList.add("open")
});
window.addEventListener("resize", function (t) {
btf.isHidden(l) && v()
});
w();
"mediumZoom" === GLOBAL_CONFIG.lightbox && (h = mediumZoom(document.querySelectorAll("#article-container :not(a)>img"))).on("open", function (t) {
var e = "dark" === document.documentElement.getAttribute("data-theme") ? "#121212" : "#fff";
h.update({background: e})
});
(g = document.querySelectorAll("#article-container :not(.highlight) > table, #article-container > table")).length && g.forEach(function (t) {
btf.wrap(t, "div", "", "table-wrap")
});
(y = document.querySelectorAll("#article-container .hide-button")).length && y.forEach(function (t) {
L(),
document.getElementById("nav").classList.add("show"),
GLOBAL_CONFIG_SITE.isPost
? (GLOBAL_CONFIG_SITE.isToc && S(),
void 0 !== GLOBAL_CONFIG.noticeOutdate &&
((r = GLOBAL_CONFIG.noticeOutdate),
(s = btf.diffDate(GLOBAL_CONFIG_SITE.postUpdate)) >= r.limitDay &&
(((a = document.createElement("div")).className =
"post-outdate-notice"),
(a.textContent = r.messagePrev + " " + s + " " + r.messageNext),
(c = document.getElementById("article-container")),
"top" === r.position
? c.insertBefore(a, c.firstChild)
: c.appendChild(a))),
GLOBAL_CONFIG.relativeDate.post &&
I(document.querySelectorAll("#post-meta time")))
: (GLOBAL_CONFIG.relativeDate.homepage &&
I(document.querySelectorAll("#recent-posts time")),
!GLOBAL_CONFIG.runtime ||
((i = document.getElementById("runtimeshow")) &&
((o = i.getAttribute("data-publishDate")),
(i.innerText = btf.diffDate(o) + " " + GLOBAL_CONFIG.runtime))),
(n = document.getElementById("last-push-date")) &&
((e = n.getAttribute("data-lastPushDate")),
(n.innerText = btf.diffDate(e, !0))),
(t = document.querySelectorAll(
"#aside-cat-list .card-category-list-item.parent i"
)).length &&
t.forEach(function (t) {
t.addEventListener("click", function (t) {
t.preventDefault();
this.classList.toggle("expand");
var e = this.parentNode.nextElementSibling;
btf.isHidden(e)
? (e.style.display = "block")
: (e.style.display = "none");
});
})),
(l = document.getElementById("toggle-menu")),
(d = document.getElementById("sidebar-menus")),
(u = document.getElementById("menu-mask")),
(f = document.body),
l.addEventListener("click", function () {
btf.sidebarPaddingR(),
(f.style.overflow = "hidden"),
btf.fadeIn(u, 0.5),
d.classList.add("open");
}),
u.addEventListener("click", function (t) {
d.classList.contains("open") && v();
}),
window.addEventListener("resize", function (t) {
btf.isHidden(l) && d.classList.contains("open") && v();
}),
!GLOBAL_CONFIG_SITE.isHome ||
((m = document.getElementById("scroll-down")) &&
m.addEventListener("click", function () {
btf.scrollToDest(
document.getElementById("content-inner").offsetTop,
300
);
})),
E(),
GLOBAL_CONFIG.isPhotoFigcaption &&
document
.querySelectorAll("#article-container img")
.forEach(function (t) {
var e,
n = t.parentNode;
n.parentNode.classList.contains("justified-gallery") ||
(((e = document.createElement("div")).className =
"img-alt is-center"),
(e.textContent = t.getAttribute("alt")),
n.insertBefore(e, t.nextSibling));
}),
w(),
"mediumZoom" === GLOBAL_CONFIG.lightbox &&
(h = mediumZoom(
document.querySelectorAll("#article-container :not(a)>img")
)).on("open", function (t) {
var e =
"dark" === document.documentElement.getAttribute("data-theme")
? "#121212"
: "#fff";
h.update({ background: e });
}),
A(),
(g = document.querySelectorAll(
"#article-container :not(.highlight) > table, #article-container > table"
)).length &&
g.forEach(function (t) {
btf.wrap(t, "div", "", "table-wrap");
}),
(y = document.querySelectorAll("#article-container .hide-button"))
.length &&
y.forEach(function (t) {
t.addEventListener("click", function (t) {
var e = this.nextElementSibling;
this.classList.toggle("open"), this.classList.contains("open") && 0 < e.querySelectorAll(".justified-gallery").length && btf.initJustifiedGallery(e.querySelectorAll(".justified-gallery"))
})
});
O();
G();
p = !1;
(b = document.querySelector("#comment-switch > .switch-btn")) && b.addEventListener("click", function () {
this.classList.toggle("move"), document.querySelectorAll("#post-comment > .comment-wrap > div").forEach(function (t) {
btf.isHidden(t) ? t.style.cssText = "display: block;animation: tabshow .5s" : t.style.cssText = "display: none;animation: ''"
this.classList.toggle("open"),
this.classList.contains("open") &&
0 < e.querySelectorAll(".justified-gallery").length &&
btf.initJustifiedGallery(
e.querySelectorAll(".justified-gallery")
);
});
p || "function" != typeof loadOtherComment || (p = !0, loadOtherComment())
}),
O(),
G(),
(p = !1),
(b = document.querySelector("#comment-switch > .switch-btn")) &&
b.addEventListener("click", function () {
this.classList.toggle("move"),
document
.querySelectorAll("#post-comment > .comment-wrap > div")
.forEach(function (t) {
btf.isHidden(t)
? (t.style.cssText = "display: block;animation: tabshow .5s")
: (t.style.cssText = "display: none;animation: ''");
}),
p ||
"function" != typeof loadOtherComment ||
((p = !0), loadOtherComment());
});
};
refreshFn();
window.addEventListener("resize", L);
window.addEventListener("orientationchange", function () {
setTimeout(L(!0), 100)
});
document.querySelectorAll("#sidebar-menus .expand").forEach(function (t) {
t.addEventListener("click", function () {
this.classList.toggle("hide");
var t = this.parentNode.nextElementSibling;
btf.isHidden(t) ? t.style.display = "block" : t.style.display = "none"
})
});
window.addEventListener("touchmove", function (t) {
document.querySelectorAll("#nav .menus_item_child").forEach(function (t) {
btf.isHidden(t) || (t.style.display = "none")
})
});
});
}),
refreshFn(),
window.addEventListener("resize", L),
window.addEventListener("orientationchange", function () {
setTimeout(L(!0), 100);
}),
document.querySelectorAll("#sidebar-menus .expand").forEach(function (t) {
t.addEventListener("click", function () {
this.classList.toggle("hide");
var t = this.parentNode.nextElementSibling;
btf.isHidden(t)
? (t.style.display = "block")
: (t.style.display = "none");
});
}),
window.addEventListener("touchmove", function (t) {
document.querySelectorAll("#nav .menus_item_child").forEach(function (t) {
btf.isHidden(t) || (t.style.display = "none");
});
}),
GLOBAL_CONFIG.islazyload &&
(window.lazyLoadInstance = new LazyLoad({
elements_selector: "img",
threshold: 0,
data_src: "lazy-src",
})),
void 0 !== GLOBAL_CONFIG.copyright &&
((g = GLOBAL_CONFIG.copyright),
(document.body.oncopy = function (t) {
t.preventDefault();
var e = window.getSelection(0).toString(),
n =
e.length > g.limitCount
? e +
"\n\n\n" +
g.languages.author +
"\n" +
g.languages.link +
window.location.href +
"\n" +
g.languages.source +
"\n" +
g.languages.info
: e;
return t.clipboardData
? t.clipboardData.setData("text", n)
: window.clipboardData.setData("text", n);
}));
});

View File

@ -1,119 +1,224 @@
"use strict";
function _toConsumableArray(e) {
return _arrayWithoutHoles(e) || _iterableToArray(e) || _unsupportedIterableToArray(e) || _nonIterableSpread()
return (
_arrayWithoutHoles(e) ||
_iterableToArray(e) ||
_unsupportedIterableToArray(e) ||
_nonIterableSpread()
);
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
throw new TypeError(
"Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
);
}
function _unsupportedIterableToArray(e, t) {
if (e) {
if ("string" == typeof e) return _arrayLikeToArray(e, t);
var n = Object.prototype.toString.call(e).slice(8, -1);
return "Object" === n && e.constructor && (n = e.constructor.name), "Map" === n || "Set" === n ? Array.from(e) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? _arrayLikeToArray(e, t) : void 0
return (
"Object" === n && e.constructor && (n = e.constructor.name),
"Map" === n || "Set" === n
? Array.from(e)
: "Arguments" === n ||
/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)
? _arrayLikeToArray(e, t)
: void 0
);
}
}
function _iterableToArray(e) {
if ("undefined" != typeof Symbol && null != e[Symbol.iterator] || null != e["@@iterator"]) return Array.from(e)
if (
("undefined" != typeof Symbol && null != e[Symbol.iterator]) ||
null != e["@@iterator"]
)
return Array.from(e);
}
function _arrayWithoutHoles(e) {
if (Array.isArray(e)) return _arrayLikeToArray(e)
if (Array.isArray(e)) return _arrayLikeToArray(e);
}
function _arrayLikeToArray(e, t) {
(null == t || t > e.length) && (t = e.length);
for (var n = 0, r = new Array(t); n < t; n++) r[n] = e[n];
return r
return r;
}
var btf = {
debounce: function (r, o, i) {
var a;
return function () {
var e = this, t = arguments, n = i && !a;
clearTimeout(a), a = setTimeout(function () {
a = null, i || r.apply(e, t)
}, o), n && r.apply(e, t)
}
}, throttle: function (n, r, o) {
var i, a, s, u = 0;
var e = this,
t = arguments,
n = i && !a;
clearTimeout(a),
(a = setTimeout(function () {
(a = null), i || r.apply(e, t);
}, o)),
n && r.apply(e, t);
};
},
throttle: function (n, r, o) {
var i,
a,
s,
u = 0;
o = o || {};
function l() {
u = !1 === o.leading ? 0 : (new Date).getTime(), i = null, n.apply(a, s), i || (a = s = null)
(u = !1 === o.leading ? 0 : new Date().getTime()),
(i = null),
n.apply(a, s),
i || (a = s = null);
}
return function () {
var e = (new Date).getTime();
var e = new Date().getTime();
u || !1 !== o.leading || (u = e);
var t = r - (e - u);
a = this, s = arguments, t <= 0 || r < t ? (i && (clearTimeout(i), i = null), u = e, n.apply(a, s), i || (a = s = null)) : i || !1 === o.trailing || (i = setTimeout(l, t))
}
}, sidebarPaddingR: function () {
var e = window.innerWidth, t = document.body.clientWidth, n = e - t;
e !== t && (document.body.style.paddingRight = n + "px")
}, snackbarShow: function (e, t, n) {
var r = void 0 !== t && t, o = void 0 !== n ? n : 5e3, i = GLOBAL_CONFIG.Snackbar.position,
a = "light" === document.documentElement.getAttribute("data-theme") ? GLOBAL_CONFIG.Snackbar.bgLight : GLOBAL_CONFIG.Snackbar.bgDark;
document.styleSheets[0].addRule(":root", "--heo-snackbar-time:" + o + "ms!important"), Snackbar.show({
text: e,
backgroundColor: a,
showAction: r,
duration: o,
pos: i
})
}, initJustifiedGallery: function (e) {
e instanceof jQuery || (e = $(e)), e.each(function (e, t) {
$(this).is(":visible") && $(this).justifiedGallery({rowHeight: 220, margins: 4})
})
}, diffDate: function (e, t) {
var n, r, o, i = 1 < arguments.length && void 0 !== t && t, a = new Date, s = new Date(e),
(a = this),
(s = arguments),
t <= 0 || r < t
? (i && (clearTimeout(i), (i = null)),
(u = e),
n.apply(a, s),
i || (a = s = null))
: i || !1 === o.trailing || (i = setTimeout(l, t));
};
},
sidebarPaddingR: function () {
var e = window.innerWidth,
t = document.body.clientWidth,
n = e - t;
e !== t && (document.body.style.paddingRight = n + "px");
},
snackbarShow: function (e, t, n) {
var r = void 0 !== t && t,
o = void 0 !== n ? n : 5e3,
i = GLOBAL_CONFIG.Snackbar.position,
a =
"light" === document.documentElement.getAttribute("data-theme")
? GLOBAL_CONFIG.Snackbar.bgLight
: GLOBAL_CONFIG.Snackbar.bgDark;
document.styleSheets[0].addRule(
":root",
"--heo-snackbar-time:" + o + "ms!important"
),
Snackbar.show({
text: e,
backgroundColor: a,
showAction: r,
duration: o,
pos: i,
});
},
initJustifiedGallery: function (e) {
e instanceof jQuery || (e = $(e)),
e.each(function (e, t) {
$(this).is(":visible") &&
$(this).justifiedGallery({ rowHeight: 220, margins: 4 });
});
},
diffDate: function (e, t) {
var n,
r,
o,
i = 1 < arguments.length && void 0 !== t && t,
a = new Date(),
s = new Date(e),
u = a.getTime() - s.getTime();
return i ? (n = u / 864e5, r = u / 36e5, o = u / 6e4, 12 < u / 2592e6 ? s.toLocaleDateString() : 7 <= n ? s.toLocaleDateString().substr(5) : 1 <= n ? parseInt(n) + "" + GLOBAL_CONFIG.date_suffix.day : 1 <= r || 1 <= o ? "最近" : GLOBAL_CONFIG.date_suffix.just) : parseInt(u / 864e5)
}, loadComment: function (e, t) {
return i
? ((n = u / 864e5),
(r = u / 36e5),
(o = u / 6e4),
12 < u / 2592e6
? s.toLocaleDateString()
: 7 <= n
? s.toLocaleDateString().substr(5)
: 1 <= n
? parseInt(n) + "" + GLOBAL_CONFIG.date_suffix.day
: 1 <= r || 1 <= o
? "最近"
: GLOBAL_CONFIG.date_suffix.just)
: parseInt(u / 864e5);
},
loadComment: function (e, t) {
var n;
"IntersectionObserver" in window ? (n = new IntersectionObserver(function (e) {
e[0].isIntersecting && (t(), n.disconnect())
}, {threshold: [0]})).observe(e) : t()
}, scrollToDest: function (o, i) {
"IntersectionObserver" in window
? (n = new IntersectionObserver(
function (e) {
e[0].isIntersecting && (t(), n.disconnect());
},
{ threshold: [0] }
)).observe(e)
: t();
},
scrollToDest: function (o, i) {
var a, s;
o < 0 || i < 0 || (a = window.scrollY || window.screenTop, o -= 70, "CSS" in window && CSS.supports("scroll-behavior", "smooth") ? window.scrollTo({
top: o,
behavior: "smooth"
}) : (s = null, i = i || 500, window.requestAnimationFrame(function e(t) {
var n, r;
s = s || t, a < o ? (n = t - s, window.scrollTo(0, (o - a) * n / i + a), n < i ? window.requestAnimationFrame(e) : window.scrollTo(0, o)) : (r = t - s, window.scrollTo(0, a - (a - o) * r / i), r < i ? window.requestAnimationFrame(e) : window.scrollTo(0, o))
})))
}, fadeIn: function (e, t) {
e.style.cssText = "display:block;animation: to_show ".concat(t, "s")
}, fadeOut: function (t, e) {
o < 0 ||
i < 0 ||
((a = window.scrollY || window.screenTop),
(o -= 70),
"CSS" in window && CSS.supports("scroll-behavior", "smooth")
? window.scrollTo({ top: o, behavior: "smooth" })
: ((s = null),
(i = i || 500),
window.requestAnimationFrame(function e(t) {
var n, r;
(s = s || t),
a < o
? ((n = t - s),
window.scrollTo(0, ((o - a) * n) / i + a),
n < i
? window.requestAnimationFrame(e)
: window.scrollTo(0, o))
: ((r = t - s),
window.scrollTo(0, a - ((a - o) * r) / i),
r < i
? window.requestAnimationFrame(e)
: window.scrollTo(0, o));
})));
},
fadeIn: function (e, t) {
e.style.cssText = "display:block;animation: to_show ".concat(t, "s");
},
fadeOut: function (t, e) {
t.addEventListener("animationend", function e() {
t.style.cssText = "display: none; animation: '' ", t.removeEventListener("animationend", e)
}), t.style.animation = "to_hide ".concat(e, "s")
}, getParents: function (e, t) {
(t.style.cssText = "display: none; animation: '' "),
t.removeEventListener("animationend", e);
}),
(t.style.animation = "to_hide ".concat(e, "s"));
},
getParents: function (e, t) {
for (; e && e !== document; e = e.parentNode) if (e.matches(t)) return e;
return null
}, siblings: function (t, n) {
return null;
},
siblings: function (t, n) {
return _toConsumableArray(t.parentNode.children).filter(function (e) {
return n ? e !== t && e.matches(n) : e !== t
})
}, wrap: function (e, t, n, r) {
var o = 2 < arguments.length && void 0 !== n ? n : "", i = 3 < arguments.length && void 0 !== r ? r : "",
return n ? e !== t && e.matches(n) : e !== t;
});
},
wrap: function (e, t, n, r) {
var o = 2 < arguments.length && void 0 !== n ? n : "",
i = 3 < arguments.length && void 0 !== r ? r : "",
a = document.createElement(t);
o && (a.id = o), i && (a.className = i), e.parentNode.insertBefore(a, e), a.appendChild(e)
}, unwrap: function (e) {
o && (a.id = o),
i && (a.className = i),
e.parentNode.insertBefore(a, e),
a.appendChild(e);
},
unwrap: function (e) {
var t = e.parentNode;
t !== document.body && (t.parentNode.insertBefore(e, t), t.parentNode.removeChild(t))
}, isJqueryLoad: function (e) {
"undefined" == typeof jQuery ? getScript(GLOBAL_CONFIG.source.jQuery).then(e) : e()
}, isHidden: function (e) {
return 0 === e.offsetHeight && 0 === e.offsetWidth
}, getEleTop: function (e) {
for (var t = e.offsetTop, n = e.offsetParent; null !== n;) t += n.offsetTop, n = n.offsetParent;
return t
}
};
t !== document.body &&
(t.parentNode.insertBefore(e, t), t.parentNode.removeChild(t));
},
isJqueryLoad: function (e) {
"undefined" == typeof jQuery
? getScript(GLOBAL_CONFIG.source.jQuery).then(e)
: e();
},
isHidden: function (e) {
return 0 === e.offsetHeight && 0 === e.offsetWidth;
},
getEleTop: function (e) {
for (var t = e.offsetTop, n = e.offsetParent; null !== n; )
(t += n.offsetTop), (n = n.offsetParent);
return t;
},
};

View File

@ -1,286 +1,605 @@
"use strict";
function _createForOfIteratorHelper(e, t) {
var o = "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
var o =
("undefined" != typeof Symbol && e[Symbol.iterator]) || e["@@iterator"];
if (!o) {
if (Array.isArray(e) || (o = _unsupportedIterableToArray(e)) || t && e && "number" == typeof e.length) {
if (
Array.isArray(e) ||
(o = _unsupportedIterableToArray(e)) ||
(t && e && "number" == typeof e.length)
) {
o && (e = o);
var n = 0, r = function () {
};
var n = 0,
r = function () {};
return {
s: r, n: function () {
return n >= e.length ? {done: !0} : {done: !1, value: e[n++]}
}, e: function (e) {
throw e
}, f: r
}
s: r,
n: function () {
return n >= e.length ? { done: !0 } : { done: !1, value: e[n++] };
},
e: function (e) {
throw e;
},
f: r,
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
throw new TypeError(
"Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
);
}
var a, i = !0, c = !1;
var a,
i = !0,
c = !1;
return {
s: function () {
o = o.call(e)
}, n: function () {
o = o.call(e);
},
n: function () {
var e = o.next();
return i = e.done, e
}, e: function (e) {
c = !0, a = e
}, f: function () {
return (i = e.done), e;
},
e: function (e) {
(c = !0), (a = e);
},
f: function () {
try {
i || null == o.return || o.return()
i || null == o.return || o.return();
} finally {
if (c) throw a
if (c) throw a;
}
}
}
},
};
}
function _unsupportedIterableToArray(e, t) {
if (e) {
if ("string" == typeof e) return _arrayLikeToArray(e, t);
var o = Object.prototype.toString.call(e).slice(8, -1);
return "Object" === o && e.constructor && (o = e.constructor.name), "Map" === o || "Set" === o ? Array.from(e) : "Arguments" === o || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o) ? _arrayLikeToArray(e, t) : void 0
return (
"Object" === o && e.constructor && (o = e.constructor.name),
"Map" === o || "Set" === o
? Array.from(e)
: "Arguments" === o ||
/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)
? _arrayLikeToArray(e, t)
: void 0
);
}
}
function _arrayLikeToArray(e, t) {
(null == t || t > e.length) && (t = e.length);
for (var o = 0, n = new Array(t); o < t; o++) n[o] = e[o];
return n
return n;
}
function _typeof(e) {
return (_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (e) {
return typeof e
} : function (e) {
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
})(e)
return (_typeof =
"function" == typeof Symbol && "symbol" == typeof Symbol.iterator
? function (e) {
return typeof e;
}
: function (e) {
return e &&
"function" == typeof Symbol &&
e.constructor === Symbol &&
e !== Symbol.prototype
? "symbol"
: typeof e;
})(e);
}
function checkOpen() {
function checkOpen() {}
function coverColor() {
var _document$getElementB,
path =
null ===
(_document$getElementB = document.getElementById("post-cover")) ||
void 0 === _document$getElementB
? void 0
: _document$getElementB.src,
httpRequest;
void 0 !== path
? ((httpRequest = new XMLHttpRequest()),
httpRequest.open("GET", path + "?imageAve", !0),
httpRequest.send(),
(httpRequest.onreadystatechange = function () {
var json, obj, value, value;
4 == httpRequest.readyState &&
200 == httpRequest.status &&
((json = httpRequest.responseText),
(obj = eval("(" + json + ")")),
(value = obj.RGB),
(value = "#" + value.slice(2)),
"light" == getContrastYIQ(value) &&
(value = LightenDarkenColor(colorHex(value), -40)),
document.styleSheets[0].addRule(
":root",
"--heo-main:" + value + "!important"
),
document.styleSheets[0].addRule(
":root",
"--heo-main-op:" + value + "23!important"
),
document.styleSheets[0].addRule(
":root",
"--heo-main-op-deep:" + value + "dd!important"
),
document.styleSheets[0].addRule(
":root",
"--heo-main-none:" + value + "00!important"
),
heo.initThemeColor(),
document.getElementById("coverdiv").classList.add("loaded"));
}))
: (document.styleSheets[0].addRule(
":root",
"--heo-main: var(--heo-theme)!important"
),
document.styleSheets[0].addRule(
":root",
"--heo-main-op: var(--heo-theme-op)!important"
),
document.styleSheets[0].addRule(
":root",
"--heo-main-op-deep:var(--heo-theme-op-deep)!important"
),
document.styleSheets[0].addRule(
":root",
"--heo-main-none: var(--heo-theme-none)!important"
),
heo.initThemeColor());
}
// https://blog.zhheo.com/p/c86d8f1f.html
// ?imageAve 使用 七牛云获取图片主色调,阿里云 oss 则是 @imageAve
// TODO 可以切换为使用本地 JS 获取色调
// function coverColor() {
// var _document$getElementB,
// path = null === (_document$getElementB = document.getElementById("post-cover")) || void 0 === _document$getElementB ? void 0 : _document$getElementB.src,
// httpRequest;
// void 0 !== path ? (httpRequest = new XMLHttpRequest, httpRequest.open("GET", path + "?imageAve", !0), httpRequest.send(), httpRequest.onreadystatechange = function () {
// var json, obj, value, value;
// 4 == httpRequest.readyState && 200 == httpRequest.status && (json = httpRequest.responseText, obj = eval("(" + json + ")"), value = obj.RGB, value = "#" + value.slice(2), "light" == getContrastYIQ(value) && (value = LightenDarkenColor(colorHex(value), -40)), document.styleSheets[0].addRule(":root", "--heo-main:" + value + "!important"), document.styleSheets[0].addRule(":root", "--heo-main-op:" + value + "23!important"), document.styleSheets[0].addRule(":root", "--heo-main-none:" + value + "00!important"), heo.initThemeColor(), document.getElementById("coverdiv").classList.add("loaded"))
// }) : (document.styleSheets[0].addRule(":root", "--heo-main: var(--heo-theme)!important"), document.styleSheets[0].addRule(":root", "--heo-main-op: var(--heo-theme-op)!important"), document.styleSheets[0].addRule(":root", "--heo-main-none: var(--heo-theme-none)!important"), heo.initThemeColor())
// }
function colorHex(e) {
var t = e;
if (/^(rgb|RGB)/.test(t)) {
for (var o = t.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(","), n = "#", r = 0; r < o.length; r++) {
for (
var o = t.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(","), n = "#", r = 0;
r < o.length;
r++
) {
var a = Number(o[r]).toString(16);
"0" === a && (a += a), n += a
"0" === a && (a += a), (n += a);
}
return 7 !== n.length && (n = t), n
return 7 !== n.length && (n = t), n;
}
if (!/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(t)) return t;
var i = t.replace(/#/, "").split("");
if (6 === i.length) return t;
if (3 === i.length) {
for (var c = "#", r = 0; r < i.length; r += 1) c += i[r] + i[r];
return c
return c;
}
}
function colorRgb(e) {
var t = e.toLowerCase();
if (t && /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(t)) {
if (4 === t.length) {
for (var o = "#", n = 1; n < 4; n += 1) o += t.slice(n, n + 1).concat(t.slice(n, n + 1));
t = o
for (var o = "#", n = 1; n < 4; n += 1)
o += t.slice(n, n + 1).concat(t.slice(n, n + 1));
t = o;
}
for (var r = [], n = 1; n < 7; n += 2) r.push(parseInt("0x" + t.slice(n, n + 2)));
return "rgb(" + r.join(",") + ")"
for (var r = [], n = 1; n < 7; n += 2)
r.push(parseInt("0x" + t.slice(n, n + 2)));
return "rgb(" + r.join(",") + ")";
}
return t
return t;
}
function LightenDarkenColor(e, t) {
var o = !1;
"#" == e[0] && (e = e.slice(1), o = !0);
var n = parseInt(e, 16), r = (n >> 16) + t;
255 < r ? r = 255 : r < 0 && (r = 0);
var a = (n >> 8 & 255) + t;
255 < a ? a = 255 : a < 0 && (a = 0);
"#" == e[0] && ((e = e.slice(1)), (o = !0));
var n = parseInt(e, 16),
r = (n >> 16) + t;
255 < r ? (r = 255) : r < 0 && (r = 0);
var a = ((n >> 8) & 255) + t;
255 < a ? (a = 255) : a < 0 && (a = 0);
var i = (255 & n) + t;
return 255 < i ? i = 255 : i < 0 && (i = 0), (o ? "#" : "") + String("000000" + (i | a << 8 | r << 16).toString(16)).slice(-6)
return (
255 < i ? (i = 255) : i < 0 && (i = 0),
(o ? "#" : "") +
String("000000" + (i | (a << 8) | (r << 16)).toString(16)).slice(-6)
);
}
function getContrastYIQ(e) {
var t = colorRgb(e).match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/), o = 299 * t[1] + 587 * t[2] + 114 * t[3];
return .5 <= (o /= 255e3) ? "light" : "dark"
var t = colorRgb(e).match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/),
o = 299 * t[1] + 587 * t[2] + 114 * t[3];
return 0.5 <= (o /= 255e3) ? "light" : "dark";
}
function navTitle() {
var e = document.title.replace(" | halo", "");
document.getElementById("page-name-text").innerHTML = e
var e = document.title.replace(" | 张洪Heo", "");
document.getElementById("page-name-text").innerHTML = e;
}
checkOpen.toString = function () {
this.opened = !0
}, window.onload = function () {
for (var e = document.getElementsByClassName("copybtn"), t = 0; t < e.length; t++) document.getElementsByClassName("copybtn")[t].addEventListener("click", function () {
showcopy()
function showcopy() {
var e;
void 0 !== GLOBAL_CONFIG.Snackbar
? btf.snackbarShow(GLOBAL_CONFIG.copy.success)
: (((e = ctx.previousElementSibling).innerText =
GLOBAL_CONFIG.copy.success),
(e.style.opacity = 1),
setTimeout(function () {
e.style.opacity = 0;
}, 700));
}
(checkOpen.toString = function () {
this.opened = !0;
}),
(window.onload = function () {
for (
var e = document.getElementsByClassName("copybtn"), t = 0;
t < e.length;
t++
)
document
.getElementsByClassName("copybtn")
[t].addEventListener("click", function () {
showcopy();
});
heo.initThemeColor();
});
heo.initThemeColor()
};
var getTimeState = function () {
var e = (new Date).getHours(), t = "";
return 0 <= e && e <= 5 ? t = "晚安" : 5 < e && e <= 10 ? t = "早上好" : 10 < e && e <= 14 ? t = "中午好" : 14 < e && e <= 18 ? t = "下午好" : 18 < e && e <= 24 && (t = "晚上好"), t
var e = new Date().getHours(),
t = "";
return (
0 <= e && e <= 5
? (t = "晚安")
: 5 < e && e <= 10
? (t = "早上好")
: 10 < e && e <= 14
? (t = "中午好")
: 14 < e && e <= 18
? (t = "下午好")
: 18 < e && e <= 24 && (t = "晚上好"),
t
);
};
function fly_to_top() {
document.getElementById("guli_top").classList.add("open_wing"), setTimeout(function () {
document.getElementById("guli_top").classList.add("flying"), btf.scrollToDest(0, 300)
}, 300), setTimeout(function () {
document.getElementById("guli_top").classList.remove("flying"), document.getElementById("guli_top").classList.remove("open_wing"), document.getElementById("guli_top").style.cssText = "opacity: ''; transform: ''"
}, 600)
document.getElementById("guli_top").classList.add("open_wing"),
setTimeout(function () {
document.getElementById("guli_top").classList.add("flying"),
btf.scrollToDest(0, 300);
}, 300),
setTimeout(function () {
document.getElementById("guli_top").classList.remove("flying"),
document.getElementById("guli_top").classList.remove("open_wing"),
(document.getElementById("guli_top").style.cssText =
"opacity: ''; transform: ''");
}, 600);
}
var navFn = {
switchDarkMode: function () {
"light" == ("dark" === document.documentElement.getAttribute("data-theme") ? "dark" : "light") ? (activateDarkMode(), saveToLocal.set("theme", "dark", 2), void 0 !== GLOBAL_CONFIG.Snackbar && btf.snackbarShow(GLOBAL_CONFIG.Snackbar.day_to_night, !1, 2e3)) : (activateLightMode(), saveToLocal.set("theme", "light", 2), void 0 !== GLOBAL_CONFIG.Snackbar && btf.snackbarShow(GLOBAL_CONFIG.Snackbar.night_to_day, !1, 2e3)), "function" == typeof utterancesTheme && utterancesTheme(), "object" === ("undefined" == typeof FB ? "undefined" : _typeof(FB)) && window.loadFBComment(), window.DISQUS && document.getElementById("disqus_thread").children.length && setTimeout(function () {
return window.disqusReset()
"light" ==
("dark" === document.documentElement.getAttribute("data-theme")
? "dark"
: "light")
? (activateDarkMode(),
saveToLocal.set("theme", "dark", 2),
void 0 !== GLOBAL_CONFIG.Snackbar &&
btf.snackbarShow(GLOBAL_CONFIG.Snackbar.day_to_night, !1, 2e3))
: (activateLightMode(),
saveToLocal.set("theme", "light", 2),
void 0 !== GLOBAL_CONFIG.Snackbar &&
btf.snackbarShow(GLOBAL_CONFIG.Snackbar.night_to_day, !1, 2e3)),
"function" == typeof utterancesTheme && utterancesTheme(),
"object" === ("undefined" == typeof FB ? "undefined" : _typeof(FB)) &&
window.loadFBComment(),
window.DISQUS &&
document.getElementById("disqus_thread").children.length &&
setTimeout(function () {
return window.disqusReset();
}, 200);
var e, t, o, n = "light" === document.documentElement.getAttribute("data-theme") ? "#363636" : "#F7F7FA";
document.getElementById("posts-chart") && ((e = postsOption).textStyle.color = n, e.title.textStyle.color = n, e.xAxis.axisLine.lineStyle.color = n, e.yAxis.axisLine.lineStyle.color = n, postsChart.setOption(e)), document.getElementById("tags-chart") && ((t = tagsOption).textStyle.color = n, t.title.textStyle.color = n, t.xAxis.axisLine.lineStyle.color = n, t.yAxis.axisLine.lineStyle.color = n, tagsChart.setOption(t)), document.getElementById("categories-chart") && ((o = categoriesOption).textStyle.color = n, o.title.textStyle.color = n, o.legend.textStyle.color = n, categoriesChart.setOption(o))
}
var e,
t,
o,
n =
"light" === document.documentElement.getAttribute("data-theme")
? "#363636"
: "#F7F7FA";
document.getElementById("posts-chart") &&
(((e = postsOption).textStyle.color = n),
(e.title.textStyle.color = n),
(e.xAxis.axisLine.lineStyle.color = n),
(e.yAxis.axisLine.lineStyle.color = n),
postsChart.setOption(e)),
document.getElementById("tags-chart") &&
(((t = tagsOption).textStyle.color = n),
(t.title.textStyle.color = n),
(t.xAxis.axisLine.lineStyle.color = n),
(t.yAxis.axisLine.lineStyle.color = n),
tagsChart.setOption(t)),
document.getElementById("categories-chart") &&
(((o = categoriesOption).textStyle.color = n),
(o.title.textStyle.color = n),
(o.legend.textStyle.color = n),
categoriesChart.setOption(o));
},
};
function RemoveRewardMask() {
$(".reward-main").attr("style", "display: none"), $("#quit-box").attr("style", "display: none")
$(".reward-main").attr("style", "display: none"),
$("#quit-box").attr("style", "display: none");
}
function AddRewardMask() {
$(".reward-main").attr("style", "display: flex");
}
function travelling() {
fetch("https://moments.zhheo.com/randomfriend")
.then(function (e) {
return e.json();
})
.then(function (e) {
var t = e.name,
o = e.link,
n =
"点击前往按钮进入随机一个友链,不保证跳转网站的安全性和可用性。本次随机到的是本站友链:「" +
t +
"」";
document.styleSheets[0].addRule(
":root",
"--heo-snackbar-time:8000ms!important"
),
Snackbar.show({
text: n,
duration: 8e3,
pos: "top-center",
actionText: "前往",
onActionClick: function (e) {
$(e).css("opacity", 0), window.open(o, "_blank");
},
});
});
}
function toforeverblog() {
Snackbar.show({
text: "点击前往按钮进入「十年之约」项目中的成员博客,不保证跳转网站的安全性和可用性",
duration: 8e3,
pos: "top-center",
actionText: "前往",
onActionClick: function (e) {
$(e).css("opacity", 0),
window.open(link, "https://www.foreverblog.cn/go.html");
},
});
}
function totraveling() {
btf.snackbarShow(
"即将跳转到「开往」项目的成员博客,不保证跳转网站的安全性和可用性",
!1,
5e3
),
setTimeout(function () {
window.open("https://travellings.link/");
}, "5000");
}
// 移除加载动画
function removeLoading() {
setTimeout(function () {
preloader.endLoading()
}, 3e3)
preloader.endLoading();
}, 3e3);
}
function addFriendLink() {
var e = document.getElementsByClassName("el-textarea__inner")[0],
t = document.createEvent("HTMLEvents");
t.initEvent("input", !0, !0),
(e.value = "昵称:\n网站地址\n头像图片url\n描述\n"),
e.dispatchEvent(t),
heo.scrollTo("#post-comment"),
e.focus(),
e.setSelectionRange(-1, -1);
}
function getArrayItems(e, t) {
var o = new Array;
var o = new Array();
for (var n in e) o.push(e[n]);
for (var r = new Array, a = 0; a < t && 0 < o.length; a++) {
for (var r = new Array(), a = 0; a < t && 0 < o.length; a++) {
var i = Math.floor(Math.random() * o.length);
r[a] = o[i], o.splice(i, 1)
(r[a] = o[i]), o.splice(i, 1);
}
return r
return r;
}
function owoBig() {
document.getElementById("post-comment").addEventListener("DOMNodeInserted", function (e) {
var t, o, n, a;
!e.target.classList || "OwO-body" != e.target.classList.value || (t = e.target) && (n = !(o = ""), (a = document.createElement("div")).id = "owo-big", document.querySelector("body").appendChild(a), t.addEventListener("contextmenu", function (e) {
return e.preventDefault()
}), t.addEventListener("mouseover", function (r) {
"LI" == r.target.tagName && n && (n = !1, o = setTimeout(function () {
var e = 3 * r.path[0].clientHeight, t = 3 * r.path[0].clientWidth,
o = r.x - r.offsetX - (t - r.path[0].clientWidth) / 2, n = r.y - r.offsetY;
a.style.height = e + "px", a.style.width = t + "px", a.style.left = o + "px", a.style.top = n + "px", a.style.display = "flex", a.innerHTML = '<img src="'.concat(r.target.querySelector("img").src, '">')
}, 300))
}), t.addEventListener("mouseout", function (e) {
a.style.display = "none", n = !0, clearTimeout(o)
}))
})
document
.getElementById("post-comment")
.addEventListener("DOMNodeInserted", function (e) {
var t, o, n, a;
!e.target.classList ||
"OwO-body" != e.target.classList.value ||
((t = e.target) &&
((n = !(o = "")),
((a = document.createElement("div")).id = "owo-big"),
document.querySelector("body").appendChild(a),
t.addEventListener("contextmenu", function (e) {
return e.preventDefault();
}),
t.addEventListener("mouseover", function (r) {
"LI" == r.target.tagName &&
n &&
((n = !1),
(o = setTimeout(function () {
var e = 3 * r.path[0].clientHeight,
t = 3 * r.path[0].clientWidth,
o = r.x - r.offsetX - (t - r.path[0].clientWidth) / 2,
n = r.y - r.offsetY;
(a.style.height = e + "px"),
(a.style.width = t + "px"),
(a.style.left = o + "px"),
(a.style.top = n + "px"),
(a.style.display = "flex"),
(a.innerHTML = '<img src="'.concat(
r.target.querySelector("img").src,
'">'
));
}, 300)));
}),
t.addEventListener("mouseout", function (e) {
(a.style.display = "none"), (n = !0), clearTimeout(o);
})));
});
}
function percent() {
var 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,
o = Math.round(e / t * 100), n = document.querySelector("#percent"),
r = window.scrollY + document.documentElement.clientHeight,
a = document.getElementById("post-tools") || document.getElementById("footer");
a.offsetTop + a.offsetHeight / 2 < r || 90 < o ? (document.querySelector("#nav-totop").classList.add("long"), n.innerHTML = "返回顶部") : (document.querySelector("#nav-totop").classList.remove("long"), n.innerHTML = o)
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),
n = document.querySelector("#percent"),
r = window.scrollY + document.documentElement.clientHeight,
a =
document.getElementById("post-tools") ||
document.getElementById("footer");
a.offsetTop + a.offsetHeight / 2 < r || 90 < o
? (document.querySelector("#nav-totop").classList.add("long"),
(n.innerHTML = "返回顶部"))
: (document.querySelector("#nav-totop").classList.remove("long"),
(n.innerHTML = o)),
(window.onscroll = percent);
}
document.addEventListener("touchstart", function (e) {
RemoveRewardMask()
}, !1);
$(document).unbind("keydown").bind("keydown", function (e) {
if ((e.ctrlKey || e.metaKey) && 67 == e.keyCode && "" != selectTextNow) return btf.snackbarShow("复制成功,复制和转载请标注本文地址"), rm.rightmenuCopyText(selectTextNow), !1
});
document.addEventListener("scroll", btf.throttle(function () {
heo.initThemeColor()
}, 200));
navigator.serviceWorker.getRegistrations().then(function (e) {
var t, o = _createForOfIteratorHelper(e);
try {
for (o.s(); !(t = o.n()).done;) {
t.value.unregister()
document.addEventListener(
"touchstart",
function (e) {
RemoveRewardMask();
},
!1
),
$(document)
.unbind("keydown")
.bind("keydown", function (e) {
if ((e.ctrlKey || e.metaKey) && 67 == e.keyCode && "" != selectTextNow)
return (
btf.snackbarShow("复制成功,复制和转载请标注本文地址"),
rm.rightmenuCopyText(selectTextNow),
!1
);
}),
document.addEventListener(
"scroll",
btf.throttle(function () {
heo.initThemeColor();
}, 200)
),
navigator.serviceWorker.getRegistrations().then(function (e) {
var t,
o = _createForOfIteratorHelper(e);
try {
for (o.s(); !(t = o.n()).done; ) {
t.value.unregister();
}
} catch (e) {
o.e(e);
} finally {
o.f();
}
} catch (e) {
o.e(e)
} finally {
o.f()
}
});
window.onkeydown = function (e) {
123 === e.keyCode && btf.snackbarShow("开发者模式已打开请遵循GPL协议", !1, 3e3)
};
document.querySelector("#console").addEventListener("wheel", function (e) {
e.preventDefault()
});
window.addEventListener("resize", function () {
document.querySelector("#waterfall") && heo.reflashEssayWaterFall()
});
document.getElementById("post-comment") && owoBig(), document.addEventListener("scroll", btf.throttle(function () {
var e, t = window.scrollY + document.documentElement.clientHeight,
o = (window.scrollY, document.getElementById("pagination")), n = document.getElementById("post-tools");
n && o && (e = n.offsetTop + n.offsetHeight / 2, 1300 < document.body.clientWidth && (e < t ? o.classList.add("show-window") : o.classList.remove("show-window")))
}, 200)), "false" !== localStorage.getItem("keyboardToggle") ? document.querySelector("#consoleKeyboard").classList.add("on") : document.querySelector("#consoleKeyboard").classList.remove("on"), $(window).on("keydown", function (e) {
if (27 == e.keyCode && (heo.hideLoading(), heo.hideConsole(), rm.hideRightMenu()), heo_keyboard && e.shiftKey) {
if (16 == e.keyCode && document.querySelector("#keyboard-tips").classList.add("show"), 75 == e.keyCode) return heo.keyboardToggle(), !1;
if (65 == e.keyCode) return heo.showConsole(), !1;
if (77 == e.keyCode) return heo.musicToggle(), !1;
if (82 == e.keyCode) return toRandomPost(), !1;
if (66 == e.keyCode) return pjax.loadUrl("/"), !1;
if (68 == e.keyCode) return rm.switchDarkMode(), !1;
if (70 == e.keyCode) return pjax.loadUrl("/moments/"), !1
}
});
$(window).on("keyup", function (e) {
16 == e.keyCode && document.querySelector("#keyboard-tips").classList.remove("show")
});
document.addEventListener("pjax:send", function () {
//heo.showLoading()
});
document.addEventListener("load", function () {
heo.categoriesBarActive();
heo.tagPageActive();
heo.onlyHome();
heo.addNavBackgroundInit();
heo.reflashEssayWaterFall();
heo.darkModeStatus();
heo.initThemeColor();
percent();
heo.hideLoading();
});
heo.initThemeColor();
window.onscroll = function () {
percent();
};
}),
(window.onkeydown = function (e) {
123 === e.keyCode &&
btf.snackbarShow("开发者模式已打开请遵循GPL协议", !1, 3e3);
}),
document
.querySelector("#algolia-search")
.addEventListener("wheel", function (e) {
e.preventDefault();
}),
document.querySelector("#console").addEventListener("wheel", function (e) {
e.preventDefault();
}),
window.addEventListener("resize", function () {
document.querySelector("#waterfall") && heo.reflashEssayWaterFall();
}),
$(".topGroup").hover(
function () {
console.log("卡片悬浮");
},
function () {
(hoverOnCommentBarrage = !1),
document.getElementById("todayCard").classList.remove("hide"),
(document.getElementById("todayCard").style.zIndex = 1),
console.log("卡片停止悬浮");
}
),
document.getElementById("post-comment") && owoBig(),
document.addEventListener(
"scroll",
btf.throttle(function () {
var e,
t = window.scrollY + document.documentElement.clientHeight,
o = (window.scrollY, document.getElementById("pagination")),
n = document.getElementById("post-tools");
n &&
o &&
((e = n.offsetTop + n.offsetHeight / 2),
1300 < document.body.clientWidth &&
(e < t
? o.classList.add("show-window")
: o.classList.remove("show-window")));
}, 200)
),
"false" !== localStorage.getItem("keyboardToggle")
? document.querySelector("#consoleKeyboard").classList.add("on")
: document.querySelector("#consoleKeyboard").classList.remove("on"),
$(window).on("keydown", function (e) {
if (
(27 == e.keyCode &&
(heo.hideLoading(), heo.hideConsole(), rm.hideRightMenu()),
heo_keyboard && e.shiftKey && !heo_intype)
) {
if (
(16 == e.keyCode &&
document.querySelector("#keyboard-tips").classList.add("show"),
75 == e.keyCode)
)
return heo.keyboardToggle(), !1;
if (65 == e.keyCode) return heo.showConsole(), !1;
if (77 == e.keyCode) return heo.musicToggle(), !1;
if (82 == e.keyCode) return toRandomPost(), !1;
if (72 == e.keyCode) return pjax.loadUrl("/"), !1;
if (68 == e.keyCode) return rm.switchDarkMode(), !1;
if (70 == e.keyCode) return pjax.loadUrl("/moments/"), !1;
if (76 == e.keyCode) return pjax.loadUrl("/link/"), !1;
if (80 == e.keyCode) return pjax.loadUrl("/about/"), !1;
if (84 == e.keyCode) return pjax.loadUrl("/tlink/"), !1;
}
}),
$(window).on("keyup", function (e) {
16 == e.keyCode &&
document.querySelector("#keyboard-tips").classList.remove("show");
}),
(window.onfocus = function () {
document.querySelector("#keyboard-tips").classList.remove("show");
}),
document.addEventListener("pjax:send", function () {
heo.showLoading();
}),
document.addEventListener("pjax:complete", function () {
coverColor(),
addRightMenuClickEvent(),
navTitle(),
percent(),
heo.topPostScroll(),
heo.topCategoriesBarScroll(),
heo.sayhi(),
heo.addTag(),
heo.stopImgRightDrag(),
heo.addFriendLinksInFooter(),
heo.qrcodeCreate(),
heo.hidecookie(),
heo.onlyHome(),
heo.addNavBackgroundInit(),
heo.initIndexEssay(),
heo.changeTimeInEssay(),
heo.reflashEssayWaterFall(),
heo.addMediumInEssay(),
heo.darkModeStatus(),
heo.categoriesBarActive(),
heo.initThemeColor(),
heo.hideLoading(),
heo.tagPageActive();
}),
$("input").focus(function () {
heo_intype = !0;
}),
$("textarea").focus(function () {
heo_intype = !0;
}),
$("input").focusout(function () {
heo_intype = !1;
}),
$("textarea").focusout(function () {
heo_intype = !1;
});

View File

@ -2,180 +2,344 @@
function asyncGeneratorStep(e, n, t, o, i, r, c) {
try {
var m = e[r](c), a = m.value
var m = e[r](c),
a = m.value;
} catch (e) {
return void t(e)
return void t(e);
}
m.done ? n(a) : Promise.resolve(a).then(o, i)
m.done ? n(a) : Promise.resolve(a).then(o, i);
}
function _asyncToGenerator(m) {
return function () {
var e = this, c = arguments;
var e = this,
c = arguments;
return new Promise(function (n, t) {
var o = m.apply(e, c);
function i(e) {
asyncGeneratorStep(o, n, t, i, r, "next", e)
asyncGeneratorStep(o, n, t, i, r, "next", e);
}
function r(e) {
asyncGeneratorStep(o, n, t, i, r, "throw", e)
asyncGeneratorStep(o, n, t, i, r, "throw", e);
}
i(void 0)
})
}
i(void 0);
});
};
}
var rm = {};
rm.stopdragimg = $("img"), rm.stopdragimg.on("dragstart", function () {
return !1
}), rm.showRightMenu = function (e) {
var n = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : 0,
t = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : 0, o = $("#rightMenu");
o.css("top", n + "px").css("left", t + "px"), e ? (o.show(), stopMaskScroll()) : o.hide()
}, rm.hideRightMenu = function () {
rm.showRightMenu(!1), $("#rightmenu-mask").attr("style", "display: none")
};
var rmWidth = $("#rightMenu").width(), rmHeight = $("#rightMenu").height();
(rm.stopdragimg = $("img")),
rm.stopdragimg.on("dragstart", function () {
return !1;
}),
(rm.showRightMenu = function (e) {
var n = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : 0,
t = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : 0,
o = $("#rightMenu");
o.css("top", n + "px").css("left", t + "px"),
e ? (o.show(), stopMaskScroll()) : o.hide();
}),
(rm.hideRightMenu = function () {
rm.showRightMenu(!1), $("#rightmenu-mask").attr("style", "display: none");
});
var rmWidth = $("#rightMenu").width(),
rmHeight = $("#rightMenu").height();
rm.reloadrmSize = function () {
rmWidth = $("#rightMenu").width(), rmHeight = $("#rightMenu").height()
(rmWidth = $("#rightMenu").width()), (rmHeight = $("#rightMenu").height());
};
var domhref = "", domImgSrc = "", globalEvent = null;
var domhref = "",
domImgSrc = "",
globalEvent = null;
function imageToBlob(e) {
var t = new Image, o = document.createElement("canvas"), i = o.getContext("2d");
return t.crossOrigin = "", t.src = e, new Promise(function (n) {
t.onload = function () {
o.width = this.naturalWidth, o.height = this.naturalHeight, i.drawImage(this, 0, 0), o.toBlob(function (e) {
n(e)
}, "image/png", .75)
}
})
var t = new Image(),
o = document.createElement("canvas"),
i = o.getContext("2d");
return (
(t.crossOrigin = ""),
(t.src = e),
new Promise(function (n) {
t.onload = function () {
(o.width = this.naturalWidth),
(o.height = this.naturalHeight),
i.drawImage(this, 0, 0),
o.toBlob(
function (e) {
n(e);
},
"image/png",
0.75
);
};
})
);
}
function copyImage(e) {
return _copyImage.apply(this, arguments)
return _copyImage.apply(this, arguments);
}
function _copyImage() {
return (_copyImage = _asyncToGenerator(regeneratorRuntime.mark(function e(n) {
var t, o;
return regeneratorRuntime.wrap(function (e) {
for (; ;) switch (e.prev = e.next) {
case 0:
return e.next = 2, imageToBlob(n);
case 2:
t = e.sent, o = new ClipboardItem({"image/png": t}), navigator.clipboard.write([o]);
case 5:
case"end":
return e.stop()
}
}, e)
}))).apply(this, arguments)
return (_copyImage = _asyncToGenerator(
regeneratorRuntime.mark(function e(n) {
var t, o;
return regeneratorRuntime.wrap(function (e) {
for (; ;)
switch ((e.prev = e.next)) {
case 0:
return (e.next = 2), imageToBlob(n);
case 2:
(t = e.sent),
(o = new ClipboardItem({"image/png": t})),
navigator.clipboard.write([o]);
case 5:
case "end":
return e.stop();
}
}, e);
})
)).apply(this, arguments);
}
function stopMaskScroll() {
document.getElementById("rightmenu-mask") && document.getElementById("rightmenu-mask").addEventListener("mousewheel", function (e) {
rm.hideRightMenu()
}, !1), document.getElementById("rightMenu") && document.getElementById("rightMenu").addEventListener("mousewheel", function (e) {
rm.hideRightMenu()
}, !1)
document.getElementById("rightmenu-mask") &&
document.getElementById("rightmenu-mask").addEventListener(
"mousewheel",
function (e) {
rm.hideRightMenu();
},
!1
),
document.getElementById("rightMenu") &&
document.getElementById("rightMenu").addEventListener(
"mousewheel",
function (e) {
rm.hideRightMenu();
},
!1
);
}
window.oncontextmenu = function (e) {
(window.oncontextmenu = function (e) {
if (768 < document.body.clientWidth) {
var n = e.clientX + 10, t = e.clientY, o = $(".rightMenuOther"), i = $(".rightMenuPlugin"),
r = $("#menu-copytext"), c = $("#menu-pastetext"), m = $("#menu-commenttext"), a = $("#menu-newwindow"),
u = $("#menu-copylink"), h = $("#menu-copyimg"), d = $("#menu-downloadimg"), s = $("#menu-search"),
l = $("#menu-searchBaidu"), g = $("#menu-music-toggle"), w = $("#menu-music-back"),
p = $("#menu-music-forward"), f = $("#menu-music-playlist"), k = $("#menu-music-copyMusicName"),
y = e.target.href, v = e.target.currentSrc, M = !1;
return o.show(), globalEvent = e, selectTextNow && window.getSelection() ? (M = !0, r.show(), m.show(), s.show(), l.show()) : (r.hide(), m.hide(), l.hide(), s.hide()), y ? (M = !0, a.show(), u.show(), domhref = y) : (a.hide(), u.hide()), v ? (M = !0, h.show(), d.show(), domImgSrc = v) : (h.hide(), d.hide()), "input" === e.target.tagName.toLowerCase() || "textarea" === e.target.tagName.toLowerCase() ? (console.log("这是一个输入框"), M = !0, c.show()) : c.hide(), "METING-JS" == e.target.nodeName ? (console.log("这是一个音乐"), M = !0, g.show(), w.show(), p.show(), f.show(), k.show()) : (g.hide(), w.hide(), p.hide(), f.hide(), k.hide()), M ? (o.hide(), i.show()) : i.hide(), rm.reloadrmSize(), n + rmWidth > window.innerWidth && (n -= rmWidth + 10), t + rmHeight > window.innerHeight && (t -= t + rmHeight - window.innerHeight), rm.showRightMenu(!0, t, n), $("#rightmenu-mask").attr("style", "display: flex"), !1
var n = e.clientX + 10,
t = e.clientY,
o = $(".rightMenuOther"),
i = $(".rightMenuPlugin"),
r = $("#menu-copytext"),
c = $("#menu-pastetext"),
m = $("#menu-commenttext"),
a = $("#menu-newwindow"),
u = $("#menu-copylink"),
h = $("#menu-copyimg"),
d = $("#menu-downloadimg"),
s = $("#menu-search"),
l = $("#menu-searchBaidu"),
g = $("#menu-music-toggle"),
w = $("#menu-music-back"),
f = $("#menu-music-forward"),
p = $("#menu-music-playlist"),
k = $("#menu-music-copyMusicName"),
y = e.target.href,
v = e.target.currentSrc,
M = !1;
return (
o.show(),
(globalEvent = e),
selectTextNow && window.getSelection()
? ((M = !0), r.show(), m.show(), s.show(), l.show())
: (r.hide(), m.hide(), l.hide(), s.hide()),
y ? ((M = !0), a.show(), u.show(), (domhref = y)) : (a.hide(), u.hide()),
v
? ((M = !0), h.show(), d.show(), (domImgSrc = v))
: (h.hide(), d.hide()),
"input" === e.target.tagName.toLowerCase() ||
"textarea" === e.target.tagName.toLowerCase()
? (console.log("这是一个输入框"), (M = !0), c.show())
: c.hide(),
"METING-JS" == e.target.nodeName
? (console.log("这是一个音乐"),
(M = !0),
g.show(),
w.show(),
f.show(),
p.show(),
k.show())
: (g.hide(), w.hide(), f.hide(), p.hide(), k.hide()),
M ? (o.hide(), i.show()) : i.hide(),
rm.reloadrmSize(),
n + rmWidth > window.innerWidth && (n -= rmWidth + 10),
t + rmHeight > window.innerHeight &&
(t -= t + rmHeight - window.innerHeight),
rm.showRightMenu(!0, t, n),
$("#rightmenu-mask").attr("style", "display: flex"),
!1
);
}
}, rm.downloadimging = !1, rm.writeClipImg = function (e) {
console.log("按下复制"), rm.hideRightMenu(), btf.snackbarShow("正在下载中,请稍后", !1, 1e4), 0 == rm.downloadimging && (rm.downloadimging = !0, setTimeout(function () {
copyImage(e), btf.snackbarShow("复制成功!图片已添加盲水印,请遵守版权协议"), rm.downloadimging = !1
}, "10000"))
}, rm.switchDarkMode = function () {
navFn.switchDarkMode(), rm.hideRightMenu(), heo.darkModeStatus()
}, rm.copyUrl = function (e) {
$("body").after("<input id='copyVal'></input>");
var n = e, t = document.getElementById("copyVal");
t.value = n, t.select(), t.setSelectionRange(0, t.value.length), document.execCommand("copy"), $("#copyVal").remove()
}, rm.rightmenuCopyText = function (e) {
navigator.clipboard && navigator.clipboard.writeText(e), rm.hideRightMenu()
}, rm.copyPageUrl = function () {
var e = window.location.href;
rm.copyUrl(e), btf.snackbarShow("复制本页链接地址成功", !1, 2e3), rm.hideRightMenu()
}, rm.sharePage = function () {
window.location.href;
rm.copyUrl(url), btf.snackbarShow("复制本页链接地址成功", !1, 2e3), rm.hideRightMenu()
};
}),
(rm.downloadimging = !1),
(rm.writeClipImg = function (e) {
console.log("按下复制"),
rm.hideRightMenu(),
btf.snackbarShow("正在下载中,请稍后", !1, 1e4),
0 == rm.downloadimging &&
((rm.downloadimging = !0),
setTimeout(function () {
copyImage(e),
btf.snackbarShow("复制成功!图片已添加盲水印,请遵守版权协议"),
(rm.downloadimging = !1);
}, "10000"));
}),
(rm.switchDarkMode = function () {
navFn.switchDarkMode(), rm.hideRightMenu(), heo.darkModeStatus();
}),
(rm.copyUrl = function (e) {
$("body").after("<input id='copyVal'></input>");
var n = e,
t = document.getElementById("copyVal");
(t.value = n),
t.select(),
t.setSelectionRange(0, t.value.length),
document.execCommand("copy"),
$("#copyVal").remove();
}),
(rm.rightmenuCopyText = function (e) {
navigator.clipboard && navigator.clipboard.writeText(e), rm.hideRightMenu();
}),
(rm.copyPageUrl = function () {
var e = window.location.href;
rm.copyUrl(e),
btf.snackbarShow("复制本页链接地址成功", !1, 2e3),
rm.hideRightMenu();
}),
(rm.sharePage = function () {
window.location.href;
rm.copyUrl(url),
btf.snackbarShow("复制本页链接地址成功", !1, 2e3),
rm.hideRightMenu();
});
var selectTextNow = "";
function selceText() {
var e = document.selection ? document.selection.createRange().text : window.getSelection() + "";
selectTextNow = e || ""
var e = document.selection
? document.selection.createRange().text
: window.getSelection() + "";
selectTextNow = e || "";
}
function replaceAll(e, n, t) {
return e.split(n).join(t)
return e.split(n).join(t);
}
function addRightMenuClickEvent() {
$("#menu-backward").on("click", function () {
window.history.back(), rm.hideRightMenu()
}), $("#menu-forward").on("click", function () {
window.history.forward(), rm.hideRightMenu()
}), $("#menu-refresh").on("click", function () {
window.location.reload()
}), $("#menu-top").on("click", function () {
btf.scrollToDest(0, 500), rm.hideRightMenu()
}), $(".menu-link").on("click", rm.hideRightMenu), $("#menu-darkmode").on("click", rm.switchDarkMode), $("#menu-home").on("click", function () {
window.location.href = window.location.origin
}), $("#menu-randomPost").on("click", function () {
toRandomPost()
}), $("#menu-translate").on("click", function () {
rm.hideRightMenu(), translateInitialization()
}), $("#menu-copy").on("click", rm.copyPageUrl), $("#menu-pastetext").on("click", rm.pasteText), $("#menu-copytext").on("click", function () {
rm.rightmenuCopyText(selectTextNow), btf.snackbarShow("复制成功,复制和转载请标注本文地址")
}), $("#menu-commenttext").on("click", function () {
rm.rightMenuCommentText(selectTextNow)
}), $("#menu-newwindow").on("click", function () {
window.open(domhref), rm.hideRightMenu()
}), $("#menu-copylink").on("click", rm.copyLink), $("#menu-downloadimg").on("click", function () {
heo.downloadImage(domImgSrc, "zhheo")
}), $("#menu-copyimg").on("click", function () {
rm.writeClipImg(domImgSrc)
}), $("#menu-searchBaidu").on("click", rm.searchBaidu), $("#menu-music-toggle").on("click", heo.musicToggle), $("#menu-music-back").on("click", heo.musicSkipBack), $("#menu-music-forward").on("click", heo.musicSkipForward), $("#menu-music-copyMusicName").on("click", function () {
rm.rightmenuCopyText(heo.musicGetName())
})
window.history.back(), rm.hideRightMenu();
}),
$("#menu-forward").on("click", function () {
window.history.forward(), rm.hideRightMenu();
}),
$("#menu-refresh").on("click", function () {
window.location.reload();
}),
$("#menu-top").on("click", function () {
btf.scrollToDest(0, 500), rm.hideRightMenu();
}),
$(".menu-link").on("click", rm.hideRightMenu),
$("#menu-darkmode").on("click", rm.switchDarkMode),
$("#menu-home").on("click", function () {
window.location.href = window.location.origin;
}),
$("#menu-randomPost").on("click", function () {
toRandomPost();
}),
$("#menu-commentBarrage").on("click", heo.switchCommentBarrage),
$("#rightmenu-mask").on("click", rm.hideRightMenu),
$("#rightmenu-mask").contextmenu(function () {
return rm.hideRightMenu(), !1;
}),
$("#menu-translate").on("click", function () {
rm.hideRightMenu(), translateInitialization();
}),
$("#menu-copy").on("click", rm.copyPageUrl),
$("#menu-pastetext").on("click", rm.pasteText),
$("#menu-copytext").on("click", function () {
rm.rightmenuCopyText(selectTextNow),
btf.snackbarShow("复制成功,复制和转载请标注本文地址");
}),
$("#menu-commenttext").on("click", function () {
rm.rightMenuCommentText(selectTextNow);
}),
$("#menu-newwindow").on("click", function () {
window.open(domhref), rm.hideRightMenu();
}),
$("#menu-copylink").on("click", rm.copyLink),
$("#menu-downloadimg").on("click", function () {
heo.downloadImage(domImgSrc, "zhheo");
}),
$("#menu-copyimg").on("click", function () {
rm.writeClipImg(domImgSrc);
}),
$("#menu-searchBaidu").on("click", rm.searchBaidu),
$("#menu-music-toggle").on("click", heo.musicToggle),
$("#menu-music-back").on("click", heo.musicSkipBack),
$("#menu-music-forward").on("click", heo.musicSkipForward),
$("#menu-music-copyMusicName").on("click", function () {
rm.rightmenuCopyText(heo.musicGetName()),
btf.snackbarShow("复制歌曲名称成功", !1, 3e3);
});
}
document.onmouseup = document.ondbclick = selceText, rm.readClipboard = function () {
navigator.clipboard && navigator.clipboard.readText().then(function (e) {
return rm.insertAtCaret(globalEvent.target, e)
})
}, rm.insertAtCaret = function (e, n) {
var t, o = e.selectionStart, i = e.selectionEnd;
document.selection ? (e.focus(), document.selection.createRange().text = n, e.focus()) : o || "0" == o ? (t = e.scrollTop, e.value = e.value.substring(0, o) + n + e.value.substring(i, e.value.length), e.focus(), e.selectionStart = o + n.length, e.selectionEnd = o + n.length, e.scrollTop = t) : (e.value += n, e.focus())
}, rm.pasteText = function () {
rm.readClipboard();
rm.hideRightMenu()
}, rm.rightMenuCommentText = function (e) {
rm.hideRightMenu();
var n = document.getElementsByClassName("el-textarea__inner")[0], t = document.createEvent("HTMLEvents");
t.initEvent("input", !0, !0);
var o = replaceAll(e, "\n", "\n> ");
n.value = "> " + o + "\n\n", n.dispatchEvent(t);
var i = document.querySelector("#post-comment").offsetTop;
window.scrollTo(0, i - 80), n.focus(), n.setSelectionRange(-1, -1), document.getElementById("comment-tips") && document.getElementById("comment-tips").classList.add("show")
}, rm.searchBaidu = function () {
btf.snackbarShow("即将跳转到百度搜索", !1, 2e3), setTimeout(function () {
window.open("https://www.baidu.com/s?wd=" + selectTextNow)
}, "2000"), rm.hideRightMenu()
}, rm.copyLink = function () {
rm.rightmenuCopyText(domhref), btf.snackbarShow("已复制链接地址")
};
(document.onmouseup = document.ondbclick = selceText),
(rm.readClipboard = function () {
navigator.clipboard &&
navigator.clipboard.readText().then(function (e) {
return rm.insertAtCaret(globalEvent.target, e);
});
}),
(rm.insertAtCaret = function (e, n) {
var t,
o = e.selectionStart,
i = e.selectionEnd;
document.selection
? (e.focus(), (document.selection.createRange().text = n), e.focus())
: o || "0" == o
? ((t = e.scrollTop),
(e.value =
e.value.substring(0, o) + n + e.value.substring(i, e.value.length)),
e.focus(),
(e.selectionStart = o + n.length),
(e.selectionEnd = o + n.length),
(e.scrollTop = t))
: ((e.value += n), e.focus());
}),
(rm.pasteText = function () {
rm.readClipboard();
rm.hideRightMenu();
}),
(rm.rightMenuCommentText = function (e) {
rm.hideRightMenu();
var n = document.getElementsByClassName("el-textarea__inner")[0],
t = document.createEvent("HTMLEvents");
t.initEvent("input", !0, !0);
var o = replaceAll(e, "\n", "\n> ");
(n.value = "> " + o + "\n\n"), n.dispatchEvent(t);
var i = document.querySelector("#post-comment").offsetTop;
window.scrollTo(0, i - 80),
n.focus(),
n.setSelectionRange(-1, -1),
document.getElementById("comment-tips") &&
document.getElementById("comment-tips").classList.add("show");
}),
(rm.searchBaidu = function () {
btf.snackbarShow("即将跳转到百度搜索", !1, 2e3),
setTimeout(function () {
window.open("https://www.baidu.com/s?wd=" + selectTextNow);
}, "2000"),
rm.hideRightMenu();
}),
(rm.copyLink = function () {
rm.rightmenuCopyText(domhref), btf.snackbarShow("已复制链接地址");
});