3 lines
19 KiB
JavaScript
3 lines
19 KiB
JavaScript
"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},_typeof(t)}function _regeneratorRuntime(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_regeneratorRuntime=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},r=o.iterator||"@@iterator",i=o.asyncIterator||"@@asyncIterator",a=o.toStringTag||"@@toStringTag";function c(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(T){c=function(t,e,n){return t[e]=n}}function s(t,e,n,o){var r=e&&e.prototype instanceof d?e:d,i=Object.create(r.prototype),a=new E(o||[]);return i._invoke=function(t,e,n){var o="suspendedStart";return function(r,i){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===r)throw i;return C()}for(n.method=r,n.arg=i;;){var a=n.delegate;if(a){var c=b(a,n);if(c){if(c===u)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===o)throw o="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o="executing";var s=l(t,e,n);if("normal"===s.type){if(o=n.done?"completed":"suspendedYield",s.arg===u)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o="completed",n.method="throw",n.arg=s.arg)}}}(t,n,a),i}function l(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(T){return{type:"throw",arg:T}}}t.wrap=s;var u={};function d(){}function f(){}function h(){}var m={};c(m,r,(function(){return this}));var p=Object.getPrototypeOf,v=p&&p(p($([])));v&&v!==e&&n.call(v,r)&&(m=v);var g=h.prototype=d.prototype=Object.create(m);function y(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function o(r,i,a,c){var s=l(t[r],t,i);if("throw"!==s.type){var u=s.arg,d=u.value;return d&&"object"==_typeof(d)&&n.call(d,"__await")?e.resolve(d.__await).then((function(t){o("next",t,a,c)}),(function(t){o("throw",t,a,c)})):e.resolve(d).then((function(t){u.value=t,a(u)}),(function(t){return o("throw",t,a,c)}))}c(s.arg)}var r;this._invoke=function(t,n){function i(){return new e((function(e,r){o(t,n,e,r)}))}return r=r?r.then(i,i):i()}}function b(t,e){var n=t.iterator[e.method];if(undefined===n){if(e.delegate=null,"throw"===e.method){if(t.iterator["return"]&&(e.method="return",e.arg=undefined,b(t,e),"throw"===e.method))return u;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var o=l(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,u;var r=o.arg;return r?r.done?(e[t.resultName]=r.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=undefined),e.delegate=null,u):r:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,u)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function $(t){if(t){var e=t[r];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function e(){for(;++o<t.length;)if(n.call(t,o))return e.value=t[o],e.done=!1,e;return e.value=undefined,e.done=!0,e};return i.next=i}}return{next:C}}function C(){return{value:undefined,done:!0}}return f.prototype=h,c(g,"constructor",h),c(h,"constructor",f),f.displayName=c(h,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,c(t,a,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},y(w.prototype),c(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,n,o,r,i){void 0===i&&(i=Promise);var a=new w(s(e,n,o,r),i);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},y(g),c(g,a,"Generator"),c(g,r,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function o(){for(;e.length;){var n=e.pop();if(n in t)return o.value=n,o.done=!1,o}return o.done=!0,o}},t.values=$,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=undefined,this.done=!1,this.delegate=null,this.method="next",this.arg=undefined,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=undefined)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function o(n,o){return a.type="throw",a.arg=t,e.next=n,o&&(e.method="next",e.arg=undefined),!!o}for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],a=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var o=this.tryEntries.length-1;o>=0;--o){var r=this.tryEntries[o];if(r.tryLoc<=this.prev&&n.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,u):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),u},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),L(n),u}},"catch":function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var o=n.completion;if("throw"===o.type){var r=o.arg;L(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:$(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=undefined),u}},t}function asyncGeneratorStep(t,e,n,o,r,i,a){try{var c=t[i](a),s=c.value}catch(l){return void n(l)}c.done?e(s):Promise.resolve(s).then(o,r)}function _asyncToGenerator(t){return function(){var e=this,n=arguments;return new Promise((function(o,r){var i=t.apply(e,n);function a(t){asyncGeneratorStep(i,o,r,a,c,"next",t)}function c(t){asyncGeneratorStep(i,o,r,a,c,"throw",t)}a(undefined)}))}}window.requestIdleCallback=window.requestIdleCallback||function(t){var e=Date.now();return setTimeout((function(){t({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-e))}})}),1)},window.cancelIdleCallback=window.cancelIdleCallback||function(t){clearTimeout(t)},window.copyCode=window.copyCode||function(t,e){var n=document.getElementById(e);if(n){var o=n.innerText;navigator.clipboard.writeText(o);var r=t.innerHTML;t.innerHTML='<i class="fa fa-check-circle"></i> 成功~',setTimeout((function(){t.innerHTML=r}),3e3)}},function(){var t,e=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=((null===(t=window.kr)||void 0===t?void 0:t.siteRoot)||"/")+"config/main.json",e.next=3,fetch(n);case 3:return e.next=5,e.sent.json();case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e)})));return function(){return t.apply(this,arguments)}}(),n="",o=function(t){var e,n=!(arguments.length>1&&arguments[1]!==undefined)||arguments[1],o=t/1e3,r=Math.floor(o/60/60/24),i=Math.floor(o/60/60-24*r),a=Math.floor(o/60-1440*r-60*i),c=Math.floor(o-86400*r-3600*i-60*a),s=r.toString(),l=i.toString(),u=a.toString(),d=c.toString();return n?(s&&1===s.length&&(s="0"+s),l&&1===l.length&&(l="0"+l),u&&1===u.length&&(u="0"+u),d&&1===d.length&&(d="0"+d),e=s+"天"+l+"小时"+u+"分"+d+"秒"):e=r<540?r<60?s+"天":Math.floor(r/30).toString()+"个月":Math.floor(r/365).toString()+"年",e},r=function(t,e){var n=0;return function(){var o=this,r=arguments;clearTimeout(n),n=setTimeout((function(){t.apply(o,r)}),e||0)}},i=function(){var t,e;t=document.getElementById("krw-toc"),e=function(){var e=t.getElementsByClassName("toc-item"),n=[];try{Array.from(e).forEach((function(t){var e=t.querySelector(".toc-link"),o=decodeURI(e.getAttribute("href"));if("#"!=o.substring(0,1))throw new Error("TOC 小标题链接无效,格式无限");var r=document.getElementById(o.substring(1));if(!r)throw new Error("TOC 小标题链接无效,未找到相关引用");r.setAttribute("data-toc-id",n.length),n.push({at:r,el:t})}))}catch(p){return console.log("错误:",p.message),void Array.from(e).forEach((function(t){t.classList.add("show")}))}var o=-1,i=function(t){if(o!==t){if(-1!==o){n[o].el.classList.remove("active"),n[o].el.classList.remove("show");for(var e=n[o].el;!e.classList.contains("toc");)e.classList.contains("toc-item")&&e.classList.remove("show"),e=e.parentNode}if(-1!==t){n[t].el.classList.add("active"),n[t].el.classList.add("show");for(var r=n[t].el;!r.classList.contains("toc");)r.classList.contains("toc-item")&&r.classList.add("show"),r=r.parentNode}o=t}};if("IntersectionObserver"in window){var a=r((function(t,e){e===window.scrollY?window.requestAnimationFrame((function(){i(t)})):a(t,window.scrollY)}),100),c=new IntersectionObserver((function(t){var e=null;t.forEach((function(t){var n=Number.parseInt(t.target.getAttribute("data-toc-id"),10);!t.isIntersecting&&t.boundingClientRect.top<=t.rootBounds.top?e=n:t.isIntersecting&&t.boundingClientRect.bottom<t.rootBounds.top+t.rootBounds.height/2&&1===t.intersectionRatio&&(e=n-1)})),null!==e&&a(e,window.scrollY)}),{rootMargin:"-62px 0px 0px 0px",threshold:1});n.forEach((function(t){c.observe(t.at)})),window.addEventListener("pjax:before",(function(){c.disconnect(),n.length=0}),{once:!0})}else{var s=function(){n.forEach((function(t){t.h=t.at.getBoundingClientRect().top+window.scrollY-61}))};s();var l=function(){var t;t=!Number.isInteger(o)||o<0||o>n.length-1?0:o;var e=window.scrollY;if(e>=n[t].h)if(e>=n[n.length-1].h)t=n.length-1;else for(;e>=n[t+1].h;)t++;else for(;e<n[t].h&&!(--t<0););return t},u=r((function(){window.requestAnimationFrame((function(){i(l())}))}),100),d=r((function(){s(),window.requestAnimationFrame((function(){i(l())}))}),100);window.addEventListener("resize",d),window.addEventListener("scroll",u),window.addEventListener("pjax:before",(function(){window.removeEventListener("resize",d),window.removeEventListener("scroll",u),n.length=0}),{once:!0})}var f=document.getElementsByClassName("toc-progress-bar")[0],h=document.querySelector(".kratos-post-content"),m=function(){if(h){var t=window.scrollY||document.documentElement.scrollTop,e=h.clientHeight,n=document.documentElement.clientHeight,o=h.offsetTop,r=e>n?e-n:document.documentElement.scrollHeight-n,i=Math.max(0,Math.min((t-o)/r,1)),a=Math.round(100*i);f.style.width=(100*i).toString()+"%",f.setAttribute("aria-valuenow",a)}};window.addEventListener("scroll",(function(){window.requestAnimationFrame(m)})),m()},t&&(null!==t.offsetParent?e():"IntersectionObserver"in window&&new IntersectionObserver(e,{threshold:0,once:!0}).observe(t)),n=document.title,document.querySelectorAll("figure.highlight").forEach((function(t,e){t.getElementsByTagName("table")[0].getElementsByTagName("tbody")[0].getElementsByTagName("tr")[0].getElementsByClassName("code")[0].setAttribute("id","code-".concat(e)),t.innerHTML+='<button class="copy" onclick="copyCode(this, \'code-'.concat(e,'\')">\n <i class="fa fa-copy"></i> 复制\n </button>')})),"undefined"!=typeof $.fancybox&&($.fancybox.defaults.hash=!1,$(".kratos-hentry").each((function(t){$(this).find("img").each((function(){if(!($(this).parent().hasClass("fancybox")||$(this).parent().hasClass("qrcode")||$(this).parent().is("a"))){var t=this.alt;t&&$(this).after('<span class="caption">'+t+"</span>"),$(this).wrap('<a rel="gallery" href="'+this.src+'" data-fancybox="gallery" data-caption="'+t+'"></a>')}}))})),$(".fancybox").fancybox()),function(){var t="undefined"!=typeof window,e=t&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro|msn)bot|crawl|spider|yand|duckgo/i.test(navigator.userAgent),n=t&&"IntersectionObserver"in window,o=document.querySelector(".post-comments.lazy-load"),r=function(){window.loadCommentsEventHandler&&window.cancelIdleCallback(window.loadCommentsEventHandler),"undefined"!=typeof load_comm&&null!==load_comm&&(window.loadCommentsEventHandler=window.requestIdleCallback(load_comm),load_comm=null)};if(t&&!e&&n&&null!==o){var i=new IntersectionObserver((function(t){t[0].isIntersecting&&(r(),i.disconnect())}),{threshold:0});i.observe(o)}else r()}()},a=function(e){!function(t){for(var e=document.getElementsByClassName("kratos-entry-thumb-new-img"),n=t.cover&&t.cover.randomAmount||20,o=t.cover&&t.cover.baseUrl||"https://cdn.jsdelivr.net/npm/hexo-theme-kratos-rebirth@latest/source/images/thumb/",r=t.cover&&t.cover.filenameTemplate||"thumb_{no}.webp",i=new Array(n+1),a=function(){for(var t,e=5;e>0&&(t=Math.floor(Math.random()*n+1),i[t]);)e--;if(e<=0){t=-1;for(var o=1;o<=n;o++)if(!i[o]){t=o;break}if(-1===t){for(var r=1;r<=n;r++)i[r]=!1;t=Math.floor(Math.random()*n+1)}}return i[t]=!0,t},c=0,s=e.length;c<s;c++)if(!$(e[c]).attr("src")){var l=a(),u=r.replace("{no}",l.toString()),d=void 0;d=u.includes("//")?u:"/"===o.substring(o.length-1)?o+u:o+"/"+u,$(e[c]).attr("src",d)}}(e),function(e){t="\n\n-------------------------\n".concat(e.copyrightNotice,"\n作者:").concat(document.querySelector("meta[name='author']").getAttribute("content"),"\n来源:").concat(document.title,"\n链接:").concat(window.location.href,"\n")}(e),function(t){if(t.expire_day){var e=document.getElementById("expire-alert");if(e){var n=e.querySelector("time"),r=new Date(parseInt(n.getAttribute("datetime"))),i=Date.now()-r;i>24*t.expire_day*3600*1e3&&(n.innerText=o(i,!1),e.classList.remove("hidden"))}}}(e)};function c(){var r,s,l;document.removeEventListener("DOMContentLoaded",c,!1),window.removeEventListener("load",c,!1),e().then((function(e){!function(e){e.copyrightNotice&&(document.body.oncopy=function(e){if(t){var n=window.getSelection().toString();n.length>150&&(e.preventDefault(),e.clipboardData&&e.clipboardData.setData("text/plain",n+t))}})}(e),function(t){if(t.siteLeaveEvent){var e,o=$('[rel="icon"]').attr("href");document.addEventListener("visibilitychange",(function(){document.hidden?(document.title=t.leaveTitle,t.leaveLogo&&$('[rel="icon"]').attr("href",t.leaveLogo),clearTimeout(e)):(document.title=t.returnTitle+" "+n,t.leaveLogo&&$('[rel="icon"]').attr("href",o),e=setTimeout((function(){document.title=n,e=0}),2e3))}))}}(e),function(t){var e=new Date(t.createTime),n=document.getElementById("span_dt");setInterval((function(){n.innerText=o(Date.now()-e)}),1e3)}(e),function(t){$(document).on("click",".donate",(function(){layer.open({type:1,area:["300px","370px"],title:t.donateBtn,resize:!1,scrollbar:!1,content:'<div class="donate-box"><div class="meta-pay text-center"><strong>'+t.scanNotice+'</strong></div><div class="qr-pay text-center"><img class="pay-img" id="alipay_qr" src="'+t.qr_alipay+'"><img class="pay-img d-none" id="wechat_qr" src="'+t.qr_wechat+'"></div><div class="choose-pay text-center mt-2"><input id="alipay" type="radio" name="pay-method" checked><label for="alipay" class="pay-button"><img src="/images/alipay.webp"></label><input id="wechatpay" type="radio" name="pay-method"><label for="wechatpay" class="pay-button"><img src="/images/wechat.webp"></label></div></div>'}),$(".choose-pay input[type='radio']").click((function(){var t=$(this).attr("id");"alipay"==t&&($(".qr-pay #alipay_qr").removeClass("d-none"),$(".qr-pay #wechat_qr").addClass("d-none")),"wechatpay"==t&&($(".qr-pay #alipay_qr").addClass("d-none"),$(".qr-pay #wechat_qr").removeClass("d-none"))}))}))}(e),function(t){if(t.topNavScrollToggle){var e=window.innerHeight,n=!1;window.addEventListener("wheel",(function(){window.requestAnimationFrame((function(){e<window.scrollY?n||(document.body.classList.add("nav-up"),n=!0):e>window.scrollY&&n&&(document.body.classList.remove("nav-up"),n=!1),e=window.scrollY}))}))}}(e),a(e),window.addEventListener("pjax:complete",(function(){a(e)}))})),r=!1,s=function(){window.requestAnimationFrame((function(){window.scrollY>200?r||(document.body.classList.add("scroll-down"),r=!0):r&&(document.body.classList.remove("scroll-down"),r=!1)}))},$(".gotop-box").on("click",(function(t){return $("html, body").animate({scrollTop:$("html").offset().top},500),!1})),s(),window.addEventListener("scroll",s),(l=$("#kratos-menu-wrap").clone()).attr({id:"offcanvas-menu"}),l.find("> ul").attr({id:""}).addClass("ul-me"),$("#kratos-page").prepend(l),$(".js-kratos-nav-toggle").on("click",(function(){$(".nav-toggle").hasClass("toon")?($(".nav-toggle").removeClass("toon"),$("#offcanvas-menu").css("right","-240px")):($(".nav-toggle").addClass("toon"),$("#offcanvas-menu").css("right","0px"))})),$("#offcanvas-menu").css("height",$(window).height()),$("#offcanvas-menu").css("right","-240px"),$(window).resize((function(){var t=$(window);$("#offcanvas-menu").css("height",t.height()),t.width()>769&&$(".nav-toggle").hasClass("toon")&&($(".nav-toggle").removeClass("toon"),$("#offcanvas-menu").css("right","-240px"))})),$(document).click((function(t){var e=$("#offcanvas-menu,.js-kratos-nav-toggle");e.is(t.target)||0!==e.has(t.target).length||$(".nav-toggle").hasClass("toon")&&($(".nav-toggle").removeClass("toon"),$("#offcanvas-menu").css("right","-240px"))})),$(document).on("click",".xHeading",(function(t){$(this).next().slideToggle(300),$(this).parent(".xControl").hasClass("active")?$(this).parent(".xControl").removeClass("active"):$(this).parent(".xControl").addClass("active"),t.preventDefault()})),$(document).on("click",".share",(function(){$(".share-wrap").fadeToggle("slow")})),$(document).on("click","a[class=toc-link]",(function(){return $("html, body").animate({scrollTop:$(decodeURI($(this).attr("href"))).offset().top-60},500),!1})),i()}window.addEventListener("pjax:complete",(function(){i(),"undefined"!=typeof MathJax&&MathJax.Hub.Typeset()})),"complete"===document.readyState?setTimeout(c):(document.addEventListener("DOMContentLoaded",c,!1),window.addEventListener("load",c,!1))}();
|
||
//# sourceMappingURL=../maps/kratosr.min.js.map
|