hexo-theme-solitude 3.0.10 → 3.0.11

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 (34) hide show
  1. package/_config.yml +15 -27
  2. package/languages/default.yml +14 -15
  3. package/languages/en.yml +22 -24
  4. package/languages/zh-CN.yml +14 -15
  5. package/languages/zh-TW.yml +14 -15
  6. package/layout/includes/head/config.pug +0 -11
  7. package/layout/includes/head/page_config.pug +1 -1
  8. package/layout/includes/inject/body.pug +1 -1
  9. package/layout/includes/layout.pug +0 -4
  10. package/layout/includes/page/brevity.pug +2 -2
  11. package/layout/includes/widgets/page/about/skillsinfo.pug +12 -11
  12. package/layout/includes/widgets/page/kit/content.pug +3 -2
  13. package/layout/includes/widgets/page/links/banner.pug +7 -6
  14. package/layout/includes/widgets/post/ai.pug +7 -0
  15. package/layout/post.pug +2 -2
  16. package/package.json +1 -1
  17. package/scripts/event/cdn.js +83 -60
  18. package/scripts/event/merge_config.js +385 -385
  19. package/scripts/filter/default.js +22 -24
  20. package/scripts/tags/tabs.js +29 -18
  21. package/source/css/_global/index.styl +2 -2
  22. package/source/css/_layout/article-container.styl +1 -1
  23. package/source/css/_layout/other.styl +2 -2
  24. package/source/css/_post/index.styl +103 -4
  25. package/source/css/_tags/tabs.styl +40 -101
  26. package/source/css/index.styl +0 -4
  27. package/source/js/main.js +447 -257
  28. package/source/js/post_ai.js +60 -0
  29. package/source/js/utils.js +0 -6
  30. package/layout/includes/widgets/post/post-ai.pug +0 -12
  31. package/layout/includes/widgets/third-party/tianli-talk.pug +0 -26
  32. package/source/css/_post/postAI.styl +0 -132
  33. package/source/css/third_party/tianli_talk.styl +0 -77
  34. package/source/js/third_party/post_ai.min.js +0 -184
package/source/js/main.js CHANGED
@@ -1,27 +1,29 @@
1
1
  const sidebarFn = () => {
2
- const $toggleMenu = document.getElementById('toggle-menu');
3
- const $mobileSidebarMenus = document.getElementById('sidebar-menus');
4
- const $menuMask = document.getElementById('menu-mask');
2
+ const $toggleMenu = document.getElementById("toggle-menu");
3
+ const $mobileSidebarMenus = document.getElementById("sidebar-menus");
4
+ const $menuMask = document.getElementById("menu-mask");
5
5
  const $body = document.body;
6
6
 
7
7
  const toggleMobileSidebar = (isOpen) => {
8
- utils.sidebarPaddingR();
9
- $body.style.overflow = isOpen ? 'hidden' : '';
10
- utils[isOpen ? 'fadeIn' : 'fadeOut']($menuMask, 0.5);
11
- $mobileSidebarMenus.classList.toggle('open', isOpen);
8
+ $body.style.overflow = isOpen ? "hidden" : "";
9
+ utils[isOpen ? "fadeIn" : "fadeOut"]($menuMask, 0.5);
10
+ $mobileSidebarMenus.classList.toggle("open", isOpen);
12
11
  };
13
12
 
14
13
  const closeMobileSidebar = () => {
15
- if ($mobileSidebarMenus.classList.contains('open')) {
14
+ if ($mobileSidebarMenus.classList.contains("open")) {
16
15
  toggleMobileSidebar(false);
17
16
  }
18
17
  };
19
18
 
20
- $toggleMenu.addEventListener('click', () => toggleMobileSidebar(true));
21
- $menuMask.addEventListener('click', closeMobileSidebar);
19
+ $toggleMenu.addEventListener("click", () => toggleMobileSidebar(true));
20
+ $menuMask.addEventListener("click", closeMobileSidebar);
22
21
 
23
- window.addEventListener('resize', () => {
24
- if (utils.isHidden($toggleMenu) && $mobileSidebarMenus.classList.contains('open')) {
22
+ window.addEventListener("resize", () => {
23
+ if (
24
+ utils.isHidden($toggleMenu) &&
25
+ $mobileSidebarMenus.classList.contains("open")
26
+ ) {
25
27
  closeMobileSidebar();
26
28
  }
27
29
  sco.refreshWaterFall();
@@ -29,23 +31,23 @@ const sidebarFn = () => {
29
31
  };
30
32
 
31
33
  const scrollFn = () => {
32
- const $rightside = document.getElementById('rightside');
33
- const $header = document.getElementById('page-header');
34
+ const $rightside = document.getElementById("rightside");
35
+ const $header = document.getElementById("page-header");
34
36
  let initTop = 0;
35
37
 
36
38
  const updateHeaderAndRightside = (isDown, currentTop) => {
37
39
  if (currentTop > 0) {
38
- $header.classList.toggle('nav-visible', !isDown);
39
- $header.classList.add('nav-fixed');
40
+ $header.classList.toggle("nav-visible", !isDown);
41
+ $header.classList.add("nav-fixed");
40
42
  if ($rightside) {
41
- $rightside.style.opacity = '0.8';
42
- $rightside.style.transform = 'translateX(-58px)';
43
+ $rightside.style.opacity = "0.8";
44
+ $rightside.style.transform = "translateX(-58px)";
43
45
  }
44
46
  } else {
45
- $header.classList.remove('nav-fixed', 'nav-visible');
47
+ $header.classList.remove("nav-fixed", "nav-visible");
46
48
  if ($rightside) {
47
- $rightside.style.opacity = '';
48
- $rightside.style.transform = '';
49
+ $rightside.style.opacity = "";
50
+ $rightside.style.transform = "";
49
51
  }
50
52
  }
51
53
  };
@@ -58,13 +60,13 @@ const scrollFn = () => {
58
60
  updateHeaderAndRightside(isDown, currentTop);
59
61
  }, 200);
60
62
 
61
- window.addEventListener('scroll', (e) => {
63
+ window.addEventListener("scroll", (e) => {
62
64
  throttledScroll(e);
63
65
  if (window.scrollY === 0) {
64
- $header.classList.remove('nav-fixed', 'nav-visible');
65
- if ($rightside) {
66
- $rightside.style.cssText = "opacity: ''; transform: ''";
67
- }
66
+ $header.classList.remove("nav-fixed", "nav-visible");
67
+ if ($rightside) {
68
+ $rightside.style.cssText = "opacity: ''; transform: ''";
69
+ }
68
70
  }
69
71
  });
70
72
  };
@@ -73,24 +75,46 @@ const percent = () => {
73
75
  const docEl = document.documentElement;
74
76
  const body = document.body;
75
77
  const scrollPos = window.pageYOffset || docEl.scrollTop;
76
- const totalScrollableHeight = Math.max(body.scrollHeight, docEl.scrollHeight, body.offsetHeight, docEl.offsetHeight, body.clientHeight, docEl.clientHeight) - docEl.clientHeight;
78
+ const totalScrollableHeight =
79
+ Math.max(
80
+ body.scrollHeight,
81
+ docEl.scrollHeight,
82
+ body.offsetHeight,
83
+ docEl.offsetHeight,
84
+ body.clientHeight,
85
+ docEl.clientHeight
86
+ ) - docEl.clientHeight;
77
87
  const scrolledPercent = Math.round((scrollPos / totalScrollableHeight) * 100);
78
88
  const navToTop = document.querySelector("#nav-totop");
79
89
  const rsToTop = document.querySelector(".rs_show .top i");
80
90
  const percentDisplay = document.querySelector("#percent");
81
- const isNearEnd = (window.scrollY + docEl.clientHeight) >= (document.getElementById("post-comment") || document.getElementById("footer")).offsetTop;
91
+ const isNearEnd =
92
+ window.scrollY + docEl.clientHeight >=
93
+ (
94
+ document.getElementById("post-comment") ||
95
+ document.getElementById("footer")
96
+ ).offsetTop;
82
97
 
83
98
  navToTop?.classList.toggle("long", isNearEnd || scrolledPercent > 90);
84
99
  rsToTop?.classList.toggle("show", isNearEnd || scrolledPercent > 90);
85
- percentDisplay.textContent = isNearEnd || scrolledPercent > 90 ? (navToTop ? GLOBAL_CONFIG.lang.backtop : '') : scrolledPercent;
86
-
87
- document.querySelectorAll(".needEndHide").forEach(item => item.classList.toggle("hide", totalScrollableHeight - scrollPos < 100));
100
+ percentDisplay.textContent =
101
+ isNearEnd || scrolledPercent > 90
102
+ ? navToTop
103
+ ? GLOBAL_CONFIG.lang.backtop
104
+ : ""
105
+ : scrolledPercent;
106
+
107
+ document
108
+ .querySelectorAll(".needEndHide")
109
+ .forEach((item) =>
110
+ item.classList.toggle("hide", totalScrollableHeight - scrollPos < 100)
111
+ );
88
112
  };
89
113
 
90
114
  const showTodayCard = () => {
91
- const el = document.getElementById('todayCard');
92
- const topGroup = document.querySelector('.topGroup');
93
- topGroup?.addEventListener('mouseleave', () => el?.classList.remove('hide'));
115
+ const el = document.getElementById("todayCard");
116
+ const topGroup = document.querySelector(".topGroup");
117
+ topGroup?.addEventListener("mouseleave", () => el?.classList.remove("hide"));
94
118
  };
95
119
 
96
120
  const initObserver = () => {
@@ -99,11 +123,13 @@ const initObserver = () => {
99
123
  const commentBarrageElement = document.querySelector(".comment-barrage");
100
124
 
101
125
  if (commentElement && paginationElement) {
102
- const observer = new IntersectionObserver(entries => {
103
- entries.forEach(entry => {
126
+ const observer = new IntersectionObserver((entries) => {
127
+ entries.forEach((entry) => {
104
128
  paginationElement.classList.toggle("show-window", entry.isIntersecting);
105
129
  if (GLOBAL_CONFIG.comment.commentBarrage) {
106
- commentBarrageElement.style.bottom = entry.isIntersecting ? "-200px" : "0px";
130
+ commentBarrageElement.style.bottom = entry.isIntersecting
131
+ ? "-200px"
132
+ : "0px";
107
133
  }
108
134
  });
109
135
  });
@@ -115,28 +141,40 @@ const addCopyright = () => {
115
141
  if (!GLOBAL_CONFIG.copyright) return;
116
142
  const { limit, author, link, source, info } = GLOBAL_CONFIG.copyright;
117
143
 
118
- document.body.addEventListener('copy', (e) => {
144
+ document.body.addEventListener("copy", (e) => {
119
145
  e.preventDefault();
120
146
  const copyText = window.getSelection().toString();
121
- const text = copyText.length > limit ? `${copyText}\n\n${author}\n${link}${window.location.href}\n${source}\n${info}` : copyText;
122
- e.clipboardData.setData('text', text);
147
+ const text =
148
+ copyText.length > limit
149
+ ? `${copyText}\n\n${author}\n${link}${window.location.href}\n${source}\n${info}`
150
+ : copyText;
151
+ e.clipboardData.setData("text", text);
123
152
  });
124
153
  };
125
154
 
126
155
  const asideStatus = () => {
127
- const status = utils.saveToLocal.get('aside-status');
128
- document.documentElement.classList.toggle('hide-aside', status === 'hide');
156
+ const status = utils.saveToLocal.get("aside-status");
157
+ document.documentElement.classList.toggle("hide-aside", status === "hide");
129
158
  };
130
159
 
131
160
  function initThemeColor() {
132
161
  const currentTop = window.scrollY || document.documentElement.scrollTop;
133
- const themeColor = currentTop > 0 ? '--efu-card-bg' : PAGE_CONFIG.is_post ? '--efu-main' : '--efu-background';
134
- applyThemeColor(getComputedStyle(document.documentElement).getPropertyValue(themeColor));
162
+ const themeColor =
163
+ currentTop > 0
164
+ ? "--efu-card-bg"
165
+ : PAGE_CONFIG.is_post
166
+ ? "--efu-main"
167
+ : "--efu-background";
168
+ applyThemeColor(
169
+ getComputedStyle(document.documentElement).getPropertyValue(themeColor)
170
+ );
135
171
  }
136
172
 
137
173
  function applyThemeColor(color) {
138
174
  const themeColorMeta = document.querySelector('meta[name="theme-color"]');
139
- const appleMobileWebAppMeta = document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');
175
+ const appleMobileWebAppMeta = document.querySelector(
176
+ 'meta[name="apple-mobile-web-app-status-bar-style"]'
177
+ );
140
178
  themeColorMeta?.setAttribute("content", color);
141
179
  appleMobileWebAppMeta?.setAttribute("content", color);
142
180
  if (window.matchMedia("(display-mode: standalone)").matches) {
@@ -144,9 +182,9 @@ function applyThemeColor(color) {
144
182
  }
145
183
  }
146
184
 
147
- const handleThemeChange = mode => {
185
+ const handleThemeChange = (mode) => {
148
186
  const themeChange = window.globalFn?.themeChange || {};
149
- Object.values(themeChange).forEach(fn => fn(mode));
187
+ Object.values(themeChange).forEach((fn) => fn(mode));
150
188
  };
151
189
 
152
190
  const sco = {
@@ -156,7 +194,8 @@ const sco = {
156
194
  scrollTo(elementId) {
157
195
  const targetElement = document.getElementById(elementId);
158
196
  if (targetElement) {
159
- const targetPosition = targetElement.getBoundingClientRect().top + window.pageYOffset - 80;
197
+ const targetPosition =
198
+ targetElement.getBoundingClientRect().top + window.pageYOffset - 80;
160
199
  window.scroll({ top: targetPosition, behavior: "smooth" });
161
200
  }
162
201
  },
@@ -164,20 +203,24 @@ const sco = {
164
203
  if (!this.isMusicBind) {
165
204
  this.musicBind();
166
205
  }
167
- const $music = document.querySelector('#nav-music');
168
- const $meting = document.querySelector('meting-js');
169
- const $console = document.getElementById('consoleMusic');
170
- const $rmText = document.querySelector('#menu-music-toggle span');
171
- const $rmIcon = document.querySelector('#menu-music-toggle i');
206
+ const $music = document.querySelector("#nav-music");
207
+ const $meting = document.querySelector("meting-js");
208
+ const $console = document.getElementById("consoleMusic");
209
+ const $rmText = document.querySelector("#menu-music-toggle span");
210
+ const $rmIcon = document.querySelector("#menu-music-toggle i");
172
211
 
173
212
  this.musicPlaying = !this.musicPlaying;
174
213
  $music.classList.toggle("playing", this.musicPlaying);
175
214
  $music.classList.toggle("stretch", this.musicPlaying);
176
215
  $console?.classList.toggle("on", this.musicPlaying);
177
216
 
178
- if (typeof rm !== 'undefined' && rm?.menuItems.music[0]) {
179
- $rmText.textContent = this.musicPlaying ? GLOBAL_CONFIG.right_menu.music.stop : GLOBAL_CONFIG.right_menu.music.start;
180
- $rmIcon.className = this.musicPlaying ? 'solitude fas fa-pause' : 'solitude fas fa-play';
217
+ if (typeof rm !== "undefined" && rm?.menuItems.music[0]) {
218
+ $rmText.textContent = this.musicPlaying
219
+ ? GLOBAL_CONFIG.right_menu.music.stop
220
+ : GLOBAL_CONFIG.right_menu.music.start;
221
+ $rmIcon.className = this.musicPlaying
222
+ ? "solitude fas fa-pause"
223
+ : "solitude fas fa-play";
181
224
  }
182
225
 
183
226
  if (isMeting) {
@@ -185,15 +228,15 @@ const sco = {
185
228
  }
186
229
  },
187
230
  musicBind() {
188
- const $music = document.querySelector('#nav-music');
189
- const $name = document.querySelector('#nav-music .aplayer-music');
190
- const $button = document.querySelector('#nav-music .aplayer-button');
231
+ const $music = document.querySelector("#nav-music");
232
+ const $name = document.querySelector("#nav-music .aplayer-music");
233
+ const $button = document.querySelector("#nav-music .aplayer-button");
191
234
 
192
- $name?.addEventListener('click', () => {
235
+ $name?.addEventListener("click", () => {
193
236
  $music.classList.toggle("stretch");
194
237
  });
195
238
 
196
- $button?.addEventListener('click', () => {
239
+ $button?.addEventListener("click", () => {
197
240
  this.musicToggle(false);
198
241
  });
199
242
 
@@ -201,13 +244,16 @@ const sco = {
201
244
  },
202
245
  switchCommentBarrage() {
203
246
  const commentBarrageElement = document.querySelector(".comment-barrage");
204
- const consoleCommentBarrage = document.querySelector("#consoleCommentBarrage");
247
+ const consoleCommentBarrage = document.querySelector(
248
+ "#consoleCommentBarrage"
249
+ );
205
250
  if (!commentBarrageElement) return;
206
251
 
207
- const isDisplayed = window.getComputedStyle(commentBarrageElement).display === "flex";
252
+ const isDisplayed =
253
+ window.getComputedStyle(commentBarrageElement).display === "flex";
208
254
  commentBarrageElement.style.display = isDisplayed ? "none" : "flex";
209
255
  consoleCommentBarrage?.classList.toggle("on", !isDisplayed);
210
- utils.saveToLocal.set("commentBarrageSwitch", !isDisplayed, .2);
256
+ utils.saveToLocal.set("commentBarrageSwitch", !isDisplayed, 0.2);
211
257
  rm?.menuItems.barrage && rm.barrage(isDisplayed);
212
258
  },
213
259
  switchHideAside() {
@@ -225,12 +271,15 @@ const sco = {
225
271
  consoleKeyboard?.classList.toggle("on", this.sco_keyboards);
226
272
  keyboardFunction();
227
273
  localStorage.setItem("keyboard", this.sco_keyboards);
228
- document.getElementById('keyboard-tips')?.classList.remove('show');
274
+ document.getElementById("keyboard-tips")?.classList.remove("show");
229
275
  },
230
276
  initConsoleState() {
231
277
  const consoleHideAside = document.querySelector("#consoleHideAside");
232
278
  if (!consoleHideAside) return;
233
- consoleHideAside.classList.toggle("on", document.documentElement.classList.contains("hide-aside"));
279
+ consoleHideAside.classList.toggle(
280
+ "on",
281
+ document.documentElement.classList.contains("hide-aside")
282
+ );
234
283
  },
235
284
  changeWittyWord() {
236
285
  const greetings = GLOBAL_CONFIG.aside.witty_words;
@@ -243,46 +292,64 @@ const sco = {
243
292
  this.lastWittyWord = randomGreeting;
244
293
  },
245
294
  switchDarkMode() {
246
- const isDarkMode = document.documentElement.getAttribute('data-theme') === 'dark';
247
- const newMode = isDarkMode ? 'light' : 'dark';
248
- document.documentElement.setAttribute('data-theme', newMode);
249
- utils.saveToLocal.set('theme', newMode, 0.02);
295
+ const isDarkMode =
296
+ document.documentElement.getAttribute("data-theme") === "dark";
297
+ const newMode = isDarkMode ? "light" : "dark";
298
+ document.documentElement.setAttribute("data-theme", newMode);
299
+ utils.saveToLocal.set("theme", newMode, 0.02);
250
300
  utils.snackbarShow(GLOBAL_CONFIG.lang.theme[newMode], false, 2000);
251
- if (typeof rm === 'object') rm.mode(!isDarkMode) && rm.hideRightMenu();
301
+ if (typeof rm === "object") rm.mode(!isDarkMode) && rm.hideRightMenu();
252
302
  handleThemeChange(newMode);
253
303
  },
254
- hideTodayCard: () => document.getElementById('todayCard').classList.add('hide'),
304
+ hideTodayCard: () =>
305
+ document.getElementById("todayCard").classList.add("hide"),
255
306
  toTop: () => utils.scrollToDest(0),
256
- showConsole: () => document.getElementById('console')?.classList.toggle('show', true),
257
- hideConsole: () => document.getElementById('console')?.classList.remove('show'),
307
+ showConsole: () =>
308
+ document.getElementById("console")?.classList.toggle("show", true),
309
+ hideConsole: () =>
310
+ document.getElementById("console")?.classList.remove("show"),
258
311
  refreshWaterFall() {
259
312
  const observer = new IntersectionObserver((entries) => {
260
- entries.forEach(entry => {
313
+ entries.forEach((entry) => {
261
314
  if (entry.isIntersecting) {
262
315
  setTimeout(() => {
263
316
  waterfall(entry.target).then(() => {
264
- entry.target.classList.add('show');
317
+ entry.target.classList.add("show");
265
318
  });
266
319
  }, 300);
267
320
  }
268
321
  });
269
322
  });
270
- document.querySelectorAll('.waterfall').forEach(el => observer.observe(el));
323
+ document
324
+ .querySelectorAll(".waterfall")
325
+ .forEach((el) => observer.observe(el));
271
326
  },
272
327
  addRuntime() {
273
- const el = document.getElementById('runtimeshow');
328
+ const el = document.getElementById("runtimeshow");
274
329
  if (el && GLOBAL_CONFIG.runtime) {
275
- el.innerText = utils.timeDiff(new Date(GLOBAL_CONFIG.runtime), new Date()) + GLOBAL_CONFIG.lang.day;
330
+ el.innerText =
331
+ utils.timeDiff(new Date(GLOBAL_CONFIG.runtime), new Date()) +
332
+ GLOBAL_CONFIG.lang.day;
276
333
  }
277
334
  },
278
335
  toTalk(txt) {
279
- const inputs = ["#wl-edit", ".el-textarea__inner", "#veditor", ".atk-textarea"];
280
- inputs.forEach(selector => {
336
+ const inputs = [
337
+ "#wl-edit",
338
+ ".el-textarea__inner",
339
+ "#veditor",
340
+ ".atk-textarea",
341
+ ];
342
+ inputs.forEach((selector) => {
281
343
  const el = document.querySelector(selector);
282
344
  if (el) {
283
- el.dispatchEvent(new Event('input', { bubble: true, cancelable: true }));
284
- el.value = '> ' + txt.replace(/\n/g, '\n> ') + '\n\n';
285
- utils.scrollToDest(utils.getEleTop(document.getElementById('post-comment')), 300);
345
+ el.dispatchEvent(
346
+ new Event("input", { bubble: true, cancelable: true })
347
+ );
348
+ el.value = "> " + txt.replace(/\n/g, "\n> ") + "\n\n";
349
+ utils.scrollToDest(
350
+ utils.getEleTop(document.getElementById("post-comment")),
351
+ 300
352
+ );
286
353
  el.focus();
287
354
  el.setSelectionRange(-1, -1);
288
355
  }
@@ -290,34 +357,51 @@ const sco = {
290
357
  utils.snackbarShow(GLOBAL_CONFIG.lang.totalk, false, 2000);
291
358
  },
292
359
  initbbtalk() {
293
- const bberTalkElement = document.querySelector('#bber-talk');
360
+ const bberTalkElement = document.querySelector("#bber-talk");
294
361
  if (bberTalkElement) {
295
- new Swiper('.swiper-container', {
296
- direction: 'vertical',
362
+ new Swiper(".swiper-container", {
363
+ direction: "vertical",
297
364
  loop: true,
298
365
  autoplay: {
299
366
  delay: 3000,
300
- pauseOnMouseEnter: true
367
+ pauseOnMouseEnter: true,
301
368
  },
302
369
  });
303
370
  }
304
371
  },
305
372
  addPhotoFigcaption() {
306
- document.querySelectorAll('.article-container img:not(.gallery-item img)').forEach(image => {
307
- const captionText = image.getAttribute('alt');
308
- if (captionText) {
309
- image.insertAdjacentHTML('afterend', `<div class="img-alt is-center">${utils.escapeHtml(captionText)}</div>`);
310
- }
311
- });
373
+ document
374
+ .querySelectorAll(".article-container img:not(.gallery-item img)")
375
+ .forEach((image) => {
376
+ const captionText = image.getAttribute("alt");
377
+ if (captionText) {
378
+ image.insertAdjacentHTML(
379
+ "afterend",
380
+ `<div class="img-alt is-center">${utils.escapeHtml(
381
+ captionText
382
+ )}</div>`
383
+ );
384
+ }
385
+ });
312
386
  },
313
- scrollToComment: () => utils.scrollToDest(utils.getEleTop(document.getElementById('post-comment')), 300),
387
+ scrollToComment: () =>
388
+ utils.scrollToDest(
389
+ utils.getEleTop(document.getElementById("post-comment")),
390
+ 300
391
+ ),
314
392
  setTimeState() {
315
- const el = document.getElementById('sayhi');
393
+ const el = document.getElementById("sayhi");
316
394
  if (el) {
317
395
  const hours = new Date().getHours();
318
396
  const lang = GLOBAL_CONFIG.aside.state;
319
397
 
320
- const localData = getLocalData(['twikoo', 'WALINE_USER_META', 'WALINE_USER', '_v_Cache_Meta', 'ArtalkUser']);
398
+ const localData = getLocalData([
399
+ "twikoo",
400
+ "WALINE_USER_META",
401
+ "WALINE_USER",
402
+ "_v_Cache_Meta",
403
+ "ArtalkUser",
404
+ ]);
321
405
 
322
406
  function getLocalData(keys) {
323
407
  for (let key of keys) {
@@ -327,10 +411,12 @@ const sco = {
327
411
  }
328
412
  }
329
413
  return null;
330
- };
331
- const nick = localData ? (localData.nick || localData.display_name) : null;
414
+ }
415
+ const nick = localData ? localData.nick || localData.display_name : null;
332
416
 
333
- const prefix = this.wasPageHidden ? GLOBAL_CONFIG.aside.witty_comment.back + nick : GLOBAL_CONFIG.aside.witty_comment.prefix + nick;
417
+ const prefix = this.wasPageHidden
418
+ ? GLOBAL_CONFIG.aside.witty_comment.back + nick
419
+ : GLOBAL_CONFIG.aside.witty_comment.prefix + nick;
334
420
 
335
421
  const greetings = [
336
422
  { start: 0, end: 5, text: nick ? prefix : lang.goodnight },
@@ -339,7 +425,9 @@ const sco = {
339
425
  { start: 15, end: 18, text: nick ? prefix : lang.afternoon },
340
426
  { start: 19, end: 24, text: nick ? prefix : lang.night },
341
427
  ];
342
- const greeting = greetings.find(g => hours >= g.start && hours <= g.end);
428
+ const greeting = greetings.find(
429
+ (g) => hours >= g.start && hours <= g.end
430
+ );
343
431
  el.innerText = greeting.text;
344
432
  }
345
433
  },
@@ -350,7 +438,7 @@ const sco = {
350
438
  const tag = decodedPath.split("/").slice(-2, -1)[0];
351
439
  const tagElement = document.getElementById(tag);
352
440
  if (tagElement) {
353
- document.querySelectorAll("a.select").forEach(link => {
441
+ document.querySelectorAll("a.select").forEach((link) => {
354
442
  link.classList.remove("select");
355
443
  });
356
444
  tagElement.classList.add("select");
@@ -363,8 +451,10 @@ const sco = {
363
451
  const isHomePage = currentPath === GLOBAL_CONFIG.root;
364
452
  if (categoryBar) {
365
453
  const categoryItems = categoryBar.querySelectorAll(".category-bar-item");
366
- categoryItems.forEach(item => item.classList.remove("select"));
367
- const activeItemId = isHomePage ? "category-bar-home" : currentPath.split("/").slice(-2, -1)[0];
454
+ categoryItems.forEach((item) => item.classList.remove("select"));
455
+ const activeItemId = isHomePage
456
+ ? "category-bar-home"
457
+ : currentPath.split("/").slice(-2, -1)[0];
368
458
  const activeItem = document.getElementById(activeItemId);
369
459
  if (activeItem) {
370
460
  activeItem.classList.add("select");
@@ -375,21 +465,30 @@ const sco = {
375
465
  const scrollBar = document.getElementById("category-bar-items");
376
466
  const nextElement = document.getElementById("category-bar-next");
377
467
  if (scrollBar) {
378
- const isScrollBarAtEnd = () => scrollBar.scrollLeft + scrollBar.clientWidth >= scrollBar.scrollWidth - 8;
468
+ const isScrollBarAtEnd = () =>
469
+ scrollBar.scrollLeft + scrollBar.clientWidth >=
470
+ scrollBar.scrollWidth - 8;
379
471
  const scroll = () => {
380
- scrollBar.scroll({ left: isScrollBarAtEnd() ? 0 : scrollBar.clientWidth, behavior: "smooth" });
472
+ scrollBar.scroll({
473
+ left: isScrollBarAtEnd() ? 0 : scrollBar.clientWidth,
474
+ behavior: "smooth",
475
+ });
381
476
  };
382
477
  scrollBar.addEventListener("scroll", () => {
383
478
  clearTimeout(this.timeoutId);
384
479
  this.timeoutId = setTimeout(() => {
385
- nextElement.style.transform = isScrollBarAtEnd() ? "rotate(180deg)" : "";
480
+ nextElement.style.transform = isScrollBarAtEnd()
481
+ ? "rotate(180deg)"
482
+ : "";
386
483
  }, 150);
387
484
  });
388
485
  scroll();
389
486
  }
390
487
  },
391
488
  openAllTags() {
392
- document.querySelectorAll(".card-allinfo .card-tag-cloud").forEach(tagCloudElement => tagCloudElement.classList.add("all-tags"));
489
+ document
490
+ .querySelectorAll(".card-allinfo .card-tag-cloud")
491
+ .forEach((tagCloudElement) => tagCloudElement.classList.add("all-tags"));
393
492
  document.getElementById("more-tags-btn")?.remove();
394
493
  },
395
494
  listenToPageInputPress() {
@@ -404,13 +503,16 @@ const sco = {
404
503
  return;
405
504
  }
406
505
  pageText.addEventListener("keydown", (event) => {
407
- if (event.key === 'Enter') {
506
+ if (event.key === "Enter") {
408
507
  sco.toPage();
409
508
  pjax.loadUrl(pageButton.href);
410
509
  }
411
510
  });
412
511
  pageText.addEventListener("input", () => {
413
- pageButton.classList.toggle("haveValue", pageText.value !== "" && pageText.value !== "0");
512
+ pageButton.classList.toggle(
513
+ "haveValue",
514
+ pageText.value !== "" && pageText.value !== "0"
515
+ );
414
516
  if (+pageText.value > lastPageNumber) {
415
517
  pageText.value = lastPageNumber;
416
518
  }
@@ -419,152 +521,174 @@ const sco = {
419
521
  addNavBackgroundInit() {
420
522
  const scrollTop = document.documentElement.scrollTop;
421
523
  if (scrollTop !== 0) {
422
- document.getElementById("page-header").classList.add("nav-fixed", "nav-visible");
524
+ document
525
+ .getElementById("page-header")
526
+ .classList.add("nav-fixed", "nav-visible");
423
527
  }
424
528
  },
425
529
  toPage() {
426
530
  const pageNumbers = document.querySelectorAll(".page-number");
427
- const maxPageNumber = parseInt(pageNumbers[pageNumbers.length - 1].innerHTML);
531
+ const maxPageNumber = parseInt(
532
+ pageNumbers[pageNumbers.length - 1].innerHTML
533
+ );
428
534
  const inputElement = document.getElementById("toPageText");
429
535
  const inputPageNumber = parseInt(inputElement.value);
430
- document.getElementById("toPageButton").href = (!isNaN(inputPageNumber) && inputPageNumber <= maxPageNumber && inputPageNumber > 1)
431
- ? window.location.href.replace(/\/page\/\d+\/$/, "/") + "page/" + inputPageNumber + "/"
432
- : '/';
536
+ document.getElementById("toPageButton").href =
537
+ !isNaN(inputPageNumber) &&
538
+ inputPageNumber <= maxPageNumber &&
539
+ inputPageNumber > 1
540
+ ? window.location.href.replace(/\/page\/\d+\/$/, "/") +
541
+ "page/" +
542
+ inputPageNumber +
543
+ "/"
544
+ : "/";
433
545
  },
434
546
  owoBig(owoSelector) {
435
- let owoBig = document.getElementById('owo-big');
547
+ let owoBig = document.getElementById("owo-big");
436
548
  if (!owoBig) {
437
- owoBig = document.createElement('div');
438
- owoBig.id = 'owo-big';
549
+ owoBig = document.createElement("div");
550
+ owoBig.id = "owo-big";
439
551
  document.body.appendChild(owoBig);
440
552
  }
441
- const showOwoBig = event => {
553
+ const showOwoBig = (event) => {
442
554
  const target = event.target;
443
555
  const owoItem = target.closest(owoSelector.item);
444
556
  if (owoItem && target.closest(owoSelector.body)) {
445
- const imgSrc = owoItem.querySelector('img')?.src;
557
+ const imgSrc = owoItem.querySelector("img")?.src;
446
558
  if (imgSrc) {
447
559
  owoBig.innerHTML = `<img src="${imgSrc}" style="max-width: 100%; height: auto;">`;
448
- owoBig.style.display = 'block';
560
+ owoBig.style.display = "block";
449
561
  positionOwoBig(owoItem);
450
562
  }
451
563
  }
452
564
  };
453
- const hideOwoBig = event => {
454
- if (event.target.closest(owoSelector.item) && event.target.closest(owoSelector.body)) {
455
- owoBig.style.display = 'none';
565
+ const hideOwoBig = (event) => {
566
+ if (
567
+ event.target.closest(owoSelector.item) &&
568
+ event.target.closest(owoSelector.body)
569
+ ) {
570
+ owoBig.style.display = "none";
456
571
  }
457
572
  };
458
- const positionOwoBig = owoItem => {
573
+ const positionOwoBig = (owoItem) => {
459
574
  const itemRect = owoItem.getBoundingClientRect();
460
- owoBig.style.left = `${itemRect.left - (owoBig.offsetWidth / 4)}px`;
575
+ owoBig.style.left = `${itemRect.left - owoBig.offsetWidth / 4}px`;
461
576
  owoBig.style.top = `${itemRect.top}px`;
462
577
  };
463
- document.addEventListener('mouseover', showOwoBig);
464
- document.addEventListener('mouseout', hideOwoBig);
578
+ document.addEventListener("mouseover", showOwoBig);
579
+ document.addEventListener("mouseout", hideOwoBig);
465
580
  },
466
581
  changeTimeFormat(selector) {
467
- selector.forEach(item => {
468
- const timeVal = item.getAttribute('datetime');
582
+ selector.forEach((item) => {
583
+ const timeVal = item.getAttribute("datetime");
469
584
  item.textContent = utils.diffDate(timeVal, true);
470
- item.style.display = 'inline';
585
+ item.style.display = "inline";
471
586
  });
472
587
  },
473
588
  switchComments() {
474
- const switchBtn = document.getElementById('switch-btn');
589
+ const switchBtn = document.getElementById("switch-btn");
475
590
  if (!switchBtn) return;
476
591
  let switchDone = false;
477
- const commentContainer = document.getElementById('post-comment');
592
+ const commentContainer = document.getElementById("post-comment");
478
593
  const handleSwitchBtn = () => {
479
- commentContainer.classList.toggle('move');
480
- if (!switchDone && typeof loadTwoComment === 'function') {
594
+ commentContainer.classList.toggle("move");
595
+ if (!switchDone && typeof loadTwoComment === "function") {
481
596
  switchDone = true;
482
597
  loadTwoComment();
483
598
  }
484
599
  };
485
- utils.addEventListenerPjax(switchBtn, 'click', handleSwitchBtn);
600
+ utils.addEventListenerPjax(switchBtn, "click", handleSwitchBtn);
486
601
  },
487
602
  homeTypeit() {
488
- if(typeof(home_subtitle) === 'undefined') return;
603
+ if (typeof home_subtitle === "undefined") return;
489
604
  const ty = new TypeIt(".banners-title-small", {
490
- speed: 200,
491
- waitUntilVisible: true,
492
- loop: true,
493
- lifeLike: true,
605
+ speed: 200,
606
+ waitUntilVisible: true,
607
+ loop: true,
608
+ lifeLike: true,
494
609
  });
495
- home_subtitle.forEach(item => {
496
- ty.type(item).pause(500).delete(item);
610
+ home_subtitle.forEach((item) => {
611
+ ty.type(item).pause(500).delete(item);
497
612
  });
498
613
  ty.go();
499
- }
614
+ },
500
615
  };
501
616
 
502
617
  const addHighlight = () => {
503
618
  const highlight = GLOBAL_CONFIG.highlight;
504
619
  if (!highlight) return;
505
620
  const { copy, expand, limit, syntax } = highlight;
506
- const $isPrismjs = syntax === 'prismjs';
621
+ const $isPrismjs = syntax === "prismjs";
507
622
  const $isShowTool = highlight.enable || copy || expand || limit;
508
- const expandClass = expand ? '' : 'closed';
509
- const $syntaxHighlight = syntax === 'highlight.js' ? document.querySelectorAll('figure.highlight') : document.querySelectorAll('pre[class*="language-"]');
510
-
623
+ const expandClass = expand ? "" : "closed";
624
+ const $syntaxHighlight =
625
+ syntax === "highlight.js"
626
+ ? document.querySelectorAll("figure.highlight")
627
+ : document.querySelectorAll('pre[class*="language-"]');
628
+
511
629
  if (!(($isShowTool || limit) && $syntaxHighlight.length)) return;
512
630
 
513
- const copyEle = copy ? `<i class="solitude fas fa-copy copy-button"></i>` : '<i></i>';
631
+ const copyEle = copy
632
+ ? `<i class="solitude fas fa-copy copy-button"></i>`
633
+ : "<i></i>";
514
634
  const expandEle = `<i class="solitude fas fa-angle-down expand"></i>`;
515
- const limitEle = limit ? `<i class="solitude fas fa-angles-down"></i>` : '<i></i>';
516
-
635
+ const limitEle = limit
636
+ ? `<i class="solitude fas fa-angles-down"></i>`
637
+ : "<i></i>";
638
+
517
639
  const alertInfo = (ele, text) => utils.snackbarShow(text, false, 2000);
518
-
640
+
519
641
  const copyFn = (e) => {
520
642
  const $buttonParent = e.parentNode;
521
- $buttonParent.classList.add('copy-true');
643
+ $buttonParent.classList.add("copy-true");
522
644
  const selection = window.getSelection();
523
645
  const range = document.createRange();
524
- const preCodeSelector = $isPrismjs ? 'pre code' : 'table .code pre';
525
- range.selectNodeContents($buttonParent.querySelectorAll(`${preCodeSelector}`)[0]);
646
+ const preCodeSelector = $isPrismjs ? "pre code" : "table .code pre";
647
+ range.selectNodeContents(
648
+ $buttonParent.querySelectorAll(`${preCodeSelector}`)[0]
649
+ );
526
650
  selection.removeAllRanges();
527
651
  selection.addRange(range);
528
- document.execCommand('copy');
652
+ document.execCommand("copy");
529
653
  alertInfo(e.lastChild, GLOBAL_CONFIG.lang.copy.success);
530
654
  selection.removeAllRanges();
531
- $buttonParent.classList.remove('copy-true');
655
+ $buttonParent.classList.remove("copy-true");
532
656
  };
533
657
 
534
- const expandClose = (e) => e.classList.toggle('closed');
658
+ const expandClose = (e) => e.classList.toggle("closed");
535
659
  const shrinkEle = function () {
536
- this.classList.toggle('expand-done');
660
+ this.classList.toggle("expand-done");
537
661
  };
538
662
 
539
663
  const ToolsFn = function (e) {
540
664
  const $target = e.target.classList;
541
- if ($target.contains('expand')) expandClose(this);
542
- else if ($target.contains('copy-button')) copyFn(this);
665
+ if ($target.contains("expand")) expandClose(this);
666
+ else if ($target.contains("copy-button")) copyFn(this);
543
667
  };
544
668
 
545
669
  const createEle = (lang, item, service) => {
546
670
  const fragment = document.createDocumentFragment();
547
671
  if ($isShowTool) {
548
- const captionItem = item.querySelector('figcaption');
549
- let caption = '';
672
+ const captionItem = item.querySelector("figcaption");
673
+ let caption = "";
550
674
  if (captionItem) {
551
675
  caption = `<div class="caption">${captionItem.innerHTML}</div>`;
552
676
  item.removeChild(captionItem);
553
677
  }
554
- const hlTools = document.createElement('div');
678
+ const hlTools = document.createElement("div");
555
679
  hlTools.className = `highlight-tools ${expandClass}`;
556
680
  hlTools.innerHTML = expandEle + lang + caption + copyEle;
557
- utils.addEventListenerPjax(hlTools, 'click', ToolsFn);
681
+ utils.addEventListenerPjax(hlTools, "click", ToolsFn);
558
682
  fragment.appendChild(hlTools);
559
683
  }
560
684
  if (limit && item.offsetHeight > limit + 30) {
561
- const ele = document.createElement('div');
562
- ele.className = 'code-expand-btn';
685
+ const ele = document.createElement("div");
686
+ ele.className = "code-expand-btn";
563
687
  ele.innerHTML = limitEle;
564
- utils.addEventListenerPjax(ele, 'click', shrinkEle);
688
+ utils.addEventListenerPjax(ele, "click", shrinkEle);
565
689
  fragment.appendChild(ele);
566
690
  }
567
- if (service === 'hl') {
691
+ if (service === "hl") {
568
692
  item.insertBefore(fragment, item.firstChild);
569
693
  } else {
570
694
  item.parentNode.insertBefore(fragment, item);
@@ -572,49 +696,65 @@ const addHighlight = () => {
572
696
  };
573
697
 
574
698
  if ($isPrismjs) {
575
- $syntaxHighlight.forEach(item => {
576
- const langName = item.getAttribute('data-language') || 'Code';
577
- const highlightLangEle = `<div class="code-lang">${utils.escapeHtml(langName)}</div>`;
578
- utils.wrap(item, 'figure', { class: 'highlight' });
699
+ $syntaxHighlight.forEach((item) => {
700
+ const langName = item.getAttribute("data-language") || "Code";
701
+ const highlightLangEle = `<div class="code-lang">${utils.escapeHtml(
702
+ langName
703
+ )}</div>`;
704
+ utils.wrap(item, "figure", { class: "highlight" });
579
705
  createEle(highlightLangEle, item);
580
706
  });
581
707
  } else {
582
- $syntaxHighlight.forEach(item => {
583
- let langName = item.getAttribute('class').split(' ')[1];
584
- if (langName === 'plain' || langName === undefined) langName = 'Code';
585
- const highlightLangEle = `<div class="code-lang">${utils.escapeHtml(langName)}</div>`;
586
- createEle(highlightLangEle, item, 'hl');
708
+ $syntaxHighlight.forEach((item) => {
709
+ let langName = item.getAttribute("class").split(" ")[1];
710
+ if (langName === "plain" || langName === undefined) langName = "Code";
711
+ const highlightLangEle = `<div class="code-lang">${utils.escapeHtml(
712
+ langName
713
+ )}</div>`;
714
+ createEle(highlightLangEle, item, "hl");
587
715
  });
588
716
  }
589
717
  };
590
718
 
591
719
  class toc {
592
720
  static init() {
593
- const tocContainer = document.getElementById('card-toc');
594
- if (!tocContainer || !tocContainer.querySelector('.toc a')) {
595
- tocContainer.style.display = 'none';
721
+ const tocContainer = document.getElementById("card-toc");
722
+ if (!tocContainer || !tocContainer.querySelector(".toc a")) {
723
+ tocContainer.style.display = "none";
596
724
  return;
597
725
  }
598
- const el = document.querySelectorAll('.toc a');
726
+ const el = document.querySelectorAll(".toc a");
599
727
  el.forEach((e) => {
600
- e.addEventListener('click', (event) => {
728
+ e.addEventListener("click", (event) => {
601
729
  event.preventDefault();
602
- utils.scrollToDest(utils.getEleTop(document.getElementById(decodeURI((event.target.className === 'toc-text' ? event.target.parentNode.hash : event.target.hash).replace('#', '')))), 300);
730
+ utils.scrollToDest(
731
+ utils.getEleTop(
732
+ document.getElementById(
733
+ decodeURI(
734
+ (event.target.className === "toc-text"
735
+ ? event.target.parentNode.hash
736
+ : event.target.hash
737
+ ).replace("#", "")
738
+ )
739
+ )
740
+ ),
741
+ 300
742
+ );
603
743
  });
604
744
  });
605
745
  this.active(el);
606
746
  }
607
747
 
608
748
  static active(toc) {
609
- const $article = document.querySelector('.article-container');
610
- const $tocContent = document.getElementById('toc-content');
611
- const list = $article.querySelectorAll('h1,h2,h3,h4,h5,h6');
612
- let detectItem = '';
749
+ const $article = document.querySelector(".article-container");
750
+ const $tocContent = document.getElementById("toc-content");
751
+ const list = $article.querySelectorAll("h1,h2,h3,h4,h5,h6");
752
+ let detectItem = "";
613
753
 
614
754
  const autoScroll = (el) => {
615
755
  const activePosition = el.getBoundingClientRect().top;
616
756
  const sidebarScrollTop = $tocContent.scrollTop;
617
- if (activePosition > (document.documentElement.clientHeight - 100)) {
757
+ if (activePosition > document.documentElement.clientHeight - 100) {
618
758
  $tocContent.scrollTop = sidebarScrollTop + 150;
619
759
  }
620
760
  if (activePosition < 100) {
@@ -624,7 +764,7 @@ class toc {
624
764
 
625
765
  const findHeadPosition = (top) => {
626
766
  if (top === 0) return false;
627
- let currentIndex = '';
767
+ let currentIndex = "";
628
768
  list.forEach((ele, index) => {
629
769
  if (top > utils.getEleTop(ele) - 80) {
630
770
  currentIndex = index;
@@ -632,16 +772,16 @@ class toc {
632
772
  });
633
773
  if (detectItem === currentIndex) return;
634
774
  detectItem = currentIndex;
635
- document.querySelectorAll('.toc .active').forEach((i) => {
636
- i.classList.remove('active');
775
+ document.querySelectorAll(".toc .active").forEach((i) => {
776
+ i.classList.remove("active");
637
777
  });
638
778
  const activeitem = toc[detectItem];
639
779
  if (activeitem) {
640
780
  let parent = toc[detectItem].parentNode;
641
- activeitem.classList.add('active');
781
+ activeitem.classList.add("active");
642
782
  autoScroll(activeitem);
643
- for (; !parent.matches('.toc'); parent = parent.parentNode) {
644
- if (parent.matches('li')) parent.classList.add('active');
783
+ for (; !parent.matches(".toc"); parent = parent.parentNode) {
784
+ if (parent.matches("li")) parent.classList.add("active");
645
785
  }
646
786
  }
647
787
  };
@@ -650,49 +790,43 @@ class toc {
650
790
  const currentTop = window.scrollY || document.documentElement.scrollTop;
651
791
  findHeadPosition(currentTop);
652
792
  }, 100);
653
- window.addEventListener('scroll', tocScrollFn);
793
+ window.addEventListener("scroll", tocScrollFn);
654
794
  }
655
795
  }
656
796
 
657
797
  class tabs {
658
798
  static init() {
659
799
  this.clickFnOfTabs();
660
- this.backToTop();
661
800
  }
662
801
 
663
802
  static clickFnOfTabs() {
664
- document.querySelectorAll('.article-container .tab > button').forEach((item) => {
665
- item.addEventListener('click', function () {
666
- const $tabItem = this.parentNode;
667
- if (!$tabItem.classList.contains('active')) {
668
- const $tabContent = $tabItem.parentNode.nextElementSibling;
669
- const $siblings = utils.siblings($tabItem, '.active')[0];
670
- $siblings && $siblings.classList.remove('active');
671
- $tabItem.classList.add('active');
672
- const tabId = this.getAttribute('data-href').replace('#', '');
673
- [...$tabContent.children].forEach((item) => {
674
- item.classList.toggle('active', item.id === tabId);
675
- });
676
- }
677
- });
678
- });
679
- }
680
-
681
- static backToTop() {
682
- document.querySelectorAll('.article-container .tabs .tab-to-top').forEach((item) => {
683
- item.addEventListener('click', function () {
684
- utils.scrollToDest(utils.getEleTop(this.parentElement.parentElement.parentNode), 300);
803
+ document
804
+ .querySelectorAll(".article-container .tab > button")
805
+ .forEach((item) => {
806
+ item.addEventListener("click", function () {
807
+ const $tabItem = this.parentNode;
808
+ if (!$tabItem.classList.contains("active")) {
809
+ const $tabContent = $tabItem.parentNode.nextElementSibling;
810
+ const $siblings = utils.siblings($tabItem, ".active")[0];
811
+ $siblings && $siblings.classList.remove("active");
812
+ $tabItem.classList.add("active");
813
+ const tabId = this.getAttribute("data-href").replace("#", "");
814
+ [...$tabContent.children].forEach((item) => {
815
+ item.classList.toggle("active", item.id === tabId);
816
+ });
817
+ }
818
+ });
685
819
  });
686
- });
687
820
  }
688
821
 
689
822
  static lureAddListener() {
690
823
  if (!GLOBAL_CONFIG.lure) return;
691
824
  const title = document.title;
692
- document.addEventListener('visibilitychange', () => {
825
+ document.addEventListener("visibilitychange", () => {
693
826
  const { lure } = GLOBAL_CONFIG;
694
- document.title = document.visibilityState === 'hidden' ? lure.jump : lure.back;
695
- if (document.visibilityState === 'visible') {
827
+ document.title =
828
+ document.visibilityState === "hidden" ? lure.jump : lure.back;
829
+ if (document.visibilityState === "visible") {
696
830
  setTimeout(() => {
697
831
  document.title = title;
698
832
  }, 2000);
@@ -703,16 +837,30 @@ class tabs {
703
837
  static expireAddListener() {
704
838
  const { expire } = GLOBAL_CONFIG;
705
839
  if (!expire) return;
706
- const list = document.querySelectorAll('.post-meta-date time');
707
- const post_date = list.length ? list[list.length - 1] : document.querySelector('.datetime');
840
+ const list = document.querySelectorAll(".post-meta-date time");
841
+ const post_date = list.length
842
+ ? list[list.length - 1]
843
+ : document.querySelector(".datetime");
708
844
  if (!post_date) return;
709
- const ex = Math.ceil((new Date().getTime() - new Date(post_date.getAttribute('datetime')).getTime()) / 1000 / 60 / 60 / 24);
845
+ const ex = Math.ceil(
846
+ (new Date().getTime() -
847
+ new Date(post_date.getAttribute("datetime")).getTime()) /
848
+ 1000 /
849
+ 60 /
850
+ 60 /
851
+ 24
852
+ );
710
853
  if (expire.time > ex) return;
711
- const ele = document.createElement('div');
712
- ele.className = 'expire';
713
- ele.innerHTML = `<i class="solitude fas fa-circle-exclamation"></i>${expire.text_prev}${-(expire.time - ex)}${expire.text_next}`;
714
- const articleContainer = document.querySelector('.article-container');
715
- articleContainer.insertAdjacentElement(expire.position === 'top' ? 'afterbegin' : 'beforeend', ele);
854
+ const ele = document.createElement("div");
855
+ ele.className = "expire";
856
+ ele.innerHTML = `<i class="solitude fas fa-circle-exclamation"></i>${
857
+ expire.text_prev
858
+ }${-(expire.time - ex)}${expire.text_next}`;
859
+ const articleContainer = document.querySelector(".article-container");
860
+ articleContainer.insertAdjacentElement(
861
+ expire.position === "top" ? "afterbegin" : "beforeend",
862
+ ele
863
+ );
716
864
  }
717
865
  }
718
866
 
@@ -720,23 +868,30 @@ const scrollFnToDo = () => {
720
868
  const { toc } = PAGE_CONFIG;
721
869
 
722
870
  if (toc) {
723
- const $cardTocLayout = document.getElementById('card-toc');
724
- const $cardToc = $cardTocLayout.querySelector('.toc-content');
725
- const $tocLink = $cardToc.querySelectorAll('.toc-link');
726
- const $tocPercentage = $cardTocLayout.querySelector('.toc-percentage');
727
- const isExpand = $cardToc.classList.contains('is-expand');
728
-
729
- const tocItemClickFn = e => {
730
- const target = e.target.closest('.toc-link');
871
+ const $cardTocLayout = document.getElementById("card-toc");
872
+ const $cardToc = $cardTocLayout.querySelector(".toc-content");
873
+ const $tocLink = $cardToc.querySelectorAll(".toc-link");
874
+ const $tocPercentage = $cardTocLayout.querySelector(".toc-percentage");
875
+ const isExpand = $cardToc.classList.contains("is-expand");
876
+
877
+ const tocItemClickFn = (e) => {
878
+ const target = e.target.closest(".toc-link");
731
879
  if (!target) return;
732
880
 
733
881
  e.preventDefault();
734
- utils.scrollToDest(utils.getEleTop(document.getElementById(decodeURI(target.getAttribute('href')).replace('#', ''))), 300);
882
+ utils.scrollToDest(
883
+ utils.getEleTop(
884
+ document.getElementById(
885
+ decodeURI(target.getAttribute("href")).replace("#", "")
886
+ )
887
+ ),
888
+ 300
889
+ );
735
890
  if (window.innerWidth < 900) {
736
- $cardTocLayout.classList.remove('open');
891
+ $cardTocLayout.classList.remove("open");
737
892
  }
738
893
  };
739
- utils.addEventListenerPjax($cardToc, 'click', tocItemClickFn);
894
+ utils.addEventListenerPjax($cardToc, "click", tocItemClickFn);
740
895
  }
741
896
  };
742
897
 
@@ -745,24 +900,50 @@ const forPostFn = () => {
745
900
  };
746
901
 
747
902
  window.refreshFn = () => {
748
- const { is_home, is_page, page, is_post } = PAGE_CONFIG;
749
- const { runtime, lazyload, lightbox, randomlink, covercolor, post_ai, lure, expire } = GLOBAL_CONFIG;
750
- const timeSelector = (is_home ? '.post-meta-date time' : is_post ? '.post-meta-date time' : '.datetime') + ', .webinfo-item time';
751
- document.body.setAttribute('data-type', page);
903
+ const { is_home, is_page, page, is_post, ai_text } = PAGE_CONFIG;
904
+ const { runtime, lazyload, lightbox, randomlink, covercolor, lure, expire } =
905
+ GLOBAL_CONFIG;
906
+ const timeSelector =
907
+ (is_home
908
+ ? ".post-meta-date time"
909
+ : is_post
910
+ ? ".post-meta-date time"
911
+ : ".datetime") + ", .webinfo-item time";
912
+ document.body.setAttribute("data-type", page);
752
913
  sco.changeTimeFormat(document.querySelectorAll(timeSelector));
753
914
  runtime && sco.addRuntime();
754
- [scrollFn, sidebarFn, sco.addPhotoFigcaption, sco.setTimeState, sco.tagPageActive, sco.categoriesBarActive, sco.listenToPageInputPress, sco.addNavBackgroundInit, sco.refreshWaterFall].forEach(fn => fn());
915
+ [
916
+ scrollFn,
917
+ sidebarFn,
918
+ sco.addPhotoFigcaption,
919
+ sco.setTimeState,
920
+ sco.tagPageActive,
921
+ sco.categoriesBarActive,
922
+ sco.listenToPageInputPress,
923
+ sco.addNavBackgroundInit,
924
+ sco.refreshWaterFall,
925
+ ].forEach((fn) => fn());
755
926
  lazyload.enable && utils.lazyloadImg();
756
- lightbox && utils.lightbox(document.querySelectorAll(".article-container img:not(.flink-avatar,.gallery-group img, .no-lightbox)"));
927
+ lightbox &&
928
+ utils.lightbox(
929
+ document.querySelectorAll(
930
+ ".article-container img:not(.flink-avatar,.gallery-group img, .no-lightbox)"
931
+ )
932
+ );
757
933
  randomlink && randomLinksList();
758
- post_ai && is_post && ai.init();
934
+ if (is_post) {
935
+ if (ai_text) {
936
+ ai.init();
937
+ }
938
+ }
759
939
  sco.switchComments();
760
940
  initObserver();
761
941
  if (is_home) {
762
942
  showTodayCard();
763
943
  sco.homeTypeit();
764
944
  }
765
- typeof updatePostsBasedOnComments === 'function' && updatePostsBasedOnComments();
945
+ typeof updatePostsBasedOnComments === "function" &&
946
+ updatePostsBasedOnComments();
766
947
  if (is_post || is_page) {
767
948
  addHighlight();
768
949
  tabs.init();
@@ -773,30 +954,39 @@ window.refreshFn = () => {
773
954
  if (covercolor.enable) coverColor();
774
955
  if (PAGE_CONFIG.toc) toc.init();
775
956
  if (lure) tabs.lureAddListener();
776
- page === 'music' && initializeMusicPlayer();
957
+ page === "music" && initializeMusicPlayer();
777
958
  forPostFn();
778
959
  };
779
960
 
780
- document.addEventListener('DOMContentLoaded', () => {
781
- [addCopyright, window.refreshFn, asideStatus, () => window.onscroll = percent, sco.initConsoleState].forEach(fn => fn());
961
+ document.addEventListener("DOMContentLoaded", () => {
962
+ [
963
+ addCopyright,
964
+ window.refreshFn,
965
+ asideStatus,
966
+ () => (window.onscroll = percent),
967
+ sco.initConsoleState,
968
+ ].forEach((fn) => fn());
782
969
  });
783
970
 
784
- document.addEventListener('visibilitychange', () => {
971
+ document.addEventListener("visibilitychange", () => {
785
972
  if (document.hidden) {
786
973
  sco.wasPageHidden = true;
787
974
  }
788
975
  });
789
976
 
790
- window.onkeydown = e => {
977
+ window.onkeydown = (e) => {
791
978
  const { code, ctrlKey, shiftKey } = e;
792
- if (code === 'F12' || (ctrlKey && shiftKey && (code === 'KeyI' || code === 'KeyC'))) {
979
+ if (
980
+ code === "F12" ||
981
+ (ctrlKey && shiftKey && (code === "KeyI" || code === "KeyC"))
982
+ ) {
793
983
  utils.snackbarShow(GLOBAL_CONFIG.lang.f12, false, 3000);
794
984
  }
795
- if (code === 'Escape') {
985
+ if (code === "Escape") {
796
986
  sco.hideConsole();
797
987
  }
798
988
  };
799
989
 
800
- document.addEventListener('copy', () => {
990
+ document.addEventListener("copy", () => {
801
991
  utils.snackbarShow(GLOBAL_CONFIG.lang.copy.success, false, 3000);
802
992
  });