UNPKG

halo-theme-dream2.0-plus

Version:

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

1 lines 6.42 kB
(()=>{const r=new Set($('link[href*=".css"]').map((e,n)=>$(n).attr("href")).get()),c=new Set($('script[src*=".js"]').map((e,n)=>$(n).attr("src")).get()),t=["multi-cube","wave-pulse","orbit-system"],o=()=>{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");c.has(e)?l(n,o+1,t):(console.log((t?"同步":"异步")+"顺序加载js "+e),Utils.cachedScript(e).done(function(){console.log((t?"同步":"异步")+"顺序加载js完成 "+e),c.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:o(),timeout:8e3})}),$(document).on("submit","form[data-pjax]",function(e){$.pjax.submit(e,".column-main",{scrollTo:(e.currentTarget,0),fragment:".column-main",serialNumber:o(),timeout:8e3})}),$(document).on("pjax:click",function(e,n){n&&n.serialNumber&&(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&&o.serialNumber&&(console.log("pjax:beforeSend sn = "+o.serialNumber),"scale"===DreamConfig.pjax_animation_style?$("html").addClass("pjax-loading"):t.includes(DreamConfig.pjax_animation_style)&&$(".pjax-animation-container").addClass("active"),window.DProgress&&DProgress.start(),document.dispatchEvent(new Event("pjax:beforeSend",{bubbles:!0})))}),$(document).on("pjax:start",function(e,n,o){o&&o.serialNumber&&(console.log("pjax:start sn = "+o.serialNumber),$(".pjax-close").remove(),document.dispatchEvent(new Event("pjax:start",{bubbles:!0})))}),$(document).on("pjax:send",function(e,n,o){o&&o.serialNumber&&(console.log("pjax:send sn = "+o.serialNumber),document.dispatchEvent(new Event("pjax:send",{bubbles:!0})))}),$(document).on("pjax:clicked",function(e,n){n&&n.serialNumber&&(console.log("pjax:clicked sn = "+n.serialNumber),document.dispatchEvent(new Event("pjax:clicked",{bubbles:!0})))}),$(document).on("pjax:beforeReplace",function(e,n,o){o&&o.serialNumber&&(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.serialNumber){a=a.serialNumber;if(console.log("pjax:success sn = "+a),window.pjaxSerialNumber===a){commonContext.initGallery(),commonContext.initTocAndNotice();var n=$($.parseHTML(n,document,!0)),i=n.find(".dream2-container-content-main");if(i.length){const r=$(".dream2-container-content-main"),c=i.attr("class")||"";r.each(function(){this.className=c}),console.log("替换容器[.dream2-container-content-main]的css:"+c)}const s=$("head");s.find("meta").remove(),s.find('link[rel="canonical"]').remove(),s.append(n.filter("meta")),s.append(n.filter('link[rel="canonical"]')),n.find("link[href]").addBack("link[href]").filter(function(){var e=$(this).is("[data-pjax]"),n=$(this).attr("href"),n=n&&n.startsWith("/plugins");return e||n}).each(function(){let e=$(this).attr("href");r.has(e)||(s.append($(this)),console.log("加载css "+$(this).attr("href")),this.onload=function(){r.add(e),window.DProgress&&DProgress.inc(),console.log("加载css完成 "+$(this).attr("href"))})});let e=n.find("script[src]").addBack("script[src]").filter(function(){var e=$(this).is("[data-pjax]"),n=$(this).attr("src"),n=n&&n.startsWith("/plugins");return e||n});if(0<e.length){e.filter("[async]").each(function(){let e=$(this).attr("src");c.has(e)||(console.log("异步无序加载js "+e),Utils.cachedScript(e).done(function(){console.log("异步无序js完成 "+e),window.DProgress&&DProgress.inc(),c.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&&o.serialNumber&&("scale"===DreamConfig.pjax_animation_style?$("html").removeClass("pjax-loading"):t.includes(DreamConfig.pjax_animation_style)&&$(".pjax-animation-container").removeClass("active"),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&&a.serialNumber&&(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){var a,i;t&&t.serialNumber&&(console.log("pjax:complete sn = "+t.serialNumber),t=document.title,a=window.location.pathname,i=window.location.href,window.history&&window.history.replaceState&&window.history.replaceState({url:i,title:t,path:a},t,i),document.dispatchEvent(new Event("pjax:complete",{bubbles:!0})))}),$(document).on("pjax:end",function(e,n,o){o&&o.serialNumber&&(console.log("pjax:end sn = "+o.serialNumber),null==n&&(commonContext.initTocAndNotice(),commonContext.initCarousel(),commonContext.initTimeCount(),commonContext.iniTaskItemDisabled(),commonContext.closeFancybox(),window.DProgress)&&DProgress.done(),document.dispatchEvent(new Event("pjax:end",{bubbles:!0})),"scale"===DreamConfig.pjax_animation_style?$("html").removeClass("pjax-loading"):t.includes(DreamConfig.pjax_animation_style)&&$(".pjax-animation-container").removeClass("active"))}),$(document).on("pjax:popstate",function(e){console.log("pjax:popstate")}),window.addEventListener("popstate",function(e){console.log("popstate event triggered");var n=window.location.href;$.pjax.reload(".column-main",{container:".column-main",push:!1,url:n,fragment:".column-main",serialNumber:o(),timeout:8e3})})})();