q78kgblog 1.0.0

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.
Files changed (231) hide show
  1. package/.github/workflows/HexoSeoAutoPush.yml +36 -0
  2. package/404.html +933 -0
  3. package/BingSiteAuth.xml +4 -0
  4. package/CNAME +1 -0
  5. package/about/index.html +1096 -0
  6. package/archives/2022/06/index.html +942 -0
  7. package/archives/2022/index.html +942 -0
  8. package/archives/2023/02/index.html +942 -0
  9. package/archives/2023/04/index.html +942 -0
  10. package/archives/2023/05/index.html +942 -0
  11. package/archives/2023/08/index.html +942 -0
  12. package/archives/2023/09/index.html +942 -0
  13. package/archives/2023/index.html +942 -0
  14. package/archives/2024/01/index.html +942 -0
  15. package/archives/2024/02/index.html +942 -0
  16. package/archives/2024/index.html +942 -0
  17. package/archives/index.html +942 -0
  18. package/assets/css/APlayer.min.css +3 -0
  19. package/assets/douban-loading.gif +0 -0
  20. package/assets/js/APlayer.min.js +2 -0
  21. package/assets/js/Meting.min.js +1 -0
  22. package/atom.xml +311 -0
  23. package/baidusitemap.xml +43 -0
  24. package/bangumis/index.html +1247 -0
  25. package/bigpie/index.html +714 -0
  26. package/bing.json +1 -0
  27. package/categories/Hello-World/index.html +954 -0
  28. package/categories/Hexo/index.html +954 -0
  29. package/categories/index.html +710 -0
  30. package/categories//345/271/264/347/273/210/346/200/273/347/273/223/index.html +954 -0
  31. package/categories//346/201/260/351/245/255/index.html +954 -0
  32. package/categories//347/264/240/346/235/220/index.html +954 -0
  33. package/categories//351/227/262/350/201/212/346/235/202/350/260/210/index.html +954 -0
  34. package/content.json +1 -0
  35. package/css/404page.css +65 -0
  36. package/css/ariasakablog.css +5632 -0
  37. package/css/commentBarrage.css +111 -0
  38. package/css/danmaku.css +89 -0
  39. package/css/essay.css +306 -0
  40. package/css/iconfont.css +55 -0
  41. package/css/iconfont.ttf +0 -0
  42. package/css/iconfont.woff +0 -0
  43. package/css/iconfont.woff2 +0 -0
  44. package/css/index.css +7006 -0
  45. package/css/people.css +18 -0
  46. package/css/stylessimple.css +40 -0
  47. package/css/swiper.min.css +701 -0
  48. package/css/swiperstyle.css +567 -0
  49. package/css/var.css +0 -0
  50. package/essay/index.html +701 -0
  51. package/favicon.ico +0 -0
  52. package/fcircle/index.html +733 -0
  53. package/fontawesome/index.html +716 -0
  54. package/google.txt +10 -0
  55. package/googlebe706248808ee393.html +1 -0
  56. package/img/144.png +0 -0
  57. package/img/16.png +0 -0
  58. package/img/1666416625095-iPhone X.png +0 -0
  59. package/img/1666416702650-Macbook Pro 2016 (1).png +0 -0
  60. package/img/1666416764216-Nexus 9.png +0 -0
  61. package/img/180.png +0 -0
  62. package/img/192.png +0 -0
  63. package/img/20200904222157.png +0 -0
  64. package/img/20200924153652.png +0 -0
  65. package/img/256.png +0 -0
  66. package/img/36.png +0 -0
  67. package/img/48.png +0 -0
  68. package/img/512.png +0 -0
  69. package/img/72.png +0 -0
  70. package/img/72645310.jpg +0 -0
  71. package/img/8DSTSS20990281646044689944.PNG +0 -0
  72. package/img/96.png +0 -0
  73. package/img/O35HOG22090681654187900371.jpg +0 -0
  74. package/img/a.webp +0 -0
  75. package/img/ad.png +0 -0
  76. package/img/apple-touch-icon.png +0 -0
  77. package/img/avatar.jpg +0 -0
  78. package/img/buYgVO22990681624844309044.jpg +0 -0
  79. package/img/comment.png +0 -0
  80. package/img/favicon.ico +0 -0
  81. package/img/favicon.jpg +0 -0
  82. package/img/friend_404.gif +0 -0
  83. package/img/mqaizf23990681654186719414.jpeg +0 -0
  84. package/img/nyancat.gif +0 -0
  85. package/img/siteshot.png +0 -0
  86. package/img/uTools_1666416859497-iMac.png +0 -0
  87. package/img-col/index.html +802 -0
  88. package/index.html +1056 -0
  89. package/js/aplayersave.js +268 -0
  90. package/js/baiduhistory.js +76 -0
  91. package/js/bbtalk.js +11354 -0
  92. package/js/bbtalklunbo.js +78 -0
  93. package/js/browser.js +35 -0
  94. package/js/calendar.js +380 -0
  95. package/js/cate.js +22 -0
  96. package/js/commentBarrage.js +240 -0
  97. package/js/commentsCount.js +43 -0
  98. package/js/copy.js +23 -0
  99. package/js/countup.js +209 -0
  100. package/js/cursor.js +82 -0
  101. package/js/danmaku.js +106 -0
  102. package/js/day.js +199 -0
  103. package/js/dianzan.js +249 -0
  104. package/js/dis.js +255 -0
  105. package/js/dist/baiduhistory.dev.js +102 -0
  106. package/js/dist/bbtalk.dev.js +12876 -0
  107. package/js/dist/bbtalklunbo.dev.js +45 -0
  108. package/js/dist/calendar.dev.js +395 -0
  109. package/js/dist/fixbugpjax.dev.js +8 -0
  110. package/js/dist/gongnong.dev.js +565 -0
  111. package/js/dist/heimu.dev.js +19 -0
  112. package/js/dist/links.dev.js +13 -0
  113. package/js/dist/main.dev.js +845 -0
  114. package/js/dist/resizeTop.dev.js +50 -0
  115. package/js/dist/seo.dev.js +33 -0
  116. package/js/dist/twikoo.all.min.dev.js +1 -0
  117. package/js/fixbugpjax.js +7 -0
  118. package/js/fixed_card_widget.js +46 -0
  119. package/js/fps.js +58 -0
  120. package/js/gitalker.js +11 -0
  121. package/js/gsap.min.js +11 -0
  122. package/js/heimu.js +16 -0
  123. package/js/hide.show.js +17 -0
  124. package/js/jike.js +121 -0
  125. package/js/jikewater.js +60 -0
  126. package/js/languages.js +511 -0
  127. package/js/latest.js +49 -0
  128. package/js/local-search.js +476 -0
  129. package/js/lunar.js +1071 -0
  130. package/js/lyxTalk.js +12 -0
  131. package/js/main.js +783 -0
  132. package/js/nav.js +30 -0
  133. package/js/noie.js +3 -0
  134. package/js/owo.js +52 -0
  135. package/js/people.js +175 -0
  136. package/js/pikaday.js +109 -0
  137. package/js/random.js +1 -0
  138. package/js/randomFriend.js +95 -0
  139. package/js/resizeTop.js +43 -0
  140. package/js/rightmenu.js +335 -0
  141. package/js/sakura.js +164 -0
  142. package/js/search/algolia.js +155 -0
  143. package/js/search/local-search.js +188 -0
  144. package/js/settings.js +353 -0
  145. package/js/sitetime.js +25 -0
  146. package/js/smooth-scrolling.js +546 -0
  147. package/js/sw-toolbox.js +16 -0
  148. package/js/swiperinit.js +23 -0
  149. package/js/tw_cn.js +100 -0
  150. package/js/twikoo.all.min.js +2 -0
  151. package/js/utils.js +278 -0
  152. package/js/welcome.js +107 -0
  153. package/js/welcomeconsole.js +23 -0
  154. package/links/index.html +842 -0
  155. package/live2d-widget/LICENSE +674 -0
  156. package/live2d-widget/README.md +188 -0
  157. package/live2d-widget/assets/screenshot-1.png +0 -0
  158. package/live2d-widget/assets/screenshot-2.png +0 -0
  159. package/live2d-widget/assets/screenshot-3.png +0 -0
  160. package/live2d-widget/autoload.js +63 -0
  161. package/live2d-widget/demo/demo.html +34 -0
  162. package/live2d-widget/demo/login.html +271 -0
  163. package/live2d-widget/live2d.min.js +1 -0
  164. package/live2d-widget/package.json +31 -0
  165. package/live2d-widget/rollup.config.js +38 -0
  166. package/live2d-widget/src/index.js +178 -0
  167. package/live2d-widget/src/message.js +22 -0
  168. package/live2d-widget/src/model.js +75 -0
  169. package/live2d-widget/src/tools.js +78 -0
  170. package/live2d-widget/src/utils.js +5 -0
  171. package/live2d-widget/src/waifu-tips.js +3 -0
  172. package/live2d-widget/waifu-tips.js +5 -0
  173. package/live2d-widget/waifu-tips.json +255 -0
  174. package/live2d-widget/waifu.css +310 -0
  175. package/manifest.json +1 -0
  176. package/noie.html +69 -0
  177. package/othersite/index.html +779 -0
  178. package/owo.json +1 -0
  179. package/package.json +1 -0
  180. package/people.html +24 -0
  181. package/posts/164ef646/index.html +1027 -0
  182. package/posts/228c2ef8/index.html +1014 -0
  183. package/posts/4a17b156/index.html +1010 -0
  184. package/posts/6f3c565b/index.html +1013 -0
  185. package/posts/7da7c3f6/index.html +1070 -0
  186. package/posts/a9a6c1fb/index.html +1041 -0
  187. package/posts/c262e439/index.html +1002 -0
  188. package/posts/c81531cf/index.html +1080 -0
  189. package/posts/da2093a1/index.html +1022 -0
  190. package/posts/e54f7476/index.html +1052 -0
  191. package/projects.html +424 -0
  192. package/random.html +32 -0
  193. package/robots.txt +17 -0
  194. package/search.xml +309 -0
  195. package/sitemap.txt +62 -0
  196. package/sitemap.xml +488 -0
  197. package/sw.js +190 -0
  198. package/swReg.js +29 -0
  199. package/tags/AI/index.html +955 -0
  200. package/tags/Butterfly/index.html +955 -0
  201. package/tags/Cloudflare/index.html +955 -0
  202. package/tags/DiffSinger/index.html +955 -0
  203. package/tags/Hexo/index.html +955 -0
  204. package/tags/Next/index.html +955 -0
  205. package/tags/RAID/index.html +955 -0
  206. package/tags/VPS/index.html +955 -0
  207. package/tags/Vercel/index.html +955 -0
  208. package/tags/Workers/index.html +955 -0
  209. package/tags/hello-world/index.html +955 -0
  210. package/tags/index.html +710 -0
  211. package/tags//344/270/273/351/242/230/index.html +955 -0
  212. package/tags//344/272/221/346/234/215/345/212/241/345/231/250/index.html +955 -0
  213. package/tags//344/276/277/345/256/234/index.html +955 -0
  214. package/tags//345/206/231/344/275/234/index.html +955 -0
  215. package/tags//345/245/263/346/200/247/346/204/217/350/257/206/index.html +955 -0
  216. package/tags//345/255/246/344/271/240/index.html +955 -0
  217. package/tags//345/256/266/351/207/214/344/272/221/index.html +955 -0
  218. package/tags//345/271/264/347/273/210/346/200/273/347/273/223/index.html +955 -0
  219. package/tags//346/200/247/344/273/267/346/257/224/index.html +955 -0
  220. package/tags//346/212/230/350/205/276/index.html +955 -0
  221. package/tags//346/217/220/344/276/233/345/225/206/index.html +955 -0
  222. package/tags//346/227/245/345/270/270/index.html +955 -0
  223. package/tags//346/234/215/345/212/241/345/231/250/index.html +955 -0
  224. package/tags//346/265/252/346/275/256/index.html +955 -0
  225. package/tags//347/256/200/347/210/261/index.html +955 -0
  226. package/tags//350/207/252/345/212/250/346/240/207/346/263/250/index.html +955 -0
  227. package/tags//350/256/272/346/226/207/index.html +955 -0
  228. package/tags//350/260/267/346/255/214/347/277/273/350/257/221/index.html +955 -0
  229. package/tags//350/264/237/350/275/275/345/235/207/350/241/241/index.html +955 -0
  230. package/tags//351/207/221/345/217/245/index.html +955 -0
  231. package/tags//351/255/224/346/224/271/index.html +955 -0
package/js/main.js ADDED
@@ -0,0 +1,783 @@
1
+
2
+ document.addEventListener('DOMContentLoaded', function () {
3
+ let blogNameWidth, menusWidth, searchWidth, $nav
4
+ let mobileSidebarOpen = false
5
+
6
+ const adjustMenu = (init) => {
7
+ if (init) {
8
+ blogNameWidth = document.getElementById('site-name').offsetWidth
9
+ const $menusEle = document.querySelectorAll('#menus .menus_item')
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
+ })