q78kgblog 0.0.0-1720441708496 → 0.0.0-1720859005089
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/404.html +3 -3
- package/about/index.html +5 -5
- package/archives/2023/02/index.html +4 -4
- package/archives/2023/04/index.html +4 -4
- package/archives/2023/05/index.html +4 -4
- package/archives/2023/08/index.html +4 -4
- package/archives/2023/09/index.html +4 -4
- package/archives/2023/index.html +4 -4
- package/archives/2024/01/index.html +4 -4
- package/archives/2024/02/index.html +4 -4
- package/archives/2024/index.html +4 -4
- package/archives/index.html +4 -4
- package/atom.xml +9 -9
- package/baidusitemap.xml +8 -8
- package/bangumis/index.html +4 -4
- package/bigpie/index.html +3 -3
- package/categories/Hexo/index.html +4 -4
- package/categories/index.html +3 -3
- package/categories//345/271/264/347/273/210/346/200/273/347/273/223/index.html +4 -4
- package/categories//347/264/240/346/235/220/index.html +4 -4
- package/categories//351/227/262/350/201/212/346/235/202/350/260/210/index.html +4 -4
- package/content.json +1 -1
- package/css/404page.css +1 -65
- package/css/ariasakablog.css +1 -6669
- package/css/commentBarrage.css +1 -118
- package/css/danmaku.css +1 -106
- package/css/essay.css +1 -306
- package/css/iconfont.css +1 -55
- package/css/index.css +1 -7006
- package/css/people.css +1 -18
- package/css/stylessimple.css +1 -40
- package/css/swiperstyle.css +1 -567
- package/fcircle/index.html +3 -3
- package/fontawesome/index.html +3 -3
- package/index.html +11 -11
- package/js/aplayersave.js +1 -268
- package/js/baiduhistory.js +1 -76
- package/js/browser.js +1 -35
- package/js/calendar.js +1 -380
- package/js/cate.js +1 -22
- package/js/commentBarrage.js +17 -232
- package/js/commentsCount.js +1 -43
- package/js/copy.js +1 -23
- package/js/countup.js +1 -209
- package/js/cursor.js +1 -82
- package/js/danmaku.js +0 -106
- package/js/day.js +13 -195
- package/js/dianzan.js +1 -249
- package/js/dis.js +4 -252
- package/js/dist/baiduhistory.dev.js +1 -102
- package/js/dist/bbtalk.dev.js +159 -12872
- package/js/dist/bbtalklunbo.dev.js +1 -45
- package/js/dist/calendar.dev.js +1 -395
- package/js/dist/fixbugpjax.dev.js +1 -8
- package/js/dist/gongnong.dev.js +1 -565
- package/js/dist/heimu.dev.js +1 -19
- package/js/dist/links.dev.js +1 -13
- package/js/dist/main.dev.js +5 -843
- package/js/dist/resizeTop.dev.js +1 -50
- package/js/dist/seo.dev.js +1 -33
- package/js/dist/twikoo.all.min.dev.js +946 -1
- package/js/fixbugpjax.js +1 -7
- package/js/fixed_card_widget.js +1 -46
- package/js/fps.js +1 -58
- package/js/gitalker.js +1 -11
- package/js/heimu.js +1 -16
- package/js/hide.show.js +1 -17
- package/js/languages.js +1 -511
- package/js/latest.js +1 -49
- package/js/local-search.js +2 -476
- package/js/lunar.js +1 -1071
- package/js/lyxTalk.js +1 -12
- package/js/main.js +5 -781
- package/js/nav.js +1 -30
- package/js/noie.js +1 -3
- package/js/owo.js +1 -52
- package/js/people.js +2 -175
- package/js/randomFriend.js +1 -95
- package/js/resizeTop.js +1 -43
- package/js/rightmenu.js +3 -333
- package/js/sakura.js +1 -164
- package/js/search/algolia.js +4 -154
- package/js/search/local-search.js +1 -188
- package/js/settings.js +3 -343
- package/js/sitetime.js +1 -25
- package/js/smooth-scrolling.js +1 -546
- package/js/sw-toolbox.js +1 -16
- package/js/swiperinit.js +1 -23
- package/js/tw_cn.js +1 -100
- package/js/utils.js +1 -278
- package/js/welcome.js +1 -107
- package/js/welcomeconsole.js +1 -23
- package/links/index.html +3 -3
- package/othersite/index.html +3 -3
- package/package.json +1 -1
- package/posts/164ef646/index.html +6 -6
- package/posts/228c2ef8/index.html +6 -6
- package/posts/a9a6c1fb/index.html +6 -6
- package/posts/c262e439/index.html +6 -6
- package/posts/c81531cf/index.html +6 -6
- package/posts/ccdf7cfc/index.html +6 -6
- package/posts/de1f83f4/index.html +6 -6
- package/posts/e54f7476/index.html +6 -6
- package/sitemap.xml +49 -49
- package/sw.js +2 -193
- package/swReg.js +1 -29
- package/tags/AI/index.html +5 -5
- package/tags/Butterfly/index.html +5 -5
- package/tags/Cloudflare/index.html +5 -5
- package/tags/DiffSinger/index.html +5 -5
- package/tags/Hexo/index.html +5 -5
- package/tags/Next/index.html +5 -5
- package/tags/RAID/index.html +5 -5
- package/tags/Vercel/index.html +5 -5
- package/tags/Workers/index.html +5 -5
- package/tags/index.html +3 -3
- package/tags//344/270/273/351/242/230/index.html +5 -5
- package/tags//345/206/231/344/275/234/index.html +5 -5
- package/tags//345/245/263/346/200/247/346/204/217/350/257/206/index.html +5 -5
- package/tags//345/255/246/344/271/240/index.html +5 -5
- package/tags//345/256/266/351/207/214/344/272/221/index.html +5 -5
- package/tags//345/271/264/347/273/210/346/200/273/347/273/223/index.html +5 -5
- package/tags//346/212/230/350/205/276/index.html +5 -5
- package/tags//346/227/245/345/270/270/index.html +5 -5
- package/tags//346/234/215/345/212/241/345/231/250/index.html +5 -5
- package/tags//346/265/252/346/275/256/index.html +5 -5
- package/tags//347/256/200/347/210/261/index.html +5 -5
- package/tags//350/207/252/345/212/250/346/240/207/346/263/250/index.html +5 -5
- package/tags//350/256/272/346/226/207/index.html +5 -5
- package/tags//350/260/267/346/255/214/347/277/273/350/257/221/index.html +5 -5
- package/tags//350/264/237/350/275/275/345/235/207/350/241/241/index.html +5 -5
- package/tags//351/207/221/345/217/245/index.html +5 -5
- package/tags//351/255/224/346/224/271/index.html +5 -5
package/js/dist/main.dev.js
CHANGED
@@ -1,845 +1,7 @@
|
|
1
|
-
"use strict";
|
1
|
+
"use strict";function _typeof(u){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?_typeof=function(b){return typeof b}:_typeof=function(b){return b&&typeof Symbol=="function"&&b.constructor===Symbol&&b!==Symbol.prototype?"symbol":typeof b},_typeof(u)}function _toConsumableArray(u){return _arrayWithoutHoles(u)||_iterableToArray(u)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(u){if(Symbol.iterator in Object(u)||Object.prototype.toString.call(u)==="[object Arguments]")return Array.from(u)}function _arrayWithoutHoles(u){if(Array.isArray(u)){for(var w=0,b=new Array(u.length);w<u.length;w++)b[w]=u[w];return b}}document.addEventListener("DOMContentLoaded",function(){var u,w,b,O,I=!1,k=function(e){if(e){u=document.getElementById("site-name").offsetWidth;var t=document.querySelectorAll("#menus .menus_item");w=0,t.length&&t.forEach(function(a){w+=a.offsetWidth});var n=document.querySelector("#search-button");b=n?n.offsetWidth:0,O=document.getElementById("nav")}var o="";window.innerWidth<768?o=!0:o=u+w+b>O.offsetWidth-120,o?O.classList.add("hide-menu"):O.classList.remove("hide-menu")},_=function(){k(!0),O.classList.add("show")},B={open:function(){btf.sidebarPaddingR(),document.body.style.overflow="hidden",btf.animateIn(document.getElementById("menu-mask"),"to_show 0.5s"),document.getElementById("sidebar-menus").classList.add("open"),I=!0},close:function(){var e=document.body;e.style.overflow="",e.style.paddingRight="",btf.animateOut(document.getElementById("menu-mask"),"to_hide 0.5s"),document.getElementById("sidebar-menus").classList.remove("open"),I=!1}},x=function(){var e=document.getElementById("scroll-down");e&&e.addEventListener("click",function(){btf.scrollToDest(document.getElementById("content-inner").offsetTop,300)})},D=function(){var e=GLOBAL_CONFIG.highlight;if(!e)return;var t=e.highlightCopy,n=e.highlightLang,o=GLOBAL_CONFIG_SITE.isHighlightShrink,a=e.highlightHeightLimit,d=t||n||o!==void 0,v=e.plugin==="highlighjs"?document.querySelectorAll("figure.highlight"):document.querySelectorAll('pre[class*="language-"]');if(!((d||a)&&v.length))return;var E=e.plugin==="prismjs",h="",g="",C=o===!0?"closed":"";o!==void 0&&(h='<i class="fas fa-angle-down expand '.concat(C,'"></i>')),t&&(g='<div class="copy-notice"></div><i class="fas fa-paste copy-button"></i>');var A=function(r,c){if(document.queryCommandSupported&&document.queryCommandSupported("copy"))if(document.execCommand("copy"),GLOBAL_CONFIG.Snackbar!==void 0)btf.snackbarShow(GLOBAL_CONFIG.copy.success);else{var s=c.previousElementSibling;s.innerText=GLOBAL_CONFIG.copy.success,s.style.opacity=1,setTimeout(function(){s.style.opacity=0},700)}else GLOBAL_CONFIG.Snackbar!==void 0?btf.snackbarShow(GLOBAL_CONFIG.copy.noSupport):c.previousElementSibling.innerText=GLOBAL_CONFIG.copy.noSupport},G=function(r){var c=r.parentNode;c.classList.add("copy-true");var s=window.getSelection(),y=document.createRange();E?y.selectNodeContents(c.querySelectorAll("pre code")[0]):y.selectNodeContents(c.querySelectorAll("table .code pre")[0]),s.removeAllRanges(),s.addRange(y);var T=s.toString();A(T,r.lastChild),s.removeAllRanges(),c.classList.remove("copy-true")},m=function(r){var c=_toConsumableArray(r.parentNode.children).slice(1);r.firstChild.classList.toggle("closed"),btf.isHidden(c[c.length-1])?c.forEach(function(s){s.style.display="block"}):c.forEach(function(s){s.style.display="none"})},L=function(r){var c=r.target.classList;c.contains("expand")?m(this):c.contains("copy-button")&&G(this)},p=function(){this.classList.toggle("expand-done")};function f(l,r,c){var s=document.createDocumentFragment();if(d){var y=document.createElement("div");y.className="highlight-tools ".concat(C),y.innerHTML=h+l+g,y.addEventListener("click",L),s.appendChild(y)}if(a&&r.offsetHeight>a+30){var T=document.createElement("div");T.className="code-expand-btn",T.innerHTML='<i class="fas fa-angle-double-down"></i>',T.addEventListener("click",p),s.appendChild(T)}c==="hl"?r.insertBefore(s,r.firstChild):r.parentNode.insertBefore(s,r)}n?E?v.forEach(function(l){var r=l.getAttribute("data-language")?l.getAttribute("data-language"):"Code",c='<div class="code-lang">'.concat(r,"</div>");btf.wrap(l,"figure",{class:"highlight"}),f(c,l)}):v.forEach(function(l){var r=l.getAttribute("class").split(" ")[1];(r==="plain"||r===void 0)&&(r="Code");var c='<div class="code-lang">'.concat(r,"</div>");f(c,l,"hl")}):E?v.forEach(function(l){btf.wrap(l,"figure",{class:"highlight"}),f("",l)}):v.forEach(function(l){f("",l,"hl")})};function H(){document.querySelectorAll("#article-container img").forEach(function(i){var e=i.parentNode,t=i.title||i.alt;if(t&&!e.parentNode.classList.contains("justified-gallery")){var n=document.createElement("div");n.className="img-alt is-center",n.textContent=t,e.insertBefore(n,i.nextSibling)}})}var q=function(){btf.loadLightbox(document.querySelectorAll("#article-container img:not(.no-lightbox)"))},M=function(e){if(e.forEach(function(n){var o=n.querySelectorAll("img");o.forEach(function(a){var d=a.getAttribute("data-lazy-src");d&&(a.src=d),btf.wrap(a,"div",{class:"fj-gallery-item"})})}),window.fjGallery){setTimeout(function(){btf.initJustifiedGallery(e)},100);return}var t=document.createElement("link");t.rel="stylesheet",t.href=GLOBAL_CONFIG.source.justifiedGallery.css,document.body.appendChild(t),getScript("".concat(GLOBAL_CONFIG.source.justifiedGallery.js)).then(function(){btf.initJustifiedGallery(e)})},P=function(){var e=document.getElementById("rightside"),t=window.innerHeight+56;if(document.body.scrollHeight<=t){e.style.cssText="opacity: 1; transform: translateX(-58px)";return}function n(h){var g=h>o;return o=h,g}var o=0,a=!0,d=document.getElementById("page-header"),v=typeof chatBtnHide=="function",E=typeof chatBtnShow=="function";d.classList.add("nav-fixed"),d.classList.add("nav-visible"),window.scrollCollect=function(){return btf.throttle(function(h){var g=window.scrollY||document.documentElement.scrollTop,C=n(g);d.classList.add("nav-fixed"),d.classList.add("nav-visible"),g>0?(C?(d.classList.contains("nav-visible")&&d.classList.add("nav-visible"),E&&a===!0&&(chatBtnHide(),a=!1)):(d.classList.contains("nav-visible")||d.classList.add("nav-visible"),v&&a===!1&&(chatBtnShow(),a=!0)),d.classList.add("nav-fixed"),window.getComputedStyle(e).getPropertyValue("opacity")==="0"&&(e.style.cssText=" transform: translateX(-58px)")):g===0&&d.classList.remove("nav-fixed","nav-visible"),document.body.scrollHeight<=t},200)()},window.addEventListener("scroll",scrollCollect)},$=function(){var e=GLOBAL_CONFIG_SITE.isToc,t=GLOBAL_CONFIG.isAnchor,n=document.getElementById("article-container");if(n&&(e||t)){var o,a,d,v,E;if(e){var h=document.getElementById("card-toc");a=h.getElementsByClassName("toc-content")[0],o=a.querySelectorAll(".toc-link");var g=h.querySelector(".toc-percentage");E=a.classList.contains("is-expand"),d=function(L){var p=n.clientHeight,f=document.documentElement.clientHeight,l=n.offsetTop,r=p>f?p-f:document.documentElement.scrollHeight-f,c=(L-l)/r,s=Math.round(c*100),y=s>100?100:s<=0?0:s;g.textContent=y},window.mobileToc={open:function(){h.style.cssText="animation: toc-open .3s; opacity: 1; right: 55px"},close:function(){h.style.animation="toc-close .2s",setTimeout(function(){h.style.cssText="opacity:''; animation: ''; right: ''"},100)}},a.addEventListener("click",function(m){m.preventDefault();var L=m.target.classList;if(!L.contains("toc-content")){var p=L.contains("toc-link")?m.target:m.target.parentElement;btf.scrollToDest(btf.getEleTop(document.getElementById(decodeURI(p.getAttribute("href")).replace("#",""))),300),window.innerWidth<900&&window.mobileToc.close()}}),v=function(L){var p=L.getBoundingClientRect().top,f=a.scrollTop;p>document.documentElement.clientHeight-100&&(a.scrollTop=f+150),p<100&&(a.scrollTop=f-150)}}var C=n.querySelectorAll("h1,h2,h3,h4,h5,h6"),A="",G=function(L){if(L===0)return!1;var p="",f="";if(C.forEach(function(c,s){if(L>btf.getEleTop(c)-80){var y=c.id;p=y?"#"+encodeURI(y):"",f=s}}),A!==f&&(t&&btf.updateAnchor(p),A=f,e)){if(a.querySelectorAll(".active").forEach(function(c){c.classList.remove("active")}),p==="")return;var l=o[f];if(l.classList.add("active"),setTimeout(function(){v(l)},0),E)return;for(var r=l.parentNode;!r.matches(".toc");r=r.parentNode)r.matches("li")&&r.classList.add("active")}};window.tocScrollFn=function(){return btf.throttle(function(){var m=window.scrollY||document.documentElement.scrollTop;e&&d(m),G(m)},100)()},window.addEventListener("scroll",tocScrollFn)}},S={switchReadMode:function(){var e=document.body;e.classList.add("read-mode");var t=document.createElement("button");t.type="button",t.className="fas fa-sign-out-alt exit-readmode",e.appendChild(t);function n(){e.classList.remove("read-mode"),t.remove(),t.removeEventListener("click",n)}t.addEventListener("click",n)},switchDarkMode:function(){var e=document.documentElement.getAttribute("data-theme")==="dark"?"dark":"light";e==="light"?(activateDarkMode(),saveToLocal.set("theme","dark",2),GLOBAL_CONFIG.Snackbar!==void 0&&btf.snackbarShow(GLOBAL_CONFIG.Snackbar.day_to_night)):(activateLightMode(),saveToLocal.set("theme","light",2),GLOBAL_CONFIG.Snackbar!==void 0&&btf.snackbarShow(GLOBAL_CONFIG.Snackbar.night_to_day)),typeof utterancesTheme=="function"&&utterancesTheme(),typeof changeGiscusTheme=="function"&&changeGiscusTheme(),(typeof FB>"u"?"undefined":_typeof(FB))==="object"&&window.loadFBComment(),window.DISQUS&&document.getElementById("disqus_thread").children.length&&setTimeout(function(){return window.disqusReset()},200),typeof runMermaid=="function"&&window.runMermaid()},showOrHideBtn:function(e){var t=document.getElementById("rightside-config-hide").classList;t.toggle("show"),e.classList.contains("show")&&(t.add("status"),setTimeout(function(){t.remove("status")},300)),e.classList.toggle("show")},scrollToTop:function(){btf.scrollToDest(0,500)},hideAsideBtn:function(){var e=document.documentElement.classList;e.contains("hide-aside")?saveToLocal.set("aside-status","show",2):saveToLocal.set("aside-status","hide",2),e.toggle("hide-aside")},runMobileToc:function(){window.getComputedStyle(document.getElementById("card-toc")).getPropertyValue("opacity")==="0"?window.mobileToc.open():window.mobileToc.close()}};document.getElementById("rightside").addEventListener("click",function(i){var e=i.target.id?i.target:i.target.parentNode;switch(e.id){case"go-up":S.scrollToTop();break;case"rightside_config":S.showOrHideBtn(e);break;case"mobile-toc-button":S.runMobileToc();break;case"readmode":S.switchReadMode();break;case"darkmode":S.switchDarkMode();break;case"hide-aside-btn":S.hideAsideBtn();break;default:break}});var j=function(){document.querySelectorAll("#sidebar-menus .site-page.group").forEach(function(e){e.addEventListener("click",function(){this.classList.toggle("hide")})})},R=function(){var e=GLOBAL_CONFIG.copyright;document.body.oncopy=function(t){t.preventDefault();var n,o=window.getSelection(0).toString();return o.length>e.limitCount?n=o+`
|
2
2
|
|
3
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
|
10
|
-
|
11
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
|
12
|
-
|
13
|
-
document.addEventListener('DOMContentLoaded', function () {
|
14
|
-
var blogNameWidth, menusWidth, searchWidth, $nav;
|
15
|
-
var mobileSidebarOpen = false;
|
16
|
-
|
17
|
-
var adjustMenu = function adjustMenu(init) {
|
18
|
-
if (init) {
|
19
|
-
blogNameWidth = document.getElementById('site-name').offsetWidth;
|
20
|
-
var $menusEle = document.querySelectorAll('#menus .menus_item');
|
21
|
-
menusWidth = 0;
|
22
|
-
$menusEle.length && $menusEle.forEach(function (i) {
|
23
|
-
menusWidth += i.offsetWidth;
|
24
|
-
});
|
25
|
-
var $searchEle = document.querySelector('#search-button');
|
26
|
-
searchWidth = $searchEle ? $searchEle.offsetWidth : 0;
|
27
|
-
$nav = document.getElementById('nav');
|
28
|
-
}
|
29
|
-
|
30
|
-
var hideMenuIndex = '';
|
31
|
-
if (window.innerWidth < 768) hideMenuIndex = true;else hideMenuIndex = blogNameWidth + menusWidth + searchWidth > $nav.offsetWidth - 120;
|
32
|
-
|
33
|
-
if (hideMenuIndex) {
|
34
|
-
$nav.classList.add('hide-menu');
|
35
|
-
} else {
|
36
|
-
$nav.classList.remove('hide-menu');
|
37
|
-
}
|
38
|
-
}; // 初始化header
|
39
|
-
|
40
|
-
|
41
|
-
var initAdjust = function initAdjust() {
|
42
|
-
adjustMenu(true);
|
43
|
-
$nav.classList.add('show');
|
44
|
-
}; // sidebar menus
|
45
|
-
|
46
|
-
|
47
|
-
var sidebarFn = {
|
48
|
-
open: function open() {
|
49
|
-
btf.sidebarPaddingR();
|
50
|
-
document.body.style.overflow = 'hidden';
|
51
|
-
btf.animateIn(document.getElementById('menu-mask'), 'to_show 0.5s');
|
52
|
-
document.getElementById('sidebar-menus').classList.add('open');
|
53
|
-
mobileSidebarOpen = true;
|
54
|
-
},
|
55
|
-
close: function close() {
|
56
|
-
var $body = document.body;
|
57
|
-
$body.style.overflow = '';
|
58
|
-
$body.style.paddingRight = '';
|
59
|
-
btf.animateOut(document.getElementById('menu-mask'), 'to_hide 0.5s');
|
60
|
-
document.getElementById('sidebar-menus').classList.remove('open');
|
61
|
-
mobileSidebarOpen = false;
|
62
|
-
}
|
63
|
-
};
|
64
|
-
/**
|
65
|
-
* 首頁top_img底下的箭頭
|
66
|
-
*/
|
67
|
-
|
68
|
-
var scrollDownInIndex = function scrollDownInIndex() {
|
69
|
-
var $scrollDownEle = document.getElementById('scroll-down');
|
70
|
-
$scrollDownEle && $scrollDownEle.addEventListener('click', function () {
|
71
|
-
btf.scrollToDest(document.getElementById('content-inner').offsetTop, 300);
|
72
|
-
});
|
73
|
-
};
|
74
|
-
/**
|
75
|
-
* 代碼
|
76
|
-
* 只適用於Hexo默認的代碼渲染
|
77
|
-
*/
|
78
|
-
|
79
|
-
|
80
|
-
var addHighlightTool = function addHighlightTool() {
|
81
|
-
var highLight = GLOBAL_CONFIG.highlight;
|
82
|
-
if (!highLight) return;
|
83
|
-
var isHighlightCopy = highLight.highlightCopy;
|
84
|
-
var isHighlightLang = highLight.highlightLang;
|
85
|
-
var isHighlightShrink = GLOBAL_CONFIG_SITE.isHighlightShrink;
|
86
|
-
var highlightHeightLimit = highLight.highlightHeightLimit;
|
87
|
-
var isShowTool = isHighlightCopy || isHighlightLang || isHighlightShrink !== undefined;
|
88
|
-
var $figureHighlight = highLight.plugin === 'highlighjs' ? document.querySelectorAll('figure.highlight') : document.querySelectorAll('pre[class*="language-"]');
|
89
|
-
if (!((isShowTool || highlightHeightLimit) && $figureHighlight.length)) return;
|
90
|
-
var isPrismjs = highLight.plugin === 'prismjs';
|
91
|
-
var highlightShrinkEle = '';
|
92
|
-
var highlightCopyEle = '';
|
93
|
-
var highlightShrinkClass = isHighlightShrink === true ? 'closed' : '';
|
94
|
-
|
95
|
-
if (isHighlightShrink !== undefined) {
|
96
|
-
highlightShrinkEle = "<i class=\"fas fa-angle-down expand ".concat(highlightShrinkClass, "\"></i>");
|
97
|
-
}
|
98
|
-
|
99
|
-
if (isHighlightCopy) {
|
100
|
-
highlightCopyEle = '<div class="copy-notice"></div><i class="fas fa-paste copy-button"></i>';
|
101
|
-
}
|
102
|
-
|
103
|
-
var copy = function copy(text, ctx) {
|
104
|
-
if (document.queryCommandSupported && document.queryCommandSupported('copy')) {
|
105
|
-
document.execCommand('copy');
|
106
|
-
|
107
|
-
if (GLOBAL_CONFIG.Snackbar !== undefined) {
|
108
|
-
btf.snackbarShow(GLOBAL_CONFIG.copy.success);
|
109
|
-
} else {
|
110
|
-
var prevEle = ctx.previousElementSibling;
|
111
|
-
prevEle.innerText = GLOBAL_CONFIG.copy.success;
|
112
|
-
prevEle.style.opacity = 1;
|
113
|
-
setTimeout(function () {
|
114
|
-
prevEle.style.opacity = 0;
|
115
|
-
}, 700);
|
116
|
-
}
|
117
|
-
} else {
|
118
|
-
if (GLOBAL_CONFIG.Snackbar !== undefined) {
|
119
|
-
btf.snackbarShow(GLOBAL_CONFIG.copy.noSupport);
|
120
|
-
} else {
|
121
|
-
ctx.previousElementSibling.innerText = GLOBAL_CONFIG.copy.noSupport;
|
122
|
-
}
|
123
|
-
}
|
124
|
-
}; // click events
|
125
|
-
|
126
|
-
|
127
|
-
var highlightCopyFn = function highlightCopyFn(ele) {
|
128
|
-
var $buttonParent = ele.parentNode;
|
129
|
-
$buttonParent.classList.add('copy-true');
|
130
|
-
var selection = window.getSelection();
|
131
|
-
var range = document.createRange();
|
132
|
-
if (isPrismjs) range.selectNodeContents($buttonParent.querySelectorAll('pre code')[0]);else range.selectNodeContents($buttonParent.querySelectorAll('table .code pre')[0]);
|
133
|
-
selection.removeAllRanges();
|
134
|
-
selection.addRange(range);
|
135
|
-
var text = selection.toString();
|
136
|
-
copy(text, ele.lastChild);
|
137
|
-
selection.removeAllRanges();
|
138
|
-
$buttonParent.classList.remove('copy-true');
|
139
|
-
};
|
140
|
-
|
141
|
-
var highlightShrinkFn = function highlightShrinkFn(ele) {
|
142
|
-
var $nextEle = _toConsumableArray(ele.parentNode.children).slice(1);
|
143
|
-
|
144
|
-
ele.firstChild.classList.toggle('closed');
|
145
|
-
|
146
|
-
if (btf.isHidden($nextEle[$nextEle.length - 1])) {
|
147
|
-
$nextEle.forEach(function (e) {
|
148
|
-
e.style.display = 'block';
|
149
|
-
});
|
150
|
-
} else {
|
151
|
-
$nextEle.forEach(function (e) {
|
152
|
-
e.style.display = 'none';
|
153
|
-
});
|
154
|
-
}
|
155
|
-
};
|
156
|
-
|
157
|
-
var highlightToolsFn = function highlightToolsFn(e) {
|
158
|
-
var $target = e.target.classList;
|
159
|
-
if ($target.contains('expand')) highlightShrinkFn(this);else if ($target.contains('copy-button')) highlightCopyFn(this);
|
160
|
-
};
|
161
|
-
|
162
|
-
var expandCode = function expandCode() {
|
163
|
-
this.classList.toggle('expand-done');
|
164
|
-
};
|
165
|
-
|
166
|
-
function createEle(lang, item, service) {
|
167
|
-
var fragment = document.createDocumentFragment();
|
168
|
-
|
169
|
-
if (isShowTool) {
|
170
|
-
var hlTools = document.createElement('div');
|
171
|
-
hlTools.className = "highlight-tools ".concat(highlightShrinkClass);
|
172
|
-
hlTools.innerHTML = highlightShrinkEle + lang + highlightCopyEle;
|
173
|
-
hlTools.addEventListener('click', highlightToolsFn);
|
174
|
-
fragment.appendChild(hlTools);
|
175
|
-
}
|
176
|
-
|
177
|
-
if (highlightHeightLimit && item.offsetHeight > highlightHeightLimit + 30) {
|
178
|
-
var ele = document.createElement('div');
|
179
|
-
ele.className = 'code-expand-btn';
|
180
|
-
ele.innerHTML = '<i class="fas fa-angle-double-down"></i>';
|
181
|
-
ele.addEventListener('click', expandCode);
|
182
|
-
fragment.appendChild(ele);
|
183
|
-
}
|
184
|
-
|
185
|
-
if (service === 'hl') {
|
186
|
-
item.insertBefore(fragment, item.firstChild);
|
187
|
-
} else {
|
188
|
-
item.parentNode.insertBefore(fragment, item);
|
189
|
-
}
|
190
|
-
}
|
191
|
-
|
192
|
-
if (isHighlightLang) {
|
193
|
-
if (isPrismjs) {
|
194
|
-
$figureHighlight.forEach(function (item) {
|
195
|
-
var langName = item.getAttribute('data-language') ? item.getAttribute('data-language') : 'Code';
|
196
|
-
var highlightLangEle = "<div class=\"code-lang\">".concat(langName, "</div>");
|
197
|
-
btf.wrap(item, 'figure', {
|
198
|
-
"class": 'highlight'
|
199
|
-
});
|
200
|
-
createEle(highlightLangEle, item);
|
201
|
-
});
|
202
|
-
} else {
|
203
|
-
$figureHighlight.forEach(function (item) {
|
204
|
-
var langName = item.getAttribute('class').split(' ')[1];
|
205
|
-
if (langName === 'plain' || langName === undefined) langName = 'Code';
|
206
|
-
var highlightLangEle = "<div class=\"code-lang\">".concat(langName, "</div>");
|
207
|
-
createEle(highlightLangEle, item, 'hl');
|
208
|
-
});
|
209
|
-
}
|
210
|
-
} else {
|
211
|
-
if (isPrismjs) {
|
212
|
-
$figureHighlight.forEach(function (item) {
|
213
|
-
btf.wrap(item, 'figure', {
|
214
|
-
"class": 'highlight'
|
215
|
-
});
|
216
|
-
createEle('', item);
|
217
|
-
});
|
218
|
-
} else {
|
219
|
-
$figureHighlight.forEach(function (item) {
|
220
|
-
createEle('', item, 'hl');
|
221
|
-
});
|
222
|
-
}
|
223
|
-
}
|
224
|
-
};
|
225
|
-
/**
|
226
|
-
* PhotoFigcaption
|
227
|
-
*/
|
228
|
-
|
229
|
-
|
230
|
-
function addPhotoFigcaption() {
|
231
|
-
document.querySelectorAll('#article-container img').forEach(function (item) {
|
232
|
-
var parentEle = item.parentNode;
|
233
|
-
var altValue = item.title || item.alt;
|
234
|
-
|
235
|
-
if (altValue && !parentEle.parentNode.classList.contains('justified-gallery')) {
|
236
|
-
var ele = document.createElement('div');
|
237
|
-
ele.className = 'img-alt is-center';
|
238
|
-
ele.textContent = altValue;
|
239
|
-
parentEle.insertBefore(ele, item.nextSibling);
|
240
|
-
}
|
241
|
-
});
|
242
|
-
}
|
243
|
-
/**
|
244
|
-
* Lightbox
|
245
|
-
*/
|
246
|
-
|
247
|
-
|
248
|
-
var runLightbox = function runLightbox() {
|
249
|
-
btf.loadLightbox(document.querySelectorAll('#article-container img:not(.no-lightbox)'));
|
250
|
-
};
|
251
|
-
/**
|
252
|
-
* justified-gallery 圖庫排版
|
253
|
-
*/
|
254
|
-
|
255
|
-
|
256
|
-
var runJustifiedGallery = function runJustifiedGallery(ele) {
|
257
|
-
ele.forEach(function (item) {
|
258
|
-
var $imgList = item.querySelectorAll('img');
|
259
|
-
$imgList.forEach(function (i) {
|
260
|
-
var dataLazySrc = i.getAttribute('data-lazy-src');
|
261
|
-
if (dataLazySrc) i.src = dataLazySrc;
|
262
|
-
btf.wrap(i, 'div', {
|
263
|
-
"class": 'fj-gallery-item'
|
264
|
-
});
|
265
|
-
});
|
266
|
-
});
|
267
|
-
|
268
|
-
if (window.fjGallery) {
|
269
|
-
setTimeout(function () {
|
270
|
-
btf.initJustifiedGallery(ele);
|
271
|
-
}, 100);
|
272
|
-
return;
|
273
|
-
}
|
274
|
-
|
275
|
-
var newEle = document.createElement('link');
|
276
|
-
newEle.rel = 'stylesheet';
|
277
|
-
newEle.href = GLOBAL_CONFIG.source.justifiedGallery.css;
|
278
|
-
document.body.appendChild(newEle);
|
279
|
-
getScript("".concat(GLOBAL_CONFIG.source.justifiedGallery.js)).then(function () {
|
280
|
-
btf.initJustifiedGallery(ele);
|
281
|
-
});
|
282
|
-
};
|
283
|
-
/**
|
284
|
-
* 滾動處理
|
285
|
-
*/
|
286
|
-
|
287
|
-
|
288
|
-
var scrollFn = function scrollFn() {
|
289
|
-
var $rightside = document.getElementById('rightside');
|
290
|
-
var innerHeight = window.innerHeight + 56; // 當滾動條小于 56 的時候
|
291
|
-
|
292
|
-
if (document.body.scrollHeight <= innerHeight) {
|
293
|
-
$rightside.style.cssText = 'opacity: 1; transform: translateX(-58px)';
|
294
|
-
return;
|
295
|
-
} // find the scroll direction
|
296
|
-
|
297
|
-
|
298
|
-
function scrollDirection(currentTop) {
|
299
|
-
var result = currentTop > initTop; // true is down & false is up
|
300
|
-
|
301
|
-
initTop = currentTop;
|
302
|
-
return result;
|
303
|
-
}
|
304
|
-
|
305
|
-
var initTop = 0;
|
306
|
-
var isChatShow = true;
|
307
|
-
var $header = document.getElementById('page-header');
|
308
|
-
var isChatBtnHide = typeof chatBtnHide === 'function';
|
309
|
-
var isChatBtnShow = typeof chatBtnShow === 'function';
|
310
|
-
$header.classList.add('nav-fixed');
|
311
|
-
$header.classList.add('nav-visible');
|
312
|
-
|
313
|
-
window.scrollCollect = function () {
|
314
|
-
return btf.throttle(function (e) {
|
315
|
-
var currentTop = window.scrollY || document.documentElement.scrollTop;
|
316
|
-
var isDown = scrollDirection(currentTop);
|
317
|
-
$header.classList.add('nav-fixed');
|
318
|
-
$header.classList.add('nav-visible');
|
319
|
-
|
320
|
-
if (currentTop > 0) {
|
321
|
-
if (isDown) {
|
322
|
-
if ($header.classList.contains('nav-visible')) $header.classList.add('nav-visible');
|
323
|
-
|
324
|
-
if (isChatBtnShow && isChatShow === true) {
|
325
|
-
chatBtnHide();
|
326
|
-
isChatShow = false;
|
327
|
-
}
|
328
|
-
} else {
|
329
|
-
if (!$header.classList.contains('nav-visible')) $header.classList.add('nav-visible');
|
330
|
-
|
331
|
-
if (isChatBtnHide && isChatShow === false) {
|
332
|
-
chatBtnShow();
|
333
|
-
isChatShow = true;
|
334
|
-
}
|
335
|
-
}
|
336
|
-
|
337
|
-
$header.classList.add('nav-fixed');
|
338
|
-
|
339
|
-
if (window.getComputedStyle($rightside).getPropertyValue('opacity') === '0') {
|
340
|
-
$rightside.style.cssText = ' transform: translateX(-58px)';
|
341
|
-
}
|
342
|
-
} else {
|
343
|
-
if (currentTop === 0) {
|
344
|
-
$header.classList.remove('nav-fixed', 'nav-visible');
|
345
|
-
} // $rightside.style.cssText = "opacity: ''; transform: ''"
|
346
|
-
|
347
|
-
}
|
348
|
-
|
349
|
-
if (document.body.scrollHeight <= innerHeight) {//$rightside.style.cssText = 'opacity: 0.8; transform: translateX(-58px)'
|
350
|
-
}
|
351
|
-
}, 200)();
|
352
|
-
};
|
353
|
-
|
354
|
-
window.addEventListener('scroll', scrollCollect);
|
355
|
-
};
|
356
|
-
/**
|
357
|
-
* toc,anchor
|
358
|
-
*/
|
359
|
-
|
360
|
-
|
361
|
-
var scrollFnToDo = function scrollFnToDo() {
|
362
|
-
var isToc = GLOBAL_CONFIG_SITE.isToc;
|
363
|
-
var isAnchor = GLOBAL_CONFIG.isAnchor;
|
364
|
-
var $article = document.getElementById('article-container');
|
365
|
-
if (!($article && (isToc || isAnchor))) return;
|
366
|
-
var $tocLink, $cardToc, scrollPercent, autoScrollToc, isExpand;
|
367
|
-
|
368
|
-
if (isToc) {
|
369
|
-
var $cardTocLayout = document.getElementById('card-toc');
|
370
|
-
$cardToc = $cardTocLayout.getElementsByClassName('toc-content')[0];
|
371
|
-
$tocLink = $cardToc.querySelectorAll('.toc-link');
|
372
|
-
var $tocPercentage = $cardTocLayout.querySelector('.toc-percentage');
|
373
|
-
isExpand = $cardToc.classList.contains('is-expand');
|
374
|
-
|
375
|
-
scrollPercent = function scrollPercent(currentTop) {
|
376
|
-
var docHeight = $article.clientHeight;
|
377
|
-
var winHeight = document.documentElement.clientHeight;
|
378
|
-
var headerHeight = $article.offsetTop;
|
379
|
-
var contentMath = docHeight > winHeight ? docHeight - winHeight : document.documentElement.scrollHeight - winHeight;
|
380
|
-
var scrollPercent = (currentTop - headerHeight) / contentMath;
|
381
|
-
var scrollPercentRounded = Math.round(scrollPercent * 100);
|
382
|
-
var percentage = scrollPercentRounded > 100 ? 100 : scrollPercentRounded <= 0 ? 0 : scrollPercentRounded;
|
383
|
-
$tocPercentage.textContent = percentage;
|
384
|
-
};
|
385
|
-
|
386
|
-
window.mobileToc = {
|
387
|
-
open: function open() {
|
388
|
-
$cardTocLayout.style.cssText = 'animation: toc-open .3s; opacity: 1; right: 55px';
|
389
|
-
},
|
390
|
-
close: function close() {
|
391
|
-
$cardTocLayout.style.animation = 'toc-close .2s';
|
392
|
-
setTimeout(function () {
|
393
|
-
$cardTocLayout.style.cssText = "opacity:''; animation: ''; right: ''";
|
394
|
-
}, 100);
|
395
|
-
}
|
396
|
-
}; // toc元素點擊
|
397
|
-
|
398
|
-
$cardToc.addEventListener('click', function (e) {
|
399
|
-
e.preventDefault();
|
400
|
-
var target = e.target.classList;
|
401
|
-
if (target.contains('toc-content')) return;
|
402
|
-
var $target = target.contains('toc-link') ? e.target : e.target.parentElement;
|
403
|
-
btf.scrollToDest(btf.getEleTop(document.getElementById(decodeURI($target.getAttribute('href')).replace('#', ''))), 300);
|
404
|
-
|
405
|
-
if (window.innerWidth < 900) {
|
406
|
-
window.mobileToc.close();
|
407
|
-
}
|
408
|
-
});
|
409
|
-
|
410
|
-
autoScrollToc = function autoScrollToc(item) {
|
411
|
-
var activePosition = item.getBoundingClientRect().top;
|
412
|
-
var sidebarScrollTop = $cardToc.scrollTop;
|
413
|
-
|
414
|
-
if (activePosition > document.documentElement.clientHeight - 100) {
|
415
|
-
$cardToc.scrollTop = sidebarScrollTop + 150;
|
416
|
-
}
|
417
|
-
|
418
|
-
if (activePosition < 100) {
|
419
|
-
$cardToc.scrollTop = sidebarScrollTop - 150;
|
420
|
-
}
|
421
|
-
};
|
422
|
-
} // find head position & add active class
|
423
|
-
|
424
|
-
|
425
|
-
var list = $article.querySelectorAll('h1,h2,h3,h4,h5,h6');
|
426
|
-
var detectItem = '';
|
427
|
-
|
428
|
-
var findHeadPosition = function findHeadPosition(top) {
|
429
|
-
if (top === 0) {
|
430
|
-
return false;
|
431
|
-
}
|
432
|
-
|
433
|
-
var currentId = '';
|
434
|
-
var currentIndex = '';
|
435
|
-
list.forEach(function (ele, index) {
|
436
|
-
if (top > btf.getEleTop(ele) - 80) {
|
437
|
-
var id = ele.id;
|
438
|
-
currentId = id ? '#' + encodeURI(id) : '';
|
439
|
-
currentIndex = index;
|
440
|
-
}
|
441
|
-
});
|
442
|
-
if (detectItem === currentIndex) return;
|
443
|
-
if (isAnchor) btf.updateAnchor(currentId);
|
444
|
-
detectItem = currentIndex;
|
445
|
-
|
446
|
-
if (isToc) {
|
447
|
-
$cardToc.querySelectorAll('.active').forEach(function (i) {
|
448
|
-
i.classList.remove('active');
|
449
|
-
});
|
450
|
-
|
451
|
-
if (currentId === '') {
|
452
|
-
return;
|
453
|
-
}
|
454
|
-
|
455
|
-
var currentActive = $tocLink[currentIndex];
|
456
|
-
currentActive.classList.add('active');
|
457
|
-
setTimeout(function () {
|
458
|
-
autoScrollToc(currentActive);
|
459
|
-
}, 0);
|
460
|
-
if (isExpand) return;
|
461
|
-
var parent = currentActive.parentNode;
|
462
|
-
|
463
|
-
for (; !parent.matches('.toc'); parent = parent.parentNode) {
|
464
|
-
if (parent.matches('li')) parent.classList.add('active');
|
465
|
-
}
|
466
|
-
}
|
467
|
-
}; // main of scroll
|
468
|
-
|
469
|
-
|
470
|
-
window.tocScrollFn = function () {
|
471
|
-
return btf.throttle(function () {
|
472
|
-
var currentTop = window.scrollY || document.documentElement.scrollTop;
|
473
|
-
isToc && scrollPercent(currentTop);
|
474
|
-
findHeadPosition(currentTop);
|
475
|
-
}, 100)();
|
476
|
-
};
|
477
|
-
|
478
|
-
window.addEventListener('scroll', tocScrollFn);
|
479
|
-
};
|
480
|
-
/**
|
481
|
-
* Rightside
|
482
|
-
*/
|
483
|
-
|
484
|
-
|
485
|
-
var rightSideFn = {
|
486
|
-
switchReadMode: function switchReadMode() {
|
487
|
-
// read-mode
|
488
|
-
var $body = document.body;
|
489
|
-
$body.classList.add('read-mode');
|
490
|
-
var newEle = document.createElement('button');
|
491
|
-
newEle.type = 'button';
|
492
|
-
newEle.className = 'fas fa-sign-out-alt exit-readmode';
|
493
|
-
$body.appendChild(newEle);
|
494
|
-
|
495
|
-
function clickFn() {
|
496
|
-
$body.classList.remove('read-mode');
|
497
|
-
newEle.remove();
|
498
|
-
newEle.removeEventListener('click', clickFn);
|
499
|
-
}
|
500
|
-
|
501
|
-
newEle.addEventListener('click', clickFn);
|
502
|
-
},
|
503
|
-
switchDarkMode: function switchDarkMode() {
|
504
|
-
// Switch Between Light And Dark Mode
|
505
|
-
var nowMode = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light';
|
506
|
-
|
507
|
-
if (nowMode === 'light') {
|
508
|
-
activateDarkMode();
|
509
|
-
saveToLocal.set('theme', 'dark', 2);
|
510
|
-
GLOBAL_CONFIG.Snackbar !== undefined && btf.snackbarShow(GLOBAL_CONFIG.Snackbar.day_to_night);
|
511
|
-
} else {
|
512
|
-
activateLightMode();
|
513
|
-
saveToLocal.set('theme', 'light', 2);
|
514
|
-
GLOBAL_CONFIG.Snackbar !== undefined && btf.snackbarShow(GLOBAL_CONFIG.Snackbar.night_to_day);
|
515
|
-
} // handle some cases
|
516
|
-
|
517
|
-
|
518
|
-
typeof utterancesTheme === 'function' && utterancesTheme();
|
519
|
-
typeof changeGiscusTheme === 'function' && changeGiscusTheme();
|
520
|
-
(typeof FB === "undefined" ? "undefined" : _typeof(FB)) === 'object' && window.loadFBComment();
|
521
|
-
window.DISQUS && document.getElementById('disqus_thread').children.length && setTimeout(function () {
|
522
|
-
return window.disqusReset();
|
523
|
-
}, 200);
|
524
|
-
typeof runMermaid === 'function' && window.runMermaid();
|
525
|
-
},
|
526
|
-
showOrHideBtn: function showOrHideBtn(e) {
|
527
|
-
// rightside 點擊設置 按鈕 展開
|
528
|
-
var rightsideHideClassList = document.getElementById('rightside-config-hide').classList;
|
529
|
-
rightsideHideClassList.toggle('show');
|
530
|
-
|
531
|
-
if (e.classList.contains('show')) {
|
532
|
-
rightsideHideClassList.add('status');
|
533
|
-
setTimeout(function () {
|
534
|
-
rightsideHideClassList.remove('status');
|
535
|
-
}, 300);
|
536
|
-
}
|
537
|
-
|
538
|
-
e.classList.toggle('show');
|
539
|
-
},
|
540
|
-
scrollToTop: function scrollToTop() {
|
541
|
-
// Back to top
|
542
|
-
btf.scrollToDest(0, 500);
|
543
|
-
},
|
544
|
-
hideAsideBtn: function hideAsideBtn() {
|
545
|
-
// Hide aside
|
546
|
-
var $htmlDom = document.documentElement.classList;
|
547
|
-
$htmlDom.contains('hide-aside') ? saveToLocal.set('aside-status', 'show', 2) : saveToLocal.set('aside-status', 'hide', 2);
|
548
|
-
$htmlDom.toggle('hide-aside');
|
549
|
-
},
|
550
|
-
runMobileToc: function runMobileToc() {
|
551
|
-
if (window.getComputedStyle(document.getElementById('card-toc')).getPropertyValue('opacity') === '0') window.mobileToc.open();else window.mobileToc.close();
|
552
|
-
}
|
553
|
-
};
|
554
|
-
document.getElementById('rightside').addEventListener('click', function (e) {
|
555
|
-
var $target = e.target.id ? e.target : e.target.parentNode;
|
556
|
-
|
557
|
-
switch ($target.id) {
|
558
|
-
case 'go-up':
|
559
|
-
rightSideFn.scrollToTop();
|
560
|
-
break;
|
561
|
-
|
562
|
-
case 'rightside_config':
|
563
|
-
rightSideFn.showOrHideBtn($target);
|
564
|
-
break;
|
565
|
-
|
566
|
-
case 'mobile-toc-button':
|
567
|
-
rightSideFn.runMobileToc();
|
568
|
-
break;
|
569
|
-
|
570
|
-
case 'readmode':
|
571
|
-
rightSideFn.switchReadMode();
|
572
|
-
break;
|
573
|
-
|
574
|
-
case 'darkmode':
|
575
|
-
rightSideFn.switchDarkMode();
|
576
|
-
break;
|
577
|
-
|
578
|
-
case 'hide-aside-btn':
|
579
|
-
rightSideFn.hideAsideBtn();
|
580
|
-
break;
|
581
|
-
|
582
|
-
default:
|
583
|
-
break;
|
584
|
-
}
|
585
|
-
});
|
586
|
-
/**
|
587
|
-
* menu
|
588
|
-
* 側邊欄sub-menu 展開/收縮
|
589
|
-
*/
|
590
|
-
|
591
|
-
var clickFnOfSubMenu = function clickFnOfSubMenu() {
|
592
|
-
document.querySelectorAll('#sidebar-menus .site-page.group').forEach(function (item) {
|
593
|
-
item.addEventListener('click', function () {
|
594
|
-
this.classList.toggle('hide');
|
595
|
-
});
|
596
|
-
});
|
597
|
-
};
|
598
|
-
/**
|
599
|
-
* 複製時加上版權信息
|
600
|
-
*/
|
601
|
-
|
602
|
-
|
603
|
-
var addCopyright = function addCopyright() {
|
604
|
-
var copyright = GLOBAL_CONFIG.copyright;
|
605
|
-
|
606
|
-
document.body.oncopy = function (e) {
|
607
|
-
e.preventDefault();
|
608
|
-
var textFont;
|
609
|
-
var copyFont = window.getSelection(0).toString();
|
610
|
-
|
611
|
-
if (copyFont.length > copyright.limitCount) {
|
612
|
-
textFont = copyFont + '\n' + '\n' + '\n' + copyright.languages.author + '\n' + copyright.languages.link + window.location.href + '\n' + copyright.languages.source + '\n' + copyright.languages.info;
|
613
|
-
} else {
|
614
|
-
textFont = copyFont;
|
615
|
-
}
|
616
|
-
|
617
|
-
if (e.clipboardData) {
|
618
|
-
return e.clipboardData.setData('text', textFont);
|
619
|
-
} else {
|
620
|
-
return window.clipboardData.setData('text', textFont);
|
621
|
-
}
|
622
|
-
};
|
623
|
-
};
|
624
|
-
/**
|
625
|
-
* 網頁運行時間
|
626
|
-
*/
|
627
|
-
|
628
|
-
|
629
|
-
var addRuntime = function addRuntime() {
|
630
|
-
var $runtimeCount = document.getElementById('runtimeshow');
|
631
|
-
|
632
|
-
if ($runtimeCount) {
|
633
|
-
var publishDate = $runtimeCount.getAttribute('data-publishDate');
|
634
|
-
$runtimeCount.innerText = btf.diffDate(publishDate) + ' ' + GLOBAL_CONFIG.runtime;
|
635
|
-
}
|
636
|
-
};
|
637
|
-
/**
|
638
|
-
* 最後一次更新時間
|
639
|
-
*/
|
640
|
-
|
641
|
-
|
642
|
-
var addLastPushDate = function addLastPushDate() {
|
643
|
-
var $lastPushDateItem = document.getElementById('last-push-date');
|
644
|
-
|
645
|
-
if ($lastPushDateItem) {
|
646
|
-
var lastPushDate = $lastPushDateItem.getAttribute('data-lastPushDate');
|
647
|
-
$lastPushDateItem.innerText = btf.diffDate(lastPushDate, true);
|
648
|
-
}
|
649
|
-
};
|
650
|
-
/**
|
651
|
-
* table overflow
|
652
|
-
*/
|
653
|
-
|
654
|
-
|
655
|
-
var addTableWrap = function addTableWrap() {
|
656
|
-
var $table = document.querySelectorAll('#article-container :not(.highlight) > table, #article-container > table');
|
657
|
-
|
658
|
-
if ($table.length) {
|
659
|
-
$table.forEach(function (item) {
|
660
|
-
btf.wrap(item, 'div', {
|
661
|
-
"class": 'table-wrap'
|
662
|
-
});
|
663
|
-
});
|
664
|
-
}
|
665
|
-
};
|
666
|
-
/**
|
667
|
-
* tag-hide
|
668
|
-
*/
|
669
|
-
|
670
|
-
|
671
|
-
var clickFnOfTagHide = function clickFnOfTagHide() {
|
672
|
-
var $hideInline = document.querySelectorAll('#article-container .hide-button');
|
673
|
-
|
674
|
-
if ($hideInline.length) {
|
675
|
-
$hideInline.forEach(function (item) {
|
676
|
-
item.addEventListener('click', function (e) {
|
677
|
-
var $this = this;
|
678
|
-
$this.classList.add('open');
|
679
|
-
var $fjGallery = $this.nextElementSibling.querySelectorAll('.fj-gallery');
|
680
|
-
$fjGallery.length && btf.initJustifiedGallery($fjGallery);
|
681
|
-
});
|
682
|
-
});
|
683
|
-
}
|
684
|
-
};
|
685
|
-
|
686
|
-
var tabsFn = {
|
687
|
-
clickFnOfTabs: function clickFnOfTabs() {
|
688
|
-
document.querySelectorAll('#article-container .tab > button').forEach(function (item) {
|
689
|
-
item.addEventListener('click', function (e) {
|
690
|
-
var $this = this;
|
691
|
-
var $tabItem = $this.parentNode;
|
692
|
-
|
693
|
-
if (!$tabItem.classList.contains('active')) {
|
694
|
-
var $tabContent = $tabItem.parentNode.nextElementSibling;
|
695
|
-
var $siblings = btf.siblings($tabItem, '.active')[0];
|
696
|
-
$siblings && $siblings.classList.remove('active');
|
697
|
-
$tabItem.classList.add('active');
|
698
|
-
var tabId = $this.getAttribute('data-href').replace('#', '');
|
699
|
-
|
700
|
-
var childList = _toConsumableArray($tabContent.children);
|
701
|
-
|
702
|
-
childList.forEach(function (item) {
|
703
|
-
if (item.id === tabId) item.classList.add('active');else item.classList.remove('active');
|
704
|
-
});
|
705
|
-
var $isTabJustifiedGallery = $tabContent.querySelectorAll("#".concat(tabId, " .fj-gallery"));
|
706
|
-
|
707
|
-
if ($isTabJustifiedGallery.length > 0) {
|
708
|
-
btf.initJustifiedGallery($isTabJustifiedGallery);
|
709
|
-
}
|
710
|
-
}
|
711
|
-
});
|
712
|
-
});
|
713
|
-
},
|
714
|
-
backToTop: function backToTop() {
|
715
|
-
document.querySelectorAll('#article-container .tabs .tab-to-top').forEach(function (item) {
|
716
|
-
item.addEventListener('click', function () {
|
717
|
-
btf.scrollToDest(btf.getEleTop(btf.getParents(this, '.tabs')), 300);
|
718
|
-
});
|
719
|
-
});
|
720
|
-
}
|
721
|
-
};
|
722
|
-
|
723
|
-
var toggleCardCategory = function toggleCardCategory() {
|
724
|
-
var $cardCategory = document.querySelectorAll('#aside-cat-list .card-category-list-item.parent i');
|
725
|
-
|
726
|
-
if ($cardCategory.length) {
|
727
|
-
$cardCategory.forEach(function (item) {
|
728
|
-
item.addEventListener('click', function (e) {
|
729
|
-
e.preventDefault();
|
730
|
-
var $this = this;
|
731
|
-
$this.classList.toggle('expand');
|
732
|
-
var $parentEle = $this.parentNode.nextElementSibling;
|
733
|
-
|
734
|
-
if (btf.isHidden($parentEle)) {
|
735
|
-
$parentEle.style.display = 'block';
|
736
|
-
} else {
|
737
|
-
$parentEle.style.display = 'none';
|
738
|
-
}
|
739
|
-
});
|
740
|
-
});
|
741
|
-
}
|
742
|
-
};
|
743
|
-
|
744
|
-
var switchComments = function switchComments() {
|
745
|
-
var switchDone = false;
|
746
|
-
var $switchBtn = document.querySelector('#comment-switch > .switch-btn');
|
747
|
-
$switchBtn && $switchBtn.addEventListener('click', function () {
|
748
|
-
this.classList.toggle('move');
|
749
|
-
document.querySelectorAll('#post-comment > .comment-wrap > div').forEach(function (item) {
|
750
|
-
if (btf.isHidden(item)) {
|
751
|
-
item.style.cssText = 'display: block;animation: tabshow .5s';
|
752
|
-
} else {
|
753
|
-
item.style.cssText = "display: none;animation: ''";
|
754
|
-
}
|
755
|
-
});
|
756
|
-
|
757
|
-
if (!switchDone && typeof loadOtherComment === 'function') {
|
758
|
-
switchDone = true;
|
759
|
-
loadOtherComment();
|
760
|
-
}
|
761
|
-
});
|
762
|
-
};
|
763
|
-
|
764
|
-
var addPostOutdateNotice = function addPostOutdateNotice() {
|
765
|
-
var data = GLOBAL_CONFIG.noticeOutdate;
|
766
|
-
var diffDay = btf.diffDate(GLOBAL_CONFIG_SITE.postUpdate);
|
767
|
-
|
768
|
-
if (diffDay >= data.limitDay) {
|
769
|
-
var ele = document.createElement('div');
|
770
|
-
ele.className = 'post-outdate-notice';
|
771
|
-
ele.textContent = data.messagePrev + ' ' + diffDay + ' ' + data.messageNext;
|
772
|
-
var $targetEle = document.getElementById('article-container');
|
773
|
-
|
774
|
-
if (data.position === 'top') {
|
775
|
-
$targetEle.insertBefore(ele, $targetEle.firstChild);
|
776
|
-
} else {
|
777
|
-
$targetEle.appendChild(ele);
|
778
|
-
}
|
779
|
-
}
|
780
|
-
};
|
781
|
-
|
782
|
-
var lazyloadImg = function lazyloadImg() {
|
783
|
-
window.lazyLoadInstance = new LazyLoad({
|
784
|
-
elements_selector: 'img',
|
785
|
-
threshold: 0,
|
786
|
-
data_src: 'lazy-src'
|
787
|
-
});
|
788
|
-
};
|
789
|
-
|
790
|
-
var relativeDate = function relativeDate(selector) {
|
791
|
-
selector.forEach(function (item) {
|
792
|
-
var $this = item;
|
793
|
-
var timeVal = $this.getAttribute('datetime');
|
794
|
-
$this.innerText = btf.diffDate(timeVal, true);
|
795
|
-
$this.style.display = 'inline';
|
796
|
-
});
|
797
|
-
};
|
798
|
-
|
799
|
-
var unRefreshFn = function unRefreshFn() {
|
800
|
-
window.addEventListener('resize', function () {
|
801
|
-
adjustMenu(false);
|
802
|
-
btf.isHidden(document.getElementById('toggle-menu')) && mobileSidebarOpen && sidebarFn.close();
|
803
|
-
});
|
804
|
-
document.getElementById('menu-mask').addEventListener('click', function (e) {
|
805
|
-
sidebarFn.close();
|
806
|
-
});
|
807
|
-
clickFnOfSubMenu();
|
808
|
-
GLOBAL_CONFIG.islazyload && lazyloadImg();
|
809
|
-
GLOBAL_CONFIG.copyright !== undefined && addCopyright();
|
810
|
-
};
|
811
|
-
|
812
|
-
window.refreshFn = function () {
|
813
|
-
initAdjust();
|
814
|
-
|
815
|
-
if (GLOBAL_CONFIG_SITE.isPost) {
|
816
|
-
GLOBAL_CONFIG.noticeOutdate !== undefined && addPostOutdateNotice();
|
817
|
-
GLOBAL_CONFIG.relativeDate.post && relativeDate(document.querySelectorAll('#post-meta time'));
|
818
|
-
} else {
|
819
|
-
GLOBAL_CONFIG.relativeDate.homepage && relativeDate(document.querySelectorAll('#recent-posts time'));
|
820
|
-
GLOBAL_CONFIG.runtime && addRuntime();
|
821
|
-
addLastPushDate();
|
822
|
-
toggleCardCategory();
|
823
|
-
}
|
824
|
-
|
825
|
-
scrollFnToDo();
|
826
|
-
GLOBAL_CONFIG_SITE.isHome && scrollDownInIndex();
|
827
|
-
addHighlightTool();
|
828
|
-
GLOBAL_CONFIG.isPhotoFigcaption && addPhotoFigcaption();
|
829
|
-
scrollFn();
|
830
|
-
var $jgEle = document.querySelectorAll('#article-container .fj-gallery');
|
831
|
-
$jgEle.length && runJustifiedGallery($jgEle);
|
832
|
-
runLightbox();
|
833
|
-
addTableWrap();
|
834
|
-
clickFnOfTagHide();
|
835
|
-
tabsFn.clickFnOfTabs();
|
836
|
-
tabsFn.backToTop();
|
837
|
-
switchComments();
|
838
|
-
document.getElementById('toggle-menu').addEventListener('click', function () {
|
839
|
-
sidebarFn.open();
|
840
|
-
});
|
841
|
-
};
|
842
|
-
|
843
|
-
refreshFn();
|
844
|
-
unRefreshFn();
|
845
|
-
});
|
4
|
+
`+e.languages.author+`
|
5
|
+
`+e.languages.link+window.location.href+`
|
6
|
+
`+e.languages.source+`
|
7
|
+
`+e.languages.info:n=o,t.clipboardData?t.clipboardData.setData("text",n):window.clipboardData.setData("text",n)}},W=function(){var e=document.getElementById("runtimeshow");if(e){var t=e.getAttribute("data-publishDate");e.innerText=btf.diffDate(t)+" "+GLOBAL_CONFIG.runtime}},z=function(){var e=document.getElementById("last-push-date");if(e){var t=e.getAttribute("data-lastPushDate");e.innerText=btf.diffDate(t,!0)}},J=function(){var e=document.querySelectorAll("#article-container :not(.highlight) > table, #article-container > table");e.length&&e.forEach(function(t){btf.wrap(t,"div",{class:"table-wrap"})})},U=function(){var e=document.querySelectorAll("#article-container .hide-button");e.length&&e.forEach(function(t){t.addEventListener("click",function(n){var o=this;o.classList.add("open");var a=o.nextElementSibling.querySelectorAll(".fj-gallery");a.length&&btf.initJustifiedGallery(a)})})},F={clickFnOfTabs:function(){document.querySelectorAll("#article-container .tab > button").forEach(function(e){e.addEventListener("click",function(t){var n=this,o=n.parentNode;if(!o.classList.contains("active")){var a=o.parentNode.nextElementSibling,d=btf.siblings(o,".active")[0];d&&d.classList.remove("active"),o.classList.add("active");var v=n.getAttribute("data-href").replace("#",""),E=_toConsumableArray(a.children);E.forEach(function(g){g.id===v?g.classList.add("active"):g.classList.remove("active")});var h=a.querySelectorAll("#".concat(v," .fj-gallery"));h.length>0&&btf.initJustifiedGallery(h)}})})},backToTop:function(){document.querySelectorAll("#article-container .tabs .tab-to-top").forEach(function(e){e.addEventListener("click",function(){btf.scrollToDest(btf.getEleTop(btf.getParents(this,".tabs")),300)})})}},V=function(){var e=document.querySelectorAll("#aside-cat-list .card-category-list-item.parent i");e.length&&e.forEach(function(t){t.addEventListener("click",function(n){n.preventDefault();var o=this;o.classList.toggle("expand");var a=o.parentNode.nextElementSibling;btf.isHidden(a)?a.style.display="block":a.style.display="none"})})},X=function(){var e=!1,t=document.querySelector("#comment-switch > .switch-btn");t&&t.addEventListener("click",function(){this.classList.toggle("move"),document.querySelectorAll("#post-comment > .comment-wrap > div").forEach(function(n){btf.isHidden(n)?n.style.cssText="display: block;animation: tabshow .5s":n.style.cssText="display: none;animation: ''"}),!e&&typeof loadOtherComment=="function"&&(e=!0,loadOtherComment())})},Y=function(){var e=GLOBAL_CONFIG.noticeOutdate,t=btf.diffDate(GLOBAL_CONFIG_SITE.postUpdate);if(t>=e.limitDay){var n=document.createElement("div");n.className="post-outdate-notice",n.textContent=e.messagePrev+" "+t+" "+e.messageNext;var o=document.getElementById("article-container");e.position==="top"?o.insertBefore(n,o.firstChild):o.appendChild(n)}},Q=function(){window.lazyLoadInstance=new LazyLoad({elements_selector:"img",threshold:0,data_src:"lazy-src"})},N=function(e){e.forEach(function(t){var n=t,o=n.getAttribute("datetime");n.innerText=btf.diffDate(o,!0),n.style.display="inline"})},K=function(){window.addEventListener("resize",function(){k(!1),btf.isHidden(document.getElementById("toggle-menu"))&&I&&B.close()}),document.getElementById("menu-mask").addEventListener("click",function(e){B.close()}),j(),GLOBAL_CONFIG.islazyload&&Q(),GLOBAL_CONFIG.copyright!==void 0&&R()};window.refreshFn=function(){_(),GLOBAL_CONFIG_SITE.isPost?(GLOBAL_CONFIG.noticeOutdate!==void 0&&Y(),GLOBAL_CONFIG.relativeDate.post&&N(document.querySelectorAll("#post-meta time"))):(GLOBAL_CONFIG.relativeDate.homepage&&N(document.querySelectorAll("#recent-posts time")),GLOBAL_CONFIG.runtime&&W(),z(),V()),$(),GLOBAL_CONFIG_SITE.isHome&&x(),D(),GLOBAL_CONFIG.isPhotoFigcaption&&H(),P();var i=document.querySelectorAll("#article-container .fj-gallery");i.length&&M(i),q(),J(),U(),F.clickFnOfTabs(),F.backToTop(),X(),document.getElementById("toggle-menu").addEventListener("click",function(){B.open()})},refreshFn(),K()});
|