hexo-theme-solitude 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 (173) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +56 -0
  3. package/_config.yml +432 -0
  4. package/languages/en-US.yml +39 -0
  5. package/languages/zh-CN.yml +39 -0
  6. package/layout/404.ejs +34 -0
  7. package/layout/archive.ejs +10 -0
  8. package/layout/category.ejs +18 -0
  9. package/layout/index.ejs +20 -0
  10. package/layout/layout.ejs +35 -0
  11. package/layout/page/about.ejs +13 -0
  12. package/layout/page/categories.ejs +12 -0
  13. package/layout/page/circle.ejs +5 -0
  14. package/layout/page/echarts.ejs +14 -0
  15. package/layout/page/equipment.ejs +2 -0
  16. package/layout/page/links.ejs +57 -0
  17. package/layout/page/page.ejs +3 -0
  18. package/layout/page/rss.ejs +37 -0
  19. package/layout/page/says.ejs +16 -0
  20. package/layout/page/tags.ejs +12 -0
  21. package/layout/page/tlink.ejs +11 -0
  22. package/layout/page.ejs +45 -0
  23. package/layout/partial/body.ejs +8 -0
  24. package/layout/partial/compoment/about/authorinfo.ejs +18 -0
  25. package/layout/partial/compoment/about/award.ejs +57 -0
  26. package/layout/partial/compoment/about/contentinfo.ejs +33 -0
  27. package/layout/partial/compoment/about/hobbies.ejs +44 -0
  28. package/layout/partial/compoment/about/motto.ejs +17 -0
  29. package/layout/partial/compoment/about/other.ejs +68 -0
  30. package/layout/partial/compoment/about/personalities.ejs +11 -0
  31. package/layout/partial/compoment/about/skillsinfo.ejs +62 -0
  32. package/layout/partial/compoment/aside/aside.ejs +28 -0
  33. package/layout/partial/compoment/aside/asideAllInfo.ejs +6 -0
  34. package/layout/partial/compoment/aside/asideArchive.ejs +11 -0
  35. package/layout/partial/compoment/aside/asideFlipCard.ejs +8 -0
  36. package/layout/partial/compoment/aside/asideInfoCard.ejs +39 -0
  37. package/layout/partial/compoment/aside/asideNewestPost.ejs +31 -0
  38. package/layout/partial/compoment/aside/asidePower.ejs +31 -0
  39. package/layout/partial/compoment/aside/asideSwitch.ejs +35 -0
  40. package/layout/partial/compoment/aside/asideTag.ejs +5 -0
  41. package/layout/partial/compoment/aside/asideToc.ejs +11 -0
  42. package/layout/partial/compoment/aside/asideWebInfo.ejs +60 -0
  43. package/layout/partial/compoment/circle/angle.ejs +26 -0
  44. package/layout/partial/compoment/circle/banner.ejs +11 -0
  45. package/layout/partial/compoment/circle/content.ejs +22 -0
  46. package/layout/partial/compoment/dorakika/rightmenu.ejs +115 -0
  47. package/layout/partial/compoment/equipment/list.ejs +37 -0
  48. package/layout/partial/compoment/home/homeCategoryBar.ejs +11 -0
  49. package/layout/partial/compoment/home/postList.ejs +37 -0
  50. package/layout/partial/compoment/hometop/bbTimeList.ejs +15 -0
  51. package/layout/partial/compoment/hometop/categoryGroup.ejs +19 -0
  52. package/layout/partial/compoment/hometop/groupTag.ejs +30 -0
  53. package/layout/partial/compoment/hometop/topGroup.ejs +48 -0
  54. package/layout/partial/compoment/inject/body.ejs +57 -0
  55. package/layout/partial/compoment/inject/head.ejs +19 -0
  56. package/layout/partial/compoment/links/banner.ejs +42 -0
  57. package/layout/partial/compoment/links/linksCard.ejs +27 -0
  58. package/layout/partial/compoment/links/linksItem.ejs +21 -0
  59. package/layout/partial/compoment/mixins/articleSort.ejs +26 -0
  60. package/layout/partial/compoment/mixins/pagination.ejs +11 -0
  61. package/layout/partial/compoment/nav/left.ejs +22 -0
  62. package/layout/partial/compoment/nav/menu.ejs +25 -0
  63. package/layout/partial/compoment/nav/right.ejs +42 -0
  64. package/layout/partial/compoment/post/award.ejs +52 -0
  65. package/layout/partial/compoment/post/copyright.ejs +37 -0
  66. package/layout/partial/compoment/post/postMeta.ejs +83 -0
  67. package/layout/partial/compoment/post/postNav.ejs +41 -0
  68. package/layout/partial/compoment/post/wave.ejs +14 -0
  69. package/layout/partial/compoment/says/banner.ejs +10 -0
  70. package/layout/partial/compoment/says/saysBottom.ejs +18 -0
  71. package/layout/partial/compoment/says/saysContent.ejs +11 -0
  72. package/layout/partial/compoment/third-party/comments/comment.ejs +12 -0
  73. package/layout/partial/compoment/third-party/comments/twikoo.ejs +29 -0
  74. package/layout/partial/compoment/third-party/comments/twikoo_k.ejs +29 -0
  75. package/layout/partial/compoment/third-party/music.ejs +5 -0
  76. package/layout/partial/compoment/third-party/pjax.ejs +31 -0
  77. package/layout/partial/compoment/third-party/search/algolia-search.ejs +20 -0
  78. package/layout/partial/compoment/third-party/search/index.ejs +10 -0
  79. package/layout/partial/compoment/third-party/search/local-search.ejs +22 -0
  80. package/layout/partial/compoment/tlink/banner.ejs +10 -0
  81. package/layout/partial/console.ejs +62 -0
  82. package/layout/partial/footer.ejs +107 -0
  83. package/layout/partial/head.ejs +37 -0
  84. package/layout/partial/header.ejs +6 -0
  85. package/layout/partial/hometop.ejs +15 -0
  86. package/layout/partial/loading.ejs +86 -0
  87. package/layout/partial/nav.ejs +34 -0
  88. package/layout/partial/pwa.ejs +40 -0
  89. package/layout/partial/sidebar.ejs +31 -0
  90. package/layout/post.ejs +36 -0
  91. package/layout/tag.ejs +19 -0
  92. package/package.json +24 -0
  93. package/scripts/event/init.js +22 -0
  94. package/scripts/event/page.js +40 -0
  95. package/scripts/event/welcome.js +15 -0
  96. package/scripts/filter/checkThemeConfig.js +18 -0
  97. package/scripts/filter/default.js +23 -0
  98. package/scripts/filter/katex.js +25 -0
  99. package/scripts/filter/lazyload.js +11 -0
  100. package/scripts/filter/randomPosts.js +9 -0
  101. package/scripts/helper/charts.js +397 -0
  102. package/scripts/helper/getArchiveLength.js +18 -0
  103. package/scripts/helper/randomLinks.js +16 -0
  104. package/scripts/helper/related_post.js +91 -0
  105. package/scripts/helper/themeJsExport.js +77 -0
  106. package/scripts/tags/bvideo.js +42 -0
  107. package/scripts/tags/expand.js +4 -0
  108. package/scripts/tags/fold.js +19 -0
  109. package/scripts/tags/link.js +17 -0
  110. package/scripts/tags/note.js +3 -0
  111. package/scripts/tags/tabs.js +61 -0
  112. package/scripts/tags/timeline.js +35 -0
  113. package/source/css/commentBarrage.css +174 -0
  114. package/source/css/custom.css +901 -0
  115. package/source/css/main.css +16471 -0
  116. package/source/css/search/algolia-search.css +141 -0
  117. package/source/css/search/local-search.css +138 -0
  118. package/source/css/var.css +186 -0
  119. package/source/img/default.png +0 -0
  120. package/source/img/loading.gif +0 -0
  121. package/source/img/power.png +0 -0
  122. package/source/img/pwa/180.png +0 -0
  123. package/source/img/pwa/192.png +0 -0
  124. package/source/img/pwa/512.png +0 -0
  125. package/source/img/pwa/logo.png +0 -0
  126. package/source/img/pwa/siteicon/splash-1125x2436.png +0 -0
  127. package/source/img/pwa/siteicon/splash-1136x640.png +0 -0
  128. package/source/img/pwa/siteicon/splash-1170x2532.png +0 -0
  129. package/source/img/pwa/siteicon/splash-1179x2556.png +0 -0
  130. package/source/img/pwa/siteicon/splash-1242x2208.png +0 -0
  131. package/source/img/pwa/siteicon/splash-1242x2688.png +0 -0
  132. package/source/img/pwa/siteicon/splash-1248x2778.png +0 -0
  133. package/source/img/pwa/siteicon/splash-1290x2796.png +0 -0
  134. package/source/img/pwa/siteicon/splash-1334x750.png +0 -0
  135. package/source/img/pwa/siteicon/splash-1536x2048.png +0 -0
  136. package/source/img/pwa/siteicon/splash-1620x2160.png +0 -0
  137. package/source/img/pwa/siteicon/splash-1668x2224.png +0 -0
  138. package/source/img/pwa/siteicon/splash-1668x2388.png +0 -0
  139. package/source/img/pwa/siteicon/splash-1792x828.png +0 -0
  140. package/source/img/pwa/siteicon/splash-2048x1536.png +0 -0
  141. package/source/img/pwa/siteicon/splash-2048x2732.png +0 -0
  142. package/source/img/pwa/siteicon/splash-2160x1620.png +0 -0
  143. package/source/img/pwa/siteicon/splash-2208x1242.png +0 -0
  144. package/source/img/pwa/siteicon/splash-2224x1668.png +0 -0
  145. package/source/img/pwa/siteicon/splash-2388x1668.png +0 -0
  146. package/source/img/pwa/siteicon/splash-2436x1125.png +0 -0
  147. package/source/img/pwa/siteicon/splash-2532x1170.png +0 -0
  148. package/source/img/pwa/siteicon/splash-2556x1179.png +0 -0
  149. package/source/img/pwa/siteicon/splash-2688x1242.png +0 -0
  150. package/source/img/pwa/siteicon/splash-2732x2048.png +0 -0
  151. package/source/img/pwa/siteicon/splash-2778x1248.png +0 -0
  152. package/source/img/pwa/siteicon/splash-2796x1290.png +0 -0
  153. package/source/img/pwa/siteicon/splash-640x1136.png +0 -0
  154. package/source/img/pwa/siteicon/splash-750x1334.png +0 -0
  155. package/source/img/pwa/siteicon/splash-828x1792.png +0 -0
  156. package/source/img/theme/avatar.png +0 -0
  157. package/source/js/circle.js +1828 -0
  158. package/source/js/commentBarrage.js +148 -0
  159. package/source/js/extend/console/comment.js +99 -0
  160. package/source/js/extend/covercolor/local.js +150 -0
  161. package/source/js/extend/covercolor/web.js +137 -0
  162. package/source/js/extend/search/algolia-search.js +136 -0
  163. package/source/js/extend/search/local-search.js +160 -0
  164. package/source/js/main.js +705 -0
  165. package/source/js/post_ai.js +517 -0
  166. package/source/js/utils.js +153 -0
  167. package/source/lib/bundle.js +27 -0
  168. package/source/lib/friends_post.js +98 -0
  169. package/source/lib/lazyload.js +1 -0
  170. package/source/lib/snackbar.js +16 -0
  171. package/source/lib/snackbar.min.css +1 -0
  172. package/source/lib/view-image.js +13 -0
  173. package/source/lib/waterfall.min.js +1 -0
@@ -0,0 +1,705 @@
1
+ function set_fest() {
2
+ let date = new Date();
3
+ switch ((date.getMonth() + 1).toString() + '.' + date.getDate()){
4
+ case '1.8': // 周总理逝世
5
+ case '9.9': // 毛主席逝世
6
+ case '7.7': // 七七事变
7
+ case '9.18': // 九一八事变
8
+ case '12.13': // 南京大屠杀国家公祭日
9
+ {
10
+ // 创建一个<style>元素
11
+ const styleElement = document.createElement('style');
12
+ // 定义要添加的CSS样式
13
+ const css = `
14
+ html {
15
+ -webkit-filter: grayscale(100%);
16
+ -moz-filter: grayscale(100%);
17
+ -ms-filter: grayscale(100%);
18
+ -o-filter: grayscale(100%);
19
+ filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
20
+ _filter: none;
21
+ }
22
+ `;
23
+ // 将CSS样式添加到<style>元素中
24
+ styleElement.appendChild(document.createTextNode(css));
25
+ // 将<style>元素添加到<head>标签中
26
+ document.head.appendChild(styleElement);
27
+ }break;
28
+ }
29
+ }
30
+
31
+ function setFixed(el) {
32
+ if (!el) return
33
+ const currentTop = window.scrollY || document.documentElement.scrollTop
34
+ if (currentTop > 0) {
35
+ el.classList.add('nav-fixed')
36
+ } else {
37
+ el.classList.remove('nav-fixed')
38
+ }
39
+ }
40
+
41
+ function getTimeState() {
42
+ var e = (new Date).getHours()
43
+ , t = "";
44
+ e >= 0 && e <= 5 ? t = "睡个好觉,保证精力充沛" : e > 5 && e <= 10 ? t = "一日之计在于晨" : e > 10 && e <= 14 ? t = "吃饱了才有力气干活" : e > 14 && e <= 18 ? t = "集中精力,攻克难关" : e > 18 && e <= 24 && (t = "不要太劳累了,早睡更健康")
45
+ return t;
46
+ }
47
+
48
+ const scrollFn = function () {
49
+ const innerHeight = window.innerHeight + 0
50
+ const $header = document.getElementById('page-header')
51
+ setFixed($header)
52
+ if (document.body.scrollHeight <= innerHeight) {
53
+ return
54
+ }
55
+ let initTop = 0
56
+ window.addEventListener('scroll', utils.throttle(function (e) {
57
+ const currentTop = window.scrollY || document.documentElement.scrollTop
58
+ const isDown = scrollDirection(currentTop)
59
+ if (currentTop > 0) {
60
+ if (isDown) {
61
+ if ($header.classList.contains('nav-visible')) $header.classList.remove(
62
+ 'nav-visible')
63
+ } else {
64
+ if (!$header.classList.contains('nav-visible')) $header.classList.add(
65
+ 'nav-visible')
66
+ }
67
+ $header.classList.add('nav-fixed')
68
+ } else {
69
+ if (currentTop === 0) {
70
+ $header.classList.remove('nav-fixed', 'nav-visible')
71
+ }
72
+ }
73
+ percent()
74
+ }, 200))
75
+
76
+ function scrollDirection(currentTop) {
77
+ const result = currentTop > initTop
78
+ initTop = currentTop
79
+ return result
80
+ }
81
+ }
82
+
83
+ /**
84
+ * 滾動處理
85
+ */
86
+
87
+ const sidebarFn = () => {
88
+ const $toggleMenu = document.getElementById('toggle-menu')
89
+ const $mobileSidebarMenus = document.getElementById('sidebar-menus')
90
+ const $menuMask = document.getElementById('menu-mask')
91
+ const $cookies_window = document.getElementById('cookies-window')
92
+ const $header = document.getElementById('page-header')
93
+ const $body = document.body
94
+
95
+ if (!$toggleMenu) return
96
+
97
+ let initTop = 0
98
+ const isChatBtnHide = typeof chatBtnHide === 'function'
99
+ const isChatBtnShow = typeof chatBtnShow === 'function'
100
+
101
+ function openMobileSidebar() {
102
+ utils.sidebarPaddingR()
103
+ $body.style.overflow = 'hidden'
104
+ utils.fadeIn($menuMask, 0.5)
105
+ $mobileSidebarMenus.classList.add('open')
106
+ }
107
+
108
+ function closeMobileSidebar() {
109
+ $body.style.overflow = ''
110
+ $body.style.paddingRight = ''
111
+ utils.fadeOut($menuMask, 0.5)
112
+ $mobileSidebarMenus.classList.remove('open')
113
+ }
114
+
115
+ $toggleMenu.addEventListener('click', openMobileSidebar)
116
+
117
+ $menuMask.addEventListener('click', e => {
118
+ if ($mobileSidebarMenus.classList.contains('open')) {
119
+ closeMobileSidebar()
120
+ }
121
+ })
122
+
123
+ window.addEventListener('resize', e => {
124
+ if ($mobileSidebarMenus.classList.contains('open')) closeMobileSidebar()
125
+ })
126
+ window.addEventListener('scroll', e => {
127
+ const currentTop = window.scrollY || document.documentElement.scrollTop
128
+ const isDown = scrollDirection(currentTop)
129
+ if (currentTop > 0) {
130
+ if (isDown) {
131
+ if ($header.classList.contains('nav-visible')) $header.classList.remove('nav-visible')
132
+ if (isChatBtnShow && isChatShow === true) {
133
+ chatBtnHide()
134
+ isChatShow = false
135
+ }
136
+ } else {
137
+ if (!$header.classList.contains('nav-visible')) $header.classList.add('nav-visible')
138
+ if (isChatBtnHide && isChatShow === false) {
139
+ chatBtnShow()
140
+ isChatShow = true
141
+ }
142
+ }
143
+ $header.classList.add('nav-fixed')
144
+ $cookies_window.classList.add('cw-hide')
145
+ } else {
146
+ if (currentTop === 0) {
147
+ $header.classList.remove('nav-fixed', 'nav-visible')
148
+ }
149
+ }
150
+ }, 200)
151
+
152
+ // find the scroll direction
153
+ function scrollDirection(currentTop) {
154
+ const result = currentTop > initTop // true is down & false is up
155
+ initTop = currentTop
156
+ return result
157
+ }
158
+ }
159
+
160
+ const showTodayCard = () => {
161
+ const el = document.getElementById('todayCard')
162
+ if (el) {
163
+ document.getElementsByClassName('topGroup')[0].addEventListener('mouseleave', () => {
164
+ if (el.classList.contains('hide')) {
165
+ el.classList.remove('hide')
166
+ }
167
+ })
168
+ }
169
+ }
170
+
171
+ const setTimeState = () => {
172
+ const el = document.getElementById('author-info__sayhi')
173
+ if (el) {
174
+ const timeNow = new Date(), hours = timeNow.getHours(), lang = GLOBALCONFIG.lang.sayhello;
175
+ let text = '';
176
+ if (hours >= 0 && hours <= 5) {
177
+ text = lang.goodnight;
178
+ } else if (hours > 5 && hours <= 10) {
179
+ text = lang.morning;
180
+ } else if (hours > 10 && hours <= 14) {
181
+ text = lang.noon;
182
+ } else if (hours > 14 && hours <= 18) {
183
+ text = lang.afternoon;
184
+ } else if (hours > 18 && hours <= 24) {
185
+ text = lang.night;
186
+ }
187
+ el.innerText = text + lang.iam;
188
+ }
189
+ };
190
+
191
+ const chageTimeFormate = () => {
192
+ const timeElements = document.getElementsByTagName("time"), lang = GLOBALCONFIG.lang.time
193
+ for (var i = 0; i < timeElements.length; i++) {
194
+ const datetime = timeElements[i].getAttribute("datetime"), timeObj = new Date(datetime),
195
+ daysDiff = utils.timeDiff(timeObj, new Date())
196
+ var timeString;
197
+ if (daysDiff === 0) {
198
+ timeString = lang.recent;
199
+ } else if (daysDiff === 1) {
200
+ timeString = lang.yesterday;
201
+ } else if (daysDiff === 2) {
202
+ timeString = lang.berforeyesterday;
203
+ } else if (daysDiff <= 7) {
204
+ timeString = daysDiff + lang.daybefore;
205
+ } else {
206
+ if (timeObj.getFullYear() !== new Date().getFullYear()) {
207
+ timeString = timeObj.getFullYear() + "/" + (timeObj.getMonth() + 1) + "/" + timeObj.getDate();
208
+ } else {
209
+ timeString = (timeObj.getMonth() + 1) + "/" + timeObj.getDate();
210
+ }
211
+ }
212
+ timeElements[i].textContent = timeString;
213
+ }
214
+ }
215
+
216
+ /*
217
+ * 文章页右下角下一篇
218
+ */
219
+ const initObserver = () => {
220
+ let e = document.getElementById("post-comment");
221
+ let t = document.getElementById("pagination");
222
+
223
+ function handleIntersection(entries) {
224
+ entries.forEach(function (entry) {
225
+ if (entry.isIntersecting) {
226
+ t.classList.add("show-window");
227
+ document.querySelector(".comment-barrage").style.bottom = "-200px";
228
+ } else {
229
+ t.classList.remove("show-window");
230
+ document.querySelector(".comment-barrage").style.bottom = "0px";
231
+ }
232
+ });
233
+ }
234
+
235
+ if (e && t) {
236
+ let observer = new IntersectionObserver(handleIntersection);
237
+ observer.observe(e);
238
+ }
239
+ }
240
+
241
+ const percent = () => {
242
+ let a = document.documentElement.scrollTop || window.pageYOffset,
243
+ b = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight) - document.documentElement.clientHeight, // 整个网页高度
244
+ result = Math.round(a / b * 100),
245
+ btn = document.querySelector("#percent");
246
+ const visibleBottom = window.scrollY + document.documentElement.clientHeight;
247
+ const eventlistner = document.getElementById('post-tools') || document.getElementById('footer');
248
+ const centerY = eventlistner.offsetTop + (eventlistner.offsetHeight / 2);
249
+ if ((centerY > visibleBottom) || (result > 90)) {
250
+ document.querySelector("#nav-totop").classList.add("long");
251
+ btn.innerHTML = GLOBALCONFIG.lang.backtop;
252
+ document.querySelectorAll(".needEndHide").forEach(item => {
253
+ item.classList.add("hide")
254
+ })
255
+ } else {
256
+ document.querySelector("#nav-totop").classList.remove("long");
257
+ if (result >= 0) {
258
+ btn.innerHTML = result;
259
+ document.querySelectorAll(".needEndHide").forEach(item => {
260
+ item.classList.remove("hide")
261
+ })
262
+ }
263
+ }
264
+ }
265
+
266
+ class toc {
267
+ static init() {
268
+ const tocContainer = document.getElementById('card-toc')
269
+ if (!tocContainer || !tocContainer.querySelector('.toc a')) {
270
+ tocContainer.style.display = 'none'
271
+ return
272
+ }
273
+ const el = document.querySelectorAll('.toc a')
274
+ el.forEach((e) => {
275
+ e.addEventListener('click', (event) => {
276
+ event.preventDefault()
277
+ utils.scrollToDest(utils.getEleTop(document.getElementById(decodeURI((event.target.className === 'toc-text' ? event.target.parentNode.hash : event.target.hash).replace('#', '')))), 300)
278
+ })
279
+ })
280
+ this.active(el)
281
+ }
282
+
283
+ static active(toc) {
284
+ const $article = document.getElementById('article-container')
285
+ const $tocContent = document.getElementById('toc-content')
286
+ const list = $article.querySelectorAll('h1,h2,h3,h4,h5,h6')
287
+ let detectItem = ''
288
+
289
+ function autoScroll(el) {
290
+ const activePosition = el.getBoundingClientRect().top
291
+ const sidebarScrollTop = $tocContent.scrollTop
292
+ if (activePosition > (document.documentElement.clientHeight - 100)) {
293
+ $tocContent.scrollTop = sidebarScrollTop + 150
294
+ }
295
+ if (activePosition < 100) {
296
+ $tocContent.scrollTop = sidebarScrollTop - 150
297
+ }
298
+ }
299
+
300
+ function findHeadPosition(top) {
301
+ if (top === 0) {
302
+ return false
303
+ }
304
+
305
+ let currentIndex = ''
306
+
307
+ list.forEach(function (ele, index) {
308
+ if (top > utils.getEleTop(ele) - 80) {
309
+ currentIndex = index
310
+ }
311
+ })
312
+
313
+ if (detectItem === currentIndex) return
314
+ detectItem = currentIndex
315
+ document.querySelectorAll('.toc .active').forEach((i) => {
316
+ i.classList.remove('active')
317
+ })
318
+ const activeitem = toc[detectItem]
319
+ if (activeitem) {
320
+ let parent = toc[detectItem].parentNode
321
+ activeitem.classList.add('active')
322
+ autoScroll(activeitem)
323
+ for (; !parent.matches('.toc'); parent = parent.parentNode) {
324
+ if (parent.matches('li')) parent.classList.add('active')
325
+ }
326
+ }
327
+ }
328
+
329
+ window.tocScrollFn = utils.throttle(function () {
330
+ const currentTop = window.scrollY || document.documentElement.scrollTop
331
+ findHeadPosition(currentTop)
332
+ }, 100)
333
+
334
+ window.addEventListener('scroll', tocScrollFn)
335
+ }
336
+ }
337
+
338
+ let lastSayHello = "";
339
+
340
+ class sco {
341
+ /*
342
+ * 隐藏协议提醒助手
343
+ */
344
+ static hideCookie() {
345
+ setTimeout(() => {
346
+ const cookiesWindow = document.getElementById("cookies-window");
347
+ if (cookiesWindow) {
348
+ cookiesWindow.classList.add("cw-hide");
349
+ setTimeout(() => {
350
+ cookiesWindow.style.display = "none";
351
+ }, 1000);
352
+ }
353
+ }, 3000);
354
+ }
355
+
356
+ static scrollTo(e) {
357
+ const t = document.getElementById(e);
358
+ if (t) {
359
+ const e = t.getBoundingClientRect().top + window.pageYOffset - 80
360
+ , o = window.pageYOffset
361
+ , n = e - o;
362
+ let a = null;
363
+ window.requestAnimationFrame((function e(t) {
364
+ a || (a = t);
365
+ const l = t - a
366
+ , i = (c = Math.min(l / 0, 1)) < .5 ? 2 * c * c : (4 - 2 * c) * c - 1;
367
+ var c;
368
+ window.scrollTo(0, o + n * i),
369
+ l < 600 && window.requestAnimationFrame(e)
370
+ }
371
+ ))
372
+ }
373
+ }
374
+
375
+ static switchCommentBarrage() {
376
+ var commentBarrageElement = document.querySelector(".comment-barrage");
377
+ if (commentBarrageElement) {
378
+ if (window.getComputedStyle(commentBarrageElement).display === "flex") {
379
+ commentBarrageElement.style.display = "none";
380
+ document.querySelector(".menu-commentBarrage-text").textContent = "显示热评";
381
+ document.querySelector("#consoleCommentBarrage").classList.remove("on");
382
+ localStorage.removeItem("commentBarrageSwitch");
383
+ } else {
384
+ commentBarrageElement.style.display = "flex";
385
+ document.querySelector(".menu-commentBarrage-text").textContent = "关闭热评";
386
+ document.querySelector("#consoleCommentBarrage").classList.add("on");
387
+ localStorage.setItem("commentBarrageSwitch", "false");
388
+ }
389
+ }
390
+ }
391
+
392
+ static sayhi() {
393
+ document.querySelector("#author-info__sayhi") && (document.getElementById("author-info__sayhi").innerHTML = getTimeState())
394
+ }
395
+
396
+ static changeSayHelloText() {
397
+ const e = ["🤖️ 数码科技爱好者", "🔍 分享与热心帮助", "🏠 智能家居小能手", "🔨 设计开发一条龙", "🤝 专修交互与设计", "🏃 脚踏实地行动派", "🧱 团队小组发动机", "💢 壮汉人狠话不多"]
398
+ , t = document.getElementById("author-info__sayhi");
399
+ let o = e[Math.floor(Math.random() * e.length)];
400
+ for (; o === lastSayHello;)
401
+ o = e[Math.floor(Math.random() * e.length)];
402
+ t.textContent = o,
403
+ lastSayHello = o
404
+ }
405
+
406
+ static switchDarkMode() {
407
+ const nowMode = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' :
408
+ 'light'
409
+ if (nowMode === 'light') {
410
+ document.documentElement.setAttribute('data-theme', 'dark')
411
+ localStorage.setItem('theme', 'dark')
412
+ utils.snackbarShow(GLOBALCONFIG.lang.theme.dark, false, 2000)
413
+ } else {
414
+ document.documentElement.setAttribute('data-theme', 'light')
415
+ localStorage.setItem('theme', 'light')
416
+ utils.snackbarShow(GLOBALCONFIG.lang.theme.light, false, 2000)
417
+ }
418
+ }
419
+
420
+ static hideTodayCard() {
421
+ document.getElementById('todayCard').classList.add('hide')
422
+ }
423
+
424
+ static toTop() {
425
+ utils.scrollToDest(0)
426
+ }
427
+
428
+ static showConsole() {
429
+ const el = document.getElementById('console')
430
+ if (!el.classList.contains('show')) {
431
+ el.classList.add('show')
432
+ }
433
+ }
434
+
435
+ static hideConsole() {
436
+ const el = document.getElementById('console')
437
+ if (el.classList.contains('show')) {
438
+ el.classList.remove('show')
439
+ }
440
+ }
441
+
442
+ static copyPageUrl() {
443
+ utils.copy(window.location.href)
444
+ }
445
+
446
+ static lightbox(el) {
447
+ window.ViewImage && window.ViewImage.init("#article-container img:not(.flink-avatar), .bber-content-img img, #album_detail img, #equipment img, #twikoo .tk-content img:not(.tk-owo-emotion)");
448
+ }
449
+
450
+ static initTheme() {
451
+ const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
452
+ const cachedMode = localStorage.getItem('theme');
453
+ const isLightMode = !isDarkMode;
454
+
455
+ const nowMode =
456
+ cachedMode && (cachedMode === 'dark' || cachedMode === 'light')
457
+ ? cachedMode === 'dark' && isLightMode ? 'light'
458
+ : cachedMode === 'light' && isDarkMode ? 'dark'
459
+ : cachedMode
460
+ : isDarkMode ? 'dark'
461
+ : 'light';
462
+
463
+ document.documentElement.setAttribute('data-theme', nowMode);
464
+ localStorage.setItem('theme', nowMode);
465
+ }
466
+
467
+ static reflashEssayWaterFall() {
468
+ if (document.getElementById('waterfall')) {
469
+ setTimeout(function () {
470
+ waterfall('#waterfall');
471
+ document.getElementById("waterfall").classList.add('show');
472
+ }, 500);
473
+ }
474
+ }
475
+
476
+ static addRuntime() {
477
+ const el = document.getElementById('runtimeshow')
478
+ if (el && GLOBALCONFIG.runtime) {
479
+ el.innerText = utils.timeDiff(new Date(GLOBALCONFIG.runtime), new Date()) + GLOBALCONFIG.lang.time.runtime
480
+ }
481
+ }
482
+
483
+ static lazyloadImg() {
484
+ window.lazyLoadInstance = new LazyLoad({
485
+ elements_selector: 'img',
486
+ threshold: 0,
487
+ data_src: 'lazy-src',
488
+ callback_error: (img) => {
489
+ img.setAttribute("src", GLOBALCONFIG.lazyload.error);
490
+ }
491
+ })
492
+ }
493
+
494
+ static toTalk(txt) {
495
+ const input = document.querySelector('.el-textarea__inner');
496
+ const evt = new Event('input', {bubbles: true, cancelable: true});
497
+ const inputValue = txt.replace(/\n/g, '\n> ');
498
+ input.value = '> ' + inputValue + '\n\n';
499
+ input.dispatchEvent(evt);
500
+ utils.scrollToDest(utils.getEleTop(document.getElementById('post-comment')), 300)
501
+ input.focus();
502
+ input.setSelectionRange(-1, -1);
503
+ const commentTips = document.querySelector("#comment-tips");
504
+ if (commentTips) {
505
+ commentTips.classList.add("show");
506
+ }
507
+ }
508
+
509
+ static initbbtalk() {
510
+ if (document.querySelector('#bber-talk')) {
511
+ var swiper = new Swiper('.swiper-container', {
512
+ direction: 'vertical',
513
+ loop: true,
514
+ autoplay: {
515
+ delay: 3000,
516
+ pauseOnMouseEnter: true
517
+ },
518
+ });
519
+ }
520
+ }
521
+
522
+ static addPhotoFigcaption() {
523
+ const images = document.querySelectorAll('#article-container img');
524
+ images.forEach((image) => {
525
+ const imageParent = image.parentNode;
526
+ const captionText = image.getAttribute('alt');
527
+
528
+ if (captionText) {
529
+ const captionElement = document.createElement('div');
530
+ captionElement.className = 'img-alt is-center';
531
+ captionElement.textContent = captionText;
532
+
533
+ imageParent.insertBefore(captionElement, image.nextSibling);
534
+ }
535
+ });
536
+ }
537
+
538
+ static musicToggle() {
539
+ const $music = document.querySelector('#nav-music'),
540
+ $meting = document.querySelector('meting-js'),
541
+ $console = document.getElementById('consoleMusic')
542
+ if (wleelw_musicPlaying) {
543
+ $music.classList.remove("playing")
544
+ $console.classList.remove("on")
545
+ wleelw_musicPlaying = false;
546
+ $meting.aplayer.pause();
547
+ } else {
548
+ $music.classList.add("playing")
549
+ $console.classList.add("on")
550
+ wleelw_musicPlaying = true;
551
+ $meting.aplayer.play();
552
+ }
553
+ }
554
+
555
+ static scrollToComment() {
556
+ utils.scrollToDest(utils.getEleTop(document.getElementById('post-comment')), 300)
557
+ }
558
+ }
559
+
560
+ class hightlight {
561
+ static createEle(langEl, item) {
562
+ const fragment = document.createDocumentFragment()
563
+ const highlightCopyEle = '<i class="ri-file-copy-fill"></i>'
564
+ const highlightExpandEle = '<i class="ri-arrow-down-s-line expand" style="font-size: 16px"></i>'
565
+
566
+ const hlTools = document.createElement('div')
567
+ hlTools.className = `highlight-tools`
568
+ hlTools.innerHTML = highlightExpandEle + langEl + highlightCopyEle
569
+ let expand = true
570
+ hlTools.children[0].addEventListener('click', (e) => {
571
+ if (expand) {
572
+ hlTools.children[0].classList.add('closed')
573
+ $table.setAttribute('style', 'display:none')
574
+ if ($expand.length !== 0) {
575
+ $expand[0].setAttribute('style', 'display:none')
576
+ }
577
+ } else {
578
+ hlTools.children[0].classList.remove('closed')
579
+ $table.setAttribute('style', 'display:block')
580
+ if ($expand.length !== 0) {
581
+ $expand[0].setAttribute('style', 'display:block')
582
+ }
583
+ if (itemHeight < 200) {
584
+ $table.setAttribute('style', 'height:' + itemHeight + "px")
585
+ } else {
586
+ $table.setAttribute('style', 'height:200px')
587
+ ele.classList.remove("expand-done")
588
+ }
589
+ }
590
+ expand = !expand
591
+ })
592
+ hlTools.children[2].addEventListener('click', (e) => {
593
+ utils.copy($table.querySelector('.code').innerText)
594
+ })
595
+ const ele = document.createElement('div')
596
+ fragment.appendChild(hlTools)
597
+ const itemHeight = item.clientHeight, $table = item.querySelector('table'),
598
+ $expand = item.getElementsByClassName('code-expand-btn')
599
+ if (GLOBALCONFIG.hightlight.limit && itemHeight > GLOBALCONFIG.hightlight.limit + 30) {
600
+ $table.setAttribute('style', `height: ${GLOBALCONFIG.hightlight.limit}px`)
601
+ ele.className = 'code-expand-btn'
602
+ ele.innerHTML = '<i class="ri-arrow-down-double-fill" style="font-size: 1.2rem"></i>'
603
+ ele.addEventListener('click', (e) => {
604
+ $table.setAttribute('style', `height: ${itemHeight}px`)
605
+ e.target.className !== 'code-expand-btn' ? e.target.parentNode.classList.add('expand-done') : e.target.classList.add('expand-done')
606
+ })
607
+ fragment.appendChild(ele)
608
+ }
609
+ item.insertBefore(fragment, item.firstChild)
610
+ }
611
+
612
+ static init() {
613
+ const $figureHighlight = document.querySelectorAll('figure.highlight'), that = this
614
+ $figureHighlight.forEach(function (item) {
615
+ let langName = item.getAttribute('class').split(' ')[1]
616
+ if (langName === 'plaintext' || langName === undefined) langName = 'Code'
617
+ const highlightLangEle = `<div class="code-lang">${langName.toUpperCase()}</div>`
618
+ that.createEle(highlightLangEle, item)
619
+ })
620
+ }
621
+ }
622
+
623
+ class tabs {
624
+ static init() {
625
+ this.clickFnOfTabs()
626
+ this.backToTop()
627
+ }
628
+
629
+ static clickFnOfTabs() {
630
+ document.querySelectorAll('#article-container .tab > button').forEach(function (item) {
631
+ item.addEventListener('click', function (e) {
632
+ const that = this
633
+ const $tabItem = that.parentNode
634
+ if (!$tabItem.classList.contains('active')) {
635
+ const $tabContent = $tabItem.parentNode.nextElementSibling
636
+ const $siblings = utils.siblings($tabItem, '.active')[0]
637
+ $siblings && $siblings.classList.remove('active')
638
+ $tabItem.classList.add('active')
639
+ const tabId = that.getAttribute('data-href').replace('#', '')
640
+ const childList = [...$tabContent.children]
641
+ childList.forEach(item => {
642
+ if (item.id === tabId) item.classList.add('active')
643
+ else item.classList.remove('active')
644
+ })
645
+ }
646
+ })
647
+ })
648
+ }
649
+
650
+ static backToTop() {
651
+ document.querySelectorAll('#article-container .tabs .tab-to-top').forEach(function (item) {
652
+ item.addEventListener('click', function () {
653
+ utils.scrollToDest(utils.getEleTop(item.parentElement.parentElement.parentNode), 300)
654
+ })
655
+ })
656
+ }
657
+ }
658
+
659
+
660
+ window.refreshFn = () => {
661
+ scrollFn()
662
+ sidebarFn()
663
+ setTimeState()
664
+ GLOBALCONFIG.comment.enable && newestCommentInit()
665
+ chageTimeFormate()
666
+ initObserver()
667
+ sco.addRuntime()
668
+ sco.hideCookie()
669
+ sco.addPhotoFigcaption()
670
+ sco.sayhi()
671
+ GLOBALCONFIG.lazyload.enable && sco.lazyloadImg()
672
+ GLOBALCONFIG.lightbox && sco.lightbox('')
673
+ GLOBALCONFIG.randomlinks && randomLinksList()
674
+ PAGECONFIG.toc && toc.init()
675
+ if (PAGECONFIG.is_post || PAGECONFIG.is_page) {
676
+ GLOBALCONFIG.hightlight.enable && hightlight.init()
677
+ tabs.init()
678
+ }
679
+ PAGECONFIG.comment && initComment()
680
+ if (PAGECONFIG.is_home) {
681
+ showTodayCard()
682
+ sco.initbbtalk()
683
+ }
684
+ if (PAGECONFIG.is_page && PAGECONFIG.page === 'says') sco.reflashEssayWaterFall()
685
+ if (PAGECONFIG.is_page) {
686
+ if (document.getElementById('album_detail')) sco.reflashEssayWaterFall()
687
+ }
688
+ GLOBALCONFIG.covercolor && coverColor();
689
+ set_fest()
690
+ }
691
+
692
+ sco.initTheme()
693
+
694
+ let wleelw_musicPlaying = false
695
+ document.addEventListener('DOMContentLoaded', function () {
696
+ window.refreshFn()
697
+ })
698
+
699
+ document.addEventListener('pjax:complete', () => {
700
+ window.refreshFn()
701
+ })
702
+
703
+ window.onkeydown = function (e) {
704
+ 123 === e.keyCode && utils.snackbarShow("开发者模式已打开,请遵循GPL协议", !1, 3e3)
705
+ }