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