UNPKG

halo-theme-dream2.0-plus

Version:

梦之城,童话梦境,动漫类型博客主题。

1 lines 5.68 kB
(()=>{const c=new Set($('link[href*=".css"]').map((e,n)=>$(n).attr("href")).get()),r=new Set($('script[src*=".js"]').map((e,n)=>$(n).attr("src")).get()),n=()=>{var e=(new Date).getTime();return window.pjaxSerialNumber=e,console.log("sn = "+e),e},l=(n,o,t)=>{if(o>=n.length)t&&t();else{let e=$(n[o]).attr("src");r.has(e)?l(n,o+1,t):(console.log((t?"同步":"异步")+"顺序加载js "+e),Utils.cachedScript(e).done(function(){console.log((t?"同步":"异步")+"顺序加载js完成 "+e),r.add(e),window.DProgress&&DProgress.inc(),l(n,o+1,t)}).fail(function(){console.log((t?"同步":"异步")+"顺序加载js失败 "+e),l(n,o+1,t)}))}};$(document).on("click","a[target!=_blank][href]:not([data-not-pjax])",e=>{$.pjax.click(e,".column-main",{scrollTo:(e.currentTarget,0),fragment:".column-main",serialNumber:n(),timeout:8e3})}),$(document).on("submit","form[data-pjax]",function(e){$.pjax.submit(e,".column-main",{scrollTo:(e.currentTarget,0),fragment:".column-main",serialNumber:n(),timeout:8e3})}),$(document).on("pjax:click",function(e,n){n&&(console.log("------------------------"),console.log("pjax:click sn = "+n.serialNumber),document.dispatchEvent(new Event("pjax:click",{bubbles:!0})))}),$(document).on("pjax:beforeSend",function(e,n,o){o&&(console.log("pjax:beforeSend sn = "+o.serialNumber),$("html").addClass("pjax-loading"),document.dispatchEvent(new Event("pjax:beforeSend",{bubbles:!0})))}),$(document).on("pjax:start",function(e,n,o){o&&(console.log("pjax:start sn = "+o.serialNumber),window.DProgress&&DProgress.start(),$(".pjax-close").remove(),document.dispatchEvent(new Event("pjax:start",{bubbles:!0})))}),$(document).on("pjax:send",function(e,n,o){o&&(console.log("pjax:send sn = "+o.serialNumber),document.dispatchEvent(new Event("pjax:send",{bubbles:!0})))}),$(document).on("pjax:clicked",function(e,n){n&&(console.log("pjax:clicked sn = "+n.serialNumber),document.dispatchEvent(new Event("pjax:clicked",{bubbles:!0})))}),$(document).on("pjax:beforeReplace",function(e,n,o){o&&(console.log("pjax:beforeReplace sn = "+o.serialNumber),$(".navbar-nav .current,.panel-side-menu .current").removeClass("current"),commonContext.initNavbar(),commonContext.showBanner(),0<$("html.disable-scroll").length&&$(".navbar-mask").trigger("click"),document.dispatchEvent(new Event("pjax:beforeReplace",{bubbles:!0})))}),$(document).on("pjax:success",async function(e,n,o,t,a){if(a){a=a.serialNumber;if(console.log("pjax:success sn = "+a),window.pjaxSerialNumber===a){commonContext.initGallery(),commonContext.initTocAndNotice(),$("html").removeClass("pjax-loading");const s=$($.parseHTML(n,document,!0)),i=$("head");i.find("meta").remove(),i.find('link[rel="canonical"]').remove(),i.append(s.filter("meta")),i.append(s.filter('link[rel="canonical"]')),s.filter("link").filter(function(){var e=$(this).is("[data-pjax]"),n=$(this).attr("href"),n=n&&(n.startsWith("/plugins/PluginHighlightJS/")||n.startsWith("/plugins/plugin-katex/"));return e||n}).each(function(){let e=$(this).attr("href");c.has(e)||(i.append($(this)),console.log("加载css "+$(this).attr("href")),this.onload=function(){c.add(e),window.DProgress&&DProgress.inc(),console.log("加载css完成 "+$(this).attr("href"))})});let e=s.filter("script").filter(function(){var e=$(this).is("[data-pjax]"),n=$(this).attr("src"),n=n&&(n.startsWith("/plugins/PluginHighlightJS/")||n.startsWith("/plugins/text-diagram/"));return e||n});if(0<e.length){e.filter("[async]").each(function(){let e=$(this).attr("src");r.has(e)||(console.log("异步无序加载js "+e),Utils.cachedScript(e).done(function(){console.log("异步无序js完成 "+e),window.DProgress&&DProgress.inc(),r.add(e)}).fail(function(){console.log("异步无序js失败 "+e)}))}),new Promise(()=>{l(e.filter("[defer]"),0)});let n=e.filter(":not([async]):not([defer])");0<n.length&&await new Promise(e=>{l(n,0,e)})}console.log("全部处理完成"),document.dispatchEvent(new Event("pjax:success",{bubbles:!0})),window.pjaxSerialNumber===a&&(window.journalPjax&&window.journalPjax(a),window.postPjax&&window.postPjax(a),commonContext.initTimeCount(),commonContext.iniTaskItemDisabled(),commonContext.initCarousel(),commonContext.closeFancybox(),window.DProgress)&&DProgress.done()}}}),$(document).on("pjax:timeout",function(e,n,o){o&&(console.log("pjax:timeout sn = "+o.serialNumber),document.dispatchEvent(new Event("pjax:timeout",{bubbles:!0})))}),$(document).on("pjax:error",function(e,n,o,t,a){a&&(console.log(`pjax:error sn = ${a.serialNumber} error `+t),document.dispatchEvent(new Event("pjax:error",{bubbles:!0})))}),$(document).on("pjax:complete",function(e,n,o,t){if(t){if(console.log("pjax:complete sn = "+t.serialNumber),DreamConfig.site_comment){const e=document.title,n=window.location.pathname,o=window.location.href;window.history&&window.history.replaceState&&window.history.replaceState({url:o,title:e,path:n},e,o)}document.dispatchEvent(new Event("pjax:complete",{bubbles:!0}))}}),$(document).on("pjax:end",function(e,n,o){o&&(console.log("pjax:end sn = "+o.serialNumber),null==n&&(commonContext.initTocAndNotice(),commonContext.initCarousel(),commonContext.initTimeCount(),commonContext.iniTaskItemDisabled(),commonContext.closeFancybox(),window.DProgress&&DProgress.done(),$("html").removeClass("pjax-loading")),document.dispatchEvent(new Event("pjax:end",{bubbles:!0})))}),$(document).on("pjax:popstate",function(e){console.log("pjax:popstate")}),window.addEventListener("popstate",function(e){if(console.log("popstate event triggered"),DreamConfig.site_comment&&e.state){const e=window.location.href;$.pjax.reload(".column-main",{container:".column-main",push:!1,url:e,fragment:".column-main",serialNumber:n(),timeout:8e3})}})})();