2019-12-03 11:37:44 +00:00
|
|
|
|
(function ($) {
|
2019-12-16 15:48:13 +00:00
|
|
|
|
// Search
|
2021-04-02 02:29:31 +00:00
|
|
|
|
let $searchWrap = $(".search-form-wrap"),
|
2019-12-03 11:37:44 +00:00
|
|
|
|
isSearchAnim = false,
|
|
|
|
|
searchAnimDuration = 200;
|
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
|
const startSearchAnim = () => {
|
2019-12-03 11:37:44 +00:00
|
|
|
|
isSearchAnim = true;
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
|
const stopSearchAnim = (callback) => {
|
2019-12-03 11:37:44 +00:00
|
|
|
|
setTimeout(function () {
|
|
|
|
|
isSearchAnim = false;
|
|
|
|
|
callback && callback();
|
|
|
|
|
}, searchAnimDuration);
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-02 02:29:31 +00:00
|
|
|
|
$(".nav-item-search").click(() => {
|
2019-12-03 11:37:44 +00:00
|
|
|
|
if (isSearchAnim) return;
|
|
|
|
|
startSearchAnim();
|
2021-04-02 02:29:31 +00:00
|
|
|
|
$searchWrap.addClass("on");
|
2019-12-03 11:37:44 +00:00
|
|
|
|
stopSearchAnim(function () {
|
2021-04-02 02:29:31 +00:00
|
|
|
|
$(".local-search-input").focus();
|
2019-12-03 11:37:44 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
|
$(document).mouseup((e) => {
|
2021-04-02 02:29:31 +00:00
|
|
|
|
const _con = $(".local-search");
|
2019-12-03 11:37:44 +00:00
|
|
|
|
if (!_con.is(e.target) && _con.has(e.target).length === 0) {
|
2021-04-02 02:29:31 +00:00
|
|
|
|
$searchWrap.removeClass("on");
|
2019-12-03 11:37:44 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
2020-04-23 07:04:32 +00:00
|
|
|
|
|
2021-04-02 02:29:31 +00:00
|
|
|
|
// Not recommended in mobile, /search.xml is actually large.
|
|
|
|
|
if ($(".local-search").size()) {
|
|
|
|
|
$.getScript("/js/search.js", function () {
|
|
|
|
|
searchFunc("/search.xml", "local-search-input", "local-search-result");
|
2020-03-24 11:53:16 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
2019-12-03 11:37:44 +00:00
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
|
// Mobile Detect
|
|
|
|
|
const isMobile = {
|
2019-12-03 11:37:44 +00:00
|
|
|
|
Android: function () {
|
|
|
|
|
return navigator.userAgent.match(/Android/i);
|
|
|
|
|
},
|
|
|
|
|
BlackBerry: function () {
|
|
|
|
|
return navigator.userAgent.match(/BlackBerry/i);
|
|
|
|
|
},
|
|
|
|
|
iOS: function () {
|
|
|
|
|
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
|
|
|
|
|
},
|
|
|
|
|
Opera: function () {
|
|
|
|
|
return navigator.userAgent.match(/Opera Mini/i);
|
|
|
|
|
},
|
|
|
|
|
Windows: function () {
|
|
|
|
|
return navigator.userAgent.match(/IEMobile/i);
|
|
|
|
|
},
|
|
|
|
|
any: function () {
|
2021-04-02 02:29:31 +00:00
|
|
|
|
return (
|
|
|
|
|
isMobile.Android() ||
|
|
|
|
|
isMobile.BlackBerry() ||
|
|
|
|
|
isMobile.iOS() ||
|
|
|
|
|
isMobile.Opera() ||
|
|
|
|
|
isMobile.Windows()
|
|
|
|
|
);
|
|
|
|
|
},
|
2019-12-03 11:37:44 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Share
|
2021-04-02 02:29:31 +00:00
|
|
|
|
$(".share-outer").click(() => $(".share-wrap").fadeToggle());
|
2019-12-03 11:37:44 +00:00
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
|
// Lazyload
|
2019-12-03 11:37:44 +00:00
|
|
|
|
$("img.lazy").lazyload({
|
2021-04-02 02:29:31 +00:00
|
|
|
|
effect: "fadeIn",
|
2019-12-03 11:37:44 +00:00
|
|
|
|
});
|
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
|
// JustifiedGallery
|
2021-04-02 02:29:31 +00:00
|
|
|
|
$("#gallery").justifiedGallery({
|
2019-12-04 11:27:58 +00:00
|
|
|
|
rowHeight: 200,
|
2021-04-02 02:29:31 +00:00
|
|
|
|
margins: 5,
|
2019-12-03 11:37:44 +00:00
|
|
|
|
});
|
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
|
// ScrollDown
|
2019-12-03 11:37:44 +00:00
|
|
|
|
$(document).ready(function ($) {
|
2021-04-02 02:29:31 +00:00
|
|
|
|
$(".anchor").click(function (e) {
|
2020-01-09 11:55:59 +00:00
|
|
|
|
e.preventDefault();
|
2021-04-02 02:29:31 +00:00
|
|
|
|
$("main").animate({ scrollTop: $(".cover").height() }, "smooth");
|
2019-12-03 11:37:44 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
|
// To Top
|
|
|
|
|
(() => {
|
2019-12-03 11:37:44 +00:00
|
|
|
|
// When to show the scroll link
|
|
|
|
|
// higher number = scroll link appears further down the page
|
2020-03-24 04:51:01 +00:00
|
|
|
|
const upperLimit = 1000;
|
2019-12-03 11:37:44 +00:00
|
|
|
|
|
|
|
|
|
// Our scroll link element
|
2021-04-02 02:29:31 +00:00
|
|
|
|
const scrollElem = $("#totop");
|
2019-12-03 11:37:44 +00:00
|
|
|
|
|
|
|
|
|
// Scroll to top speed
|
2020-08-08 13:32:36 +00:00
|
|
|
|
const scrollSpeed = 1000;
|
2019-12-03 11:37:44 +00:00
|
|
|
|
|
|
|
|
|
// Show and hide the scroll to top link based on scroll position
|
|
|
|
|
scrollElem.hide();
|
2021-04-02 02:29:31 +00:00
|
|
|
|
$(".content").scroll(function () {
|
|
|
|
|
const scrollTop = $(".content").scrollTop();
|
2019-12-04 11:27:58 +00:00
|
|
|
|
if (scrollTop > upperLimit) {
|
2021-04-02 02:29:31 +00:00
|
|
|
|
$(scrollElem).stop().fadeTo(200, 0.6); // fade back in
|
2019-12-04 11:27:58 +00:00
|
|
|
|
} else {
|
2020-03-23 15:04:50 +00:00
|
|
|
|
$(scrollElem).stop().fadeTo(200, 0); // fade out
|
2019-12-03 11:37:44 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Scroll to top animation on click
|
2019-12-04 11:27:58 +00:00
|
|
|
|
$(scrollElem).click(function () {
|
2021-04-02 02:29:31 +00:00
|
|
|
|
$(".content").animate({ scrollTop: 0 }, scrollSpeed);
|
|
|
|
|
return false;
|
2019-12-03 11:37:44 +00:00
|
|
|
|
});
|
2020-03-24 04:51:01 +00:00
|
|
|
|
})();
|
2019-12-03 11:37:44 +00:00
|
|
|
|
|
2021-07-01 02:14:42 +00:00
|
|
|
|
// Caption
|
|
|
|
|
$(".article-entry").each(function (i) {
|
|
|
|
|
$(this)
|
|
|
|
|
.find("img")
|
|
|
|
|
.each(function () {
|
|
|
|
|
if ($(this).parent().is("a")) return;
|
|
|
|
|
|
|
|
|
|
const { alt } = this;
|
|
|
|
|
|
|
|
|
|
if (alt) $(this).after('<span class="caption">' + alt + "</span>");
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
|
// Mobile Nav
|
2021-04-02 02:29:31 +00:00
|
|
|
|
const $content = $(".content"),
|
|
|
|
|
$sidebar = $(".sidebar");
|
2019-12-03 11:37:44 +00:00
|
|
|
|
|
2021-04-02 02:29:31 +00:00
|
|
|
|
$(".navbar-toggle").on("click", function () {
|
|
|
|
|
$(".content,.sidebar").addClass("anim");
|
|
|
|
|
$content.toggleClass("on");
|
|
|
|
|
$sidebar.toggleClass("on");
|
2019-12-03 11:37:44 +00:00
|
|
|
|
});
|
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
|
// Reward
|
2021-04-02 02:29:31 +00:00
|
|
|
|
$("#reward-btn").click(() => {
|
|
|
|
|
$("#reward").fadeIn(150);
|
|
|
|
|
$("#mask").fadeIn(150);
|
|
|
|
|
});
|
|
|
|
|
$("#reward .close, #mask").click(() => {
|
|
|
|
|
$("#mask").fadeOut(100);
|
|
|
|
|
$("#reward").fadeOut(100);
|
2019-12-16 15:48:13 +00:00
|
|
|
|
});
|
2020-03-23 15:04:50 +00:00
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
|
// DarkMode
|
2021-04-02 02:29:31 +00:00
|
|
|
|
if (sessionStorage.getItem("darkmode") == 1) {
|
|
|
|
|
$("body").addClass("darkmode");
|
|
|
|
|
$("#todark i").removeClass("ri-moon-line").addClass("ri-sun-line");
|
2020-03-24 04:51:01 +00:00
|
|
|
|
} else {
|
2021-04-02 02:29:31 +00:00
|
|
|
|
$("body").removeClass("darkmode");
|
|
|
|
|
$("#todark i").removeClass("ri-sun-line").addClass("ri-moon-line");
|
2020-03-23 15:04:50 +00:00
|
|
|
|
}
|
2021-04-02 02:29:31 +00:00
|
|
|
|
$("#todark").click(() => {
|
|
|
|
|
if (sessionStorage.getItem("darkmode") == 1) {
|
|
|
|
|
$("body").removeClass("darkmode");
|
|
|
|
|
$("#todark i").removeClass("ri-sun-line").addClass("ri-moon-line");
|
|
|
|
|
sessionStorage.removeItem("darkmode");
|
2020-03-24 04:51:01 +00:00
|
|
|
|
} else {
|
2021-04-02 02:29:31 +00:00
|
|
|
|
$("body").addClass("darkmode");
|
|
|
|
|
$("#todark i").removeClass("ri-moon-line").addClass("ri-sun-line");
|
|
|
|
|
sessionStorage.setItem("darkmode", 1);
|
2020-03-23 15:04:50 +00:00
|
|
|
|
}
|
2021-04-02 02:29:31 +00:00
|
|
|
|
});
|
2020-03-24 06:06:11 +00:00
|
|
|
|
|
2021-04-02 02:29:31 +00:00
|
|
|
|
// ShowThemeInConsole
|
|
|
|
|
const ayerInfo = "主题不错?⭐star 支持一下 ->";
|
|
|
|
|
const ayerURL = "https://github.com/Shen-Yu/hexo-theme-ayer";
|
2020-03-24 06:06:11 +00:00
|
|
|
|
const ayerNameStr =
|
2021-04-02 02:29:31 +00:00
|
|
|
|
"\n\n _ __ _______ _____ \n / \\ \\ \\ / / ____| _ \\ \n / _ \\ \\ V /| _| | |_) | \n / ___ \\ | | | |___| _ < \n /_/ \\_\\ _| |_____|_| \\__\\ \n";
|
2020-03-24 06:06:11 +00:00
|
|
|
|
const ayerInfoStyle =
|
2021-04-02 02:29:31 +00:00
|
|
|
|
"background-color: #49b1f5; color: #fff; padding: 8px; font-size: 14px;";
|
2020-03-24 06:06:11 +00:00
|
|
|
|
const ayerURLStyle =
|
2021-04-02 02:29:31 +00:00
|
|
|
|
"background-color: #ffbca2; padding: 8px; font-size: 14px;";
|
|
|
|
|
const ayerNameStyle = "background-color: #eaf8ff;";
|
2020-03-24 06:06:11 +00:00
|
|
|
|
|
|
|
|
|
console.log(
|
2021-04-02 02:29:31 +00:00
|
|
|
|
"%c%s%c%s%c%s",
|
2020-03-24 06:06:11 +00:00
|
|
|
|
ayerInfoStyle,
|
|
|
|
|
ayerInfo,
|
|
|
|
|
ayerURLStyle,
|
|
|
|
|
ayerURL,
|
|
|
|
|
ayerNameStyle,
|
|
|
|
|
ayerNameStr
|
|
|
|
|
);
|
2019-12-03 11:37:44 +00:00
|
|
|
|
})(jQuery);
|
|
|
|
|
|
2021-04-02 02:29:31 +00:00
|
|
|
|
// Tracking
|
|
|
|
|
!(function (p) {
|
|
|
|
|
"use strict";
|
|
|
|
|
!(function (t) {
|
|
|
|
|
var s = window,
|
|
|
|
|
e = document,
|
|
|
|
|
i = p,
|
|
|
|
|
c = "".concat(
|
|
|
|
|
"https:" === e.location.protocol ? "https://" : "http://",
|
|
|
|
|
"sdk.51.la/js-sdk-pro.min.js"
|
|
|
|
|
),
|
|
|
|
|
n = e.createElement("script"),
|
|
|
|
|
r = e.getElementsByTagName("script")[0];
|
|
|
|
|
(n.type = "text/javascript"),
|
|
|
|
|
n.setAttribute("charset", "UTF-8"),
|
|
|
|
|
(n.async = !0),
|
|
|
|
|
(n.src = c),
|
|
|
|
|
(n.id = "LA_COLLECT"),
|
|
|
|
|
(i.d = n);
|
|
|
|
|
var o = function () {
|
|
|
|
|
s.LA.ids.push(i);
|
|
|
|
|
};
|
|
|
|
|
s.LA ? s.LA.ids && o() : ((s.LA = p), (s.LA.ids = []), o()),
|
|
|
|
|
r.parentNode.insertBefore(n, r);
|
|
|
|
|
})();
|
|
|
|
|
})({ id: "JGjrOr2rebvP6q2a", ck: "JGjrOr2rebvP6q2a" });
|