2023-09-16 01:07:44 +08:00
|
|
|
(()=>{window.encrypt=e=>window.btoa(unescape(encodeURIComponent(e))),window.decrypt=e=>decodeURIComponent(escape(window.atob(e)));const t={initWidget(){var e=$(".columns .column-right"),t=$(".columns .column-right-shadow");if(e.length&&t.length&&!t[0].children.length)for(const n of e[0].children)t[0].append(n.cloneNode(!0))},initTocAndNotice(){var e=location["pathname"],t=(window.tocPjax&&window.tocPjax(),0===$(".widget.toc .card-content ul").length),e="toc"===DreamConfig.notice_show_mode&&!t||"index"===DreamConfig.notice_show_mode&&"/"!==e;t?$(".widget.toc,.action-toc").addClass("is-hidden-all"):$(".widget.toc,.action-toc").removeClass("is-hidden-all"),e?$(".widget.notice").addClass("is-hidden-all"):$(".widget.notice").removeClass("is-hidden-all")},initBanner(){const i=$(".banner-info-desc");if(0!==i.length){const o=i.text();i.text("");let t,n="",a=!0;const s=function(){var e=n.length;a&&e<o.length?(n+=o.charAt(e),i.text(n)):!a&&0<e?(n=n.slice(0,e-1),i.text(n)):(clearInterval(t),a=!a,t=setInterval(s,a?500:80))};t=setInterval(s,a?500:80)}},initGallery(){$(".main-content img:not(.not-gallery)").each(function(){0===$(this).parents("[data-fancybox],mew-photos").length&&$(this).wrap(`<div class="gallery-item"><div data-fancybox="gallery" ${this.alt?`data-caption="${this.alt}"`:""} href="${$(this).attr("src")}"></div>${this.alt&&DreamConfig.show_img_name?`<p>${this.alt}</p>`:""}</div>`)})},initMode(){let t=localStorage.getItem("night")||!1;const n=e=>{e?document.documentElement.classList.add("night"):document.documentElement.classList.remove("night"),localStorage.setItem("night",e),t=e};$("#toggle-mode").on("click",()=>n("true"!==t.toString())),"system"===DreamConfig.default_theme&&window.matchMedia("(prefers-color-scheme: dark)").addListener(e=>n(e.matches))},initNavbar(){var t=$(".navbar-nav a"),e=$(".panel-side-menu .link");let n=0;var{href:a,pathname:i}=location;if(i&&"/"!==i)for(let e=0;e<t.length;e++){const o=t[e].getAttribute("href");if((i.includes(o)||a.includes(o))&&(n=e,i===o||a===o))break}const o=t.eq(n);o.addClass("current"),o.parents(".item-dropdown").length&&o.parents(".item-dropdown").find(".item-dropdown-link a").addClass("current"),e.eq(n).addClass("current")},initDropMenu(){$(".item-dropdown").each(function(e,t){var n=$(this).find(".item-dropdown-menu"),a=$(t).attr("trigger")||"click",t=$(t).attr("placement")||$(this).height()||0;n.css("top",t),"hover"===a?$(this).hover(()=>$(this).addClass("active"),()=>$(this).removeClass("active")):($(this).on("click",function(e){e.stopPropagation(),$(this).toggleClass("active"),$(document).one("click",()=>$(this).removeClass("active")),e.stopPropagation()}),n.on("click",e=>e.stopPropagation()))})},initScroll(){window.initTop=0,document.addEventListener("scroll",()=>{const e=$(document).scrollTop(),t=(i=e>window.initTop,window.initTop=e,i),n=$("body"),a=$(".actions");var i;50<e&&t?n.addClass("move-up"):n.removeClass("move-up"),100<e?a.addClass("show"):a.removeClass("show")})},drawerMobile(){$(".navbar-slideicon").on("click",function(e){e.stopPropagation(),$(".navbar-searchout").removeClass("active");var e=$("html"),t=$(".navbar-mask"),n=$(".navbar-slideout");n.hasClass("active")?(e.removeClass("disable-scroll"),t.removeClass("active slideout"),n.removeClass("active")):(e.addClass("disable-scroll"),t.addClass("active slideout"),n.addClass("active"))}),$(".action-toc").on("click",function(e){e.stopPropagation(),$(".navbar-searchout").removeClass("active");var e=$("html"),t=$(".navbar-mask"),n=$(".navbar-slideout");n.hasClass("active")?(e.removeClass("disable-scroll"),t.removeClass("active slideout"),n.removeClass("active slideout-toc")):(e.addClass("disable-scroll"),t.addClass("active slideout"),n.addClass("active slideout-toc"))})},back2Top(){$("#back-to-top").on("click",function(){$("body, html").animate({scrollTop:0},400)})},maskClose(){$(".navbar-mask").on("click",function(e){e.stopPropagation(),$("html").removeClass("disable-scroll"),$(".navbar-mask").removeClass("active slideout"),$(".navbar-searchout").removeClass("active"),$(".navbar-slideout").removeClass("active
|