hexo-theme-redefine-x 2.8.5

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 (319) hide show
  1. package/.github/ISSUE_TEMPLATE/bug-chinese.yml +115 -0
  2. package/.github/ISSUE_TEMPLATE/bug-english.yml +106 -0
  3. package/.github/ISSUE_TEMPLATE/enhancement-chinese.yml +55 -0
  4. package/.github/ISSUE_TEMPLATE/enhancement-english.yml +55 -0
  5. package/.github/workflows/build-and-commit.yml +49 -0
  6. package/.github/workflows/npm-publish.yml +34 -0
  7. package/.github/workflows/stale-issues.yml +20 -0
  8. package/CHANGELOG_REDEFINE_X.md +236 -0
  9. package/CODE_OF_CONDUCT.md +128 -0
  10. package/CONTRIBUTING.md +51 -0
  11. package/DONATION.md +82 -0
  12. package/LICENSE +674 -0
  13. package/README.md +135 -0
  14. package/README_zh-CN.md +138 -0
  15. package/README_zh-TW.md +137 -0
  16. package/TODO.md +215 -0
  17. package/_config.yml +489 -0
  18. package/languages/en.yml +93 -0
  19. package/languages/es.yml +92 -0
  20. package/languages/fr.yml +92 -0
  21. package/languages/ja.yml +92 -0
  22. package/languages/zh-CN.yml +95 -0
  23. package/languages/zh-TW.yml +94 -0
  24. package/layout/404.ejs +1 -0
  25. package/layout/archive.ejs +1 -0
  26. package/layout/category.ejs +1 -0
  27. package/layout/components/comments/comment.ejs +22 -0
  28. package/layout/components/comments/giscus.ejs +42 -0
  29. package/layout/components/comments/gitalk.ejs +47 -0
  30. package/layout/components/comments/twikoo.ejs +50 -0
  31. package/layout/components/comments/waline.ejs +34 -0
  32. package/layout/components/footer/footer.ejs +99 -0
  33. package/layout/components/header/head.ejs +222 -0
  34. package/layout/components/header/navbar.ejs +163 -0
  35. package/layout/components/header/preloader.ejs +148 -0
  36. package/layout/components/header/progress-bar.ejs +12 -0
  37. package/layout/components/plugins/aplayer.ejs +3 -0
  38. package/layout/components/scripts.ejs +90 -0
  39. package/layout/components/sidebar/author.ejs +6 -0
  40. package/layout/components/sidebar/avatar.ejs +3 -0
  41. package/layout/components/sidebar/statistics.ejs +14 -0
  42. package/layout/components/swup.ejs +27 -0
  43. package/layout/index.ejs +1 -0
  44. package/layout/layout.ejs +13 -0
  45. package/layout/page.ejs +57 -0
  46. package/layout/pages/archive/archive.ejs +3 -0
  47. package/layout/pages/bookmarks/bookmarks.ejs +68 -0
  48. package/layout/pages/category/categories.ejs +11 -0
  49. package/layout/pages/category/category-detail.ejs +6 -0
  50. package/layout/pages/friends/friends-link.ejs +59 -0
  51. package/layout/pages/home/home-article.ejs +52 -0
  52. package/layout/pages/home/home-background.ejs +33 -0
  53. package/layout/pages/home/home-banner.ejs +234 -0
  54. package/layout/pages/home/home-content.ejs +62 -0
  55. package/layout/pages/home/home-sidebar.ejs +78 -0
  56. package/layout/pages/masonry/masonry.ejs +28 -0
  57. package/layout/pages/notfound/notfound.ejs +8 -0
  58. package/layout/pages/page-template.ejs +23 -0
  59. package/layout/pages/post/article-content.ejs +153 -0
  60. package/layout/pages/post/article-copyright.ejs +69 -0
  61. package/layout/pages/post/article-info.ejs +78 -0
  62. package/layout/pages/post/post-tools.ejs +17 -0
  63. package/layout/pages/post/toc.ejs +15 -0
  64. package/layout/pages/shuoshuo/essays.ejs +23 -0
  65. package/layout/pages/tag/tag-detail.ejs +6 -0
  66. package/layout/pages/tag/tags.ejs +24 -0
  67. package/layout/post.ejs +1 -0
  68. package/layout/tag.ejs +1 -0
  69. package/layout/tags.ejs +1 -0
  70. package/layout/utils/image-viewer.ejs +3 -0
  71. package/layout/utils/local-search.ejs +20 -0
  72. package/layout/utils/paginator.ejs +8 -0
  73. package/layout/utils/posts-list.ejs +28 -0
  74. package/layout/utils/side-tools.ejs +51 -0
  75. package/package.json +45 -0
  76. package/scripts/config-export.js +66 -0
  77. package/scripts/data-handle.js +37 -0
  78. package/scripts/events/404.js +16 -0
  79. package/scripts/events/welcome.js +141 -0
  80. package/scripts/filters/delete-mask-handle.js +27 -0
  81. package/scripts/filters/encrypt.js +202 -0
  82. package/scripts/filters/img-handle.js +9 -0
  83. package/scripts/filters/lazyload-handle.js +350 -0
  84. package/scripts/filters/lib/hbe.default.js +15 -0
  85. package/scripts/filters/link-handle.js +42 -0
  86. package/scripts/filters/stylus-handle.js +9 -0
  87. package/scripts/filters/table-handle.js +11 -0
  88. package/scripts/helpers/meta-helpers.js +38 -0
  89. package/scripts/helpers/page-helpers.js +153 -0
  90. package/scripts/helpers/recommendation-helpers.js +367 -0
  91. package/scripts/helpers/theme-helpers.js +251 -0
  92. package/scripts/helpers/waline-helpers.js +33 -0
  93. package/scripts/modules/btn.js +85 -0
  94. package/scripts/modules/btns.js +71 -0
  95. package/scripts/modules/folding.js +34 -0
  96. package/scripts/modules/note-large.js +72 -0
  97. package/scripts/modules/note.js +64 -0
  98. package/scripts/modules/tabs.js +99 -0
  99. package/source/assets/hbe.style.css +220 -0
  100. package/source/assets/odometer-theme-minimal.css +81 -0
  101. package/source/css/build/tailwind.css +2 -0
  102. package/source/css/common/animated.styl +71 -0
  103. package/source/css/common/basic.styl +239 -0
  104. package/source/css/common/codeblock/code-block.styl +158 -0
  105. package/source/css/common/codeblock/code-theme.styl +82 -0
  106. package/source/css/common/codeblock/highlight.styl +189 -0
  107. package/source/css/common/codeblock/hljs-themes/dark/a11y-dark.styl +18 -0
  108. package/source/css/common/codeblock/hljs-themes/dark/agate.styl +18 -0
  109. package/source/css/common/codeblock/hljs-themes/dark/atom-one-dark.styl +18 -0
  110. package/source/css/common/codeblock/hljs-themes/dark/github-dark.styl +18 -0
  111. package/source/css/common/codeblock/hljs-themes/dark/monokai-sublime.styl +18 -0
  112. package/source/css/common/codeblock/hljs-themes/dark/night-owl.styl +18 -0
  113. package/source/css/common/codeblock/hljs-themes/dark/nord.styl +18 -0
  114. package/source/css/common/codeblock/hljs-themes/dark/tokyo-night-dark.styl +18 -0
  115. package/source/css/common/codeblock/hljs-themes/dark/vs2015.styl +18 -0
  116. package/source/css/common/codeblock/hljs-themes/light/atom-one-light.styl +18 -0
  117. package/source/css/common/codeblock/hljs-themes/light/default.styl +18 -0
  118. package/source/css/common/codeblock/hljs-themes/light/github.styl +18 -0
  119. package/source/css/common/colors.styl +112 -0
  120. package/source/css/common/markdown.styl +337 -0
  121. package/source/css/common/redefine-theme.styl +65 -0
  122. package/source/css/common/theme.styl +72 -0
  123. package/source/css/common/variables.styl +145 -0
  124. package/source/css/layout/_modules/aplayer.styl +799 -0
  125. package/source/css/layout/_modules/buttons.styl +42 -0
  126. package/source/css/layout/_modules/folding.styl +180 -0
  127. package/source/css/layout/_modules/notes.styl +181 -0
  128. package/source/css/layout/_modules/tabs.styl +105 -0
  129. package/source/css/layout/_partials/404.styl +14 -0
  130. package/source/css/layout/_partials/archive-list.styl +49 -0
  131. package/source/css/layout/_partials/article-copyright-info.styl +27 -0
  132. package/source/css/layout/_partials/article-meta-info.styl +62 -0
  133. package/source/css/layout/_partials/comments/comment.styl +11 -0
  134. package/source/css/layout/_partials/comments/gitalk.styl +529 -0
  135. package/source/css/layout/_partials/comments/twikoo.styl +62 -0
  136. package/source/css/layout/_partials/comments/waline.styl +1151 -0
  137. package/source/css/layout/_partials/footer.styl +59 -0
  138. package/source/css/layout/_partials/home-banner.styl +48 -0
  139. package/source/css/layout/_partials/image-viewer.styl +37 -0
  140. package/source/css/layout/_partials/local-search.styl +137 -0
  141. package/source/css/layout/_partials/navbar.styl +309 -0
  142. package/source/css/layout/_partials/page-template.styl +147 -0
  143. package/source/css/layout/_partials/paginator.styl +65 -0
  144. package/source/css/layout/_partials/post-tools.styl +43 -0
  145. package/source/css/layout/_partials/progress-bar.styl +33 -0
  146. package/source/css/layout/_partials/side-tools.styl +87 -0
  147. package/source/css/layout/_partials/tagcloud.styl +136 -0
  148. package/source/css/layout/_partials/toc.styl +105 -0
  149. package/source/css/layout/animations.styl +42 -0
  150. package/source/css/layout/archive-content.styl +8 -0
  151. package/source/css/layout/article-content.styl +257 -0
  152. package/source/css/layout/bookmarks.styl +8 -0
  153. package/source/css/layout/category-content.styl +21 -0
  154. package/source/css/layout/category-list.styl +119 -0
  155. package/source/css/layout/home-content.styl +114 -0
  156. package/source/css/layout/home-sidebar.styl +126 -0
  157. package/source/css/layout/page.styl +144 -0
  158. package/source/css/layout/tag-content.styl +30 -0
  159. package/source/css/style.styl +26 -0
  160. package/source/css/tailwind.source.css +236 -0
  161. package/source/fontawesome/all.min.css +6 -0
  162. package/source/fontawesome/brands.min.css +6 -0
  163. package/source/fontawesome/duotone.min.css +6 -0
  164. package/source/fontawesome/fontawesome.min.css +6 -0
  165. package/source/fontawesome/light.min.css +6 -0
  166. package/source/fontawesome/regular.min.css +6 -0
  167. package/source/fontawesome/sharp-solid.min.css +6 -0
  168. package/source/fontawesome/solid.min.css +6 -0
  169. package/source/fontawesome/svg-with-js.min.css +6 -0
  170. package/source/fontawesome/thin.min.css +6 -0
  171. package/source/fontawesome/v4-font-face.min.css +6 -0
  172. package/source/fontawesome/v4-shims.min.css +6 -0
  173. package/source/fontawesome/v5-font-face.min.css +6 -0
  174. package/source/fonts/Chillax/Chillax-Variable.eot +0 -0
  175. package/source/fonts/Chillax/Chillax-Variable.ttf +0 -0
  176. package/source/fonts/Chillax/Chillax-Variable.woff +0 -0
  177. package/source/fonts/Chillax/Chillax-Variable.woff2 +0 -0
  178. package/source/fonts/Chillax/chillax.css +39 -0
  179. package/source/fonts/Geist/GeistVF.ttf +0 -0
  180. package/source/fonts/Geist/GeistVF.woff +0 -0
  181. package/source/fonts/Geist/GeistVF.woff2 +0 -0
  182. package/source/fonts/Geist/geist.css +16 -0
  183. package/source/fonts/GeistMono/GeistMonoVF.ttf +0 -0
  184. package/source/fonts/GeistMono/GeistMonoVF.woff +0 -0
  185. package/source/fonts/GeistMono/GeistMonoVF.woff2 +0 -0
  186. package/source/fonts/GeistMono/geist-mono.css +16 -0
  187. package/source/images/bookmark-placeholder.svg +9 -0
  188. package/source/images/loading.svg +5 -0
  189. package/source/images/redefine-avatar.svg +1 -0
  190. package/source/images/redefine-favicon.svg +1 -0
  191. package/source/images/redefine-logo.svg +1 -0
  192. package/source/images/redefine-logo.webp +0 -0
  193. package/source/images/redefine-og.webp +0 -0
  194. package/source/images/wallhaven-wqery6-dark.webp +0 -0
  195. package/source/images/wallhaven-wqery6-light.webp +0 -0
  196. package/source/js/build/layouts/bookmarkNav.js +2 -0
  197. package/source/js/build/layouts/bookmarkNav.js.map +1 -0
  198. package/source/js/build/layouts/categoryList.js +2 -0
  199. package/source/js/build/layouts/categoryList.js.map +1 -0
  200. package/source/js/build/layouts/essays.js +2 -0
  201. package/source/js/build/layouts/essays.js.map +1 -0
  202. package/source/js/build/layouts/lazyload.js +2 -0
  203. package/source/js/build/layouts/lazyload.js.map +1 -0
  204. package/source/js/build/layouts/navbarShrink.js +2 -0
  205. package/source/js/build/layouts/navbarShrink.js.map +1 -0
  206. package/source/js/build/layouts/toc.js +2 -0
  207. package/source/js/build/layouts/toc.js.map +1 -0
  208. package/source/js/build/libs/APlayer.min.js +2 -0
  209. package/source/js/build/libs/Swup.min.js +2 -0
  210. package/source/js/build/libs/SwupPreloadPlugin.min.js +1 -0
  211. package/source/js/build/libs/SwupProgressPlugin.min.js +1 -0
  212. package/source/js/build/libs/SwupScriptsPlugin.min.js +1 -0
  213. package/source/js/build/libs/SwupScrollPlugin.min.js +1 -0
  214. package/source/js/build/libs/SwupSlideTheme.min.js +1 -0
  215. package/source/js/build/libs/Typed.min.js +10 -0
  216. package/source/js/build/libs/anime.min.js +8 -0
  217. package/source/js/build/libs/mermaid.min.js +2314 -0
  218. package/source/js/build/libs/minimasonry.min.js +1 -0
  219. package/source/js/build/libs/moment-with-locales.min.js +2 -0
  220. package/source/js/build/libs/moment.min.js +2 -0
  221. package/source/js/build/libs/odometer.min.js +2 -0
  222. package/source/js/build/libs/pangu.min.js +9 -0
  223. package/source/js/build/libs/pjax.min.js +1 -0
  224. package/source/js/build/libs/waline.js +84 -0
  225. package/source/js/build/main.js +2 -0
  226. package/source/js/build/main.js.map +1 -0
  227. package/source/js/build/plugins/aplayer.js +2 -0
  228. package/source/js/build/plugins/aplayer.js.map +1 -0
  229. package/source/js/build/plugins/hbe.js +2 -0
  230. package/source/js/build/plugins/hbe.js.map +1 -0
  231. package/source/js/build/plugins/masonry.js +2 -0
  232. package/source/js/build/plugins/masonry.js.map +1 -0
  233. package/source/js/build/plugins/mermaid.js +2 -0
  234. package/source/js/build/plugins/mermaid.js.map +1 -0
  235. package/source/js/build/plugins/pangu.js +2 -0
  236. package/source/js/build/plugins/pangu.js.map +1 -0
  237. package/source/js/build/plugins/tabs.js +2 -0
  238. package/source/js/build/plugins/tabs.js.map +1 -0
  239. package/source/js/build/plugins/typed.js +2 -0
  240. package/source/js/build/plugins/typed.js.map +1 -0
  241. package/source/js/build/tools/codeBlock.js +2 -0
  242. package/source/js/build/tools/codeBlock.js.map +1 -0
  243. package/source/js/build/tools/imageViewer.js +2 -0
  244. package/source/js/build/tools/imageViewer.js.map +1 -0
  245. package/source/js/build/tools/lightDarkSwitch.js +2 -0
  246. package/source/js/build/tools/lightDarkSwitch.js.map +1 -0
  247. package/source/js/build/tools/localSearch.js +2 -0
  248. package/source/js/build/tools/localSearch.js.map +1 -0
  249. package/source/js/build/tools/runtime.js +2 -0
  250. package/source/js/build/tools/runtime.js.map +1 -0
  251. package/source/js/build/tools/scrollTopBottom.js +2 -0
  252. package/source/js/build/tools/scrollTopBottom.js.map +1 -0
  253. package/source/js/build/tools/tocToggle.js +2 -0
  254. package/source/js/build/tools/tocToggle.js.map +1 -0
  255. package/source/js/build/utils.js +2 -0
  256. package/source/js/build/utils.js.map +1 -0
  257. package/source/js/build.js +148 -0
  258. package/source/js/layouts/bookmarkNav.js +65 -0
  259. package/source/js/layouts/categoryList.js +53 -0
  260. package/source/js/layouts/essays.js +25 -0
  261. package/source/js/layouts/lazyload.js +199 -0
  262. package/source/js/layouts/navbarShrink.js +135 -0
  263. package/source/js/layouts/toc.js +115 -0
  264. package/source/js/libs/APlayer.min.js +2 -0
  265. package/source/js/libs/APlayer.min.js.map +1 -0
  266. package/source/js/libs/Swup.min.js +2 -0
  267. package/source/js/libs/Swup.min.js.map +1 -0
  268. package/source/js/libs/SwupPreloadPlugin.min.js +1 -0
  269. package/source/js/libs/SwupPreloadPlugin.min.js.map +1 -0
  270. package/source/js/libs/SwupProgressPlugin.min.js +1 -0
  271. package/source/js/libs/SwupScriptsPlugin.min.js +1 -0
  272. package/source/js/libs/SwupScrollPlugin.min.js +1 -0
  273. package/source/js/libs/SwupScrollPlugin.min.js.map +1 -0
  274. package/source/js/libs/SwupSlideTheme.min.js +1 -0
  275. package/source/js/libs/Typed.min.js +10 -0
  276. package/source/js/libs/anime.min.js +8 -0
  277. package/source/js/libs/mermaid.min.js +2314 -0
  278. package/source/js/libs/mermaid.min.js.map +7 -0
  279. package/source/js/libs/minimasonry.min.js +1 -0
  280. package/source/js/libs/moment-with-locales.min.js +2 -0
  281. package/source/js/libs/moment.min.js +2 -0
  282. package/source/js/libs/odometer.min.js +2 -0
  283. package/source/js/libs/pangu.min.js +9 -0
  284. package/source/js/libs/pjax.min.js +1 -0
  285. package/source/js/libs/waline.js +84 -0
  286. package/source/js/libs/waline.js.map +1 -0
  287. package/source/js/main.js +95 -0
  288. package/source/js/plugins/aplayer.js +33 -0
  289. package/source/js/plugins/hbe.js +350 -0
  290. package/source/js/plugins/masonry.js +115 -0
  291. package/source/js/plugins/mermaid.js +7 -0
  292. package/source/js/plugins/pangu.js +12 -0
  293. package/source/js/plugins/tabs.js +29 -0
  294. package/source/js/plugins/typed.js +62 -0
  295. package/source/js/tools/codeBlock.js +48 -0
  296. package/source/js/tools/imageViewer.js +194 -0
  297. package/source/js/tools/lightDarkSwitch.js +165 -0
  298. package/source/js/tools/localSearch.js +327 -0
  299. package/source/js/tools/runtime.js +28 -0
  300. package/source/js/tools/scrollTopBottom.js +34 -0
  301. package/source/js/tools/tocToggle.js +58 -0
  302. package/source/js/utils.js +383 -0
  303. package/source/webfonts/fa-brands-400.ttf +0 -0
  304. package/source/webfonts/fa-brands-400.woff2 +0 -0
  305. package/source/webfonts/fa-duotone-900.ttf +0 -0
  306. package/source/webfonts/fa-duotone-900.woff2 +0 -0
  307. package/source/webfonts/fa-light-300.ttf +0 -0
  308. package/source/webfonts/fa-light-300.woff2 +0 -0
  309. package/source/webfonts/fa-regular-400.ttf +0 -0
  310. package/source/webfonts/fa-regular-400.woff2 +0 -0
  311. package/source/webfonts/fa-sharp-solid-900.ttf +0 -0
  312. package/source/webfonts/fa-sharp-solid-900.woff2 +0 -0
  313. package/source/webfonts/fa-solid-900.ttf +0 -0
  314. package/source/webfonts/fa-solid-900.woff2 +0 -0
  315. package/source/webfonts/fa-thin-100.ttf +0 -0
  316. package/source/webfonts/fa-thin-100.woff2 +0 -0
  317. package/source/webfonts/fa-v4compatibility.ttf +0 -0
  318. package/source/webfonts/fa-v4compatibility.woff2 +0 -0
  319. package/vercel.json +7 -0
@@ -0,0 +1,383 @@
1
+ /* utils function */
2
+ import { navbarShrink } from "./layouts/navbarShrink.js";
3
+ import { initTOC } from "./layouts/toc.js";
4
+ import { main } from "./main.js";
5
+ import imageViewer from "./tools/imageViewer.js";
6
+
7
+ export const navigationState = {
8
+ isNavigating: false,
9
+ };
10
+
11
+ export default function initUtils() {
12
+ const utils = {
13
+ html_root_dom: document.querySelector("html"),
14
+ pageContainer_dom: document.querySelector(".page-container"),
15
+ pageTop_dom: document.querySelector(".main-content-header"),
16
+ homeBanner_dom: document.querySelector(".home-banner-container"),
17
+ homeBannerBackground_dom: document.querySelector(".home-banner-background"),
18
+ scrollProgressBar_dom: document.querySelector(".scroll-progress-bar"),
19
+ pjaxProgressBar_dom: document.querySelector(".pjax-progress-bar"),
20
+ backToTopButton_dom: document.querySelector(".tool-scroll-to-top"),
21
+ toolsList: document.querySelector(".hidden-tools-list"),
22
+ toggleButton: document.querySelector(".toggle-tools-list"),
23
+
24
+ innerHeight: window.innerHeight,
25
+ pjaxProgressBarTimer: null,
26
+ prevScrollValue: 0,
27
+ fontSizeLevel: 0,
28
+ triggerViewHeight: 0.5 * window.innerHeight,
29
+
30
+ isHasScrollProgressBar: theme.global.scroll_progress.bar === true,
31
+ isHasScrollPercent: theme.global.scroll_progress.percentage === true,
32
+
33
+ // Scroll Style
34
+ updateScrollStyle() {
35
+ const scrollTop =
36
+ window.pageYOffset || document.documentElement.scrollTop;
37
+ const scrollHeight = document.documentElement.scrollHeight;
38
+ const clientHeight =
39
+ window.innerHeight || document.documentElement.clientHeight;
40
+ const percent = this.calculatePercentage(
41
+ scrollTop,
42
+ scrollHeight,
43
+ clientHeight,
44
+ );
45
+
46
+ this.updateScrollProgressBar(percent);
47
+ this.updateScrollPercent(percent);
48
+ this.updatePageTopVisibility(scrollTop, clientHeight);
49
+
50
+ this.prevScrollValue = scrollTop;
51
+ },
52
+
53
+ updateScrollProgressBar(percent) {
54
+ if (this.isHasScrollProgressBar) {
55
+ const progressPercent = percent.toFixed(3);
56
+ const visibility = percent === 0 ? "hidden" : "visible";
57
+
58
+ this.scrollProgressBar_dom.style.visibility = visibility;
59
+ this.scrollProgressBar_dom.style.width = `${progressPercent}%`;
60
+ }
61
+ },
62
+
63
+ updateScrollPercent(percent) {
64
+ if (this.isHasScrollPercent) {
65
+ const percentDom = this.backToTopButton_dom.querySelector(".percent");
66
+ const showButton = percent !== 0 && percent !== undefined;
67
+
68
+ this.backToTopButton_dom.classList.toggle("show", showButton);
69
+ percentDom.innerHTML = percent.toFixed(0);
70
+ }
71
+ },
72
+
73
+ updatePageTopVisibility(scrollTop, clientHeight) {
74
+ if (theme.navbar.auto_hide) {
75
+ const prevScrollValue = this.prevScrollValue;
76
+ const hidePageTop =
77
+ prevScrollValue > clientHeight && scrollTop > prevScrollValue;
78
+
79
+ this.pageTop_dom.classList.toggle("hide", hidePageTop);
80
+ } else {
81
+ this.pageTop_dom.classList.remove("hide");
82
+ }
83
+ },
84
+
85
+ calculatePercentage(scrollTop, scrollHeight, clientHeight) {
86
+ let percentageValue = Math.round(
87
+ (scrollTop / (scrollHeight - clientHeight)) * 100,
88
+ );
89
+ if (
90
+ isNaN(percentageValue) ||
91
+ percentageValue < 0 ||
92
+ !isFinite(percentageValue)
93
+ ) {
94
+ percentageValue = 0;
95
+ } else if (percentageValue > 100) {
96
+ percentageValue = 100;
97
+ }
98
+ return percentageValue;
99
+ },
100
+
101
+ // register window scroll event
102
+ registerWindowScroll() {
103
+ window.addEventListener("scroll", () => {
104
+ this.updateScrollStyle();
105
+ this.updateTOCScroll();
106
+ this.updateNavbarShrink();
107
+ // this.updateHomeBannerBlur();
108
+ this.updateAutoHideTools();
109
+ });
110
+ window.addEventListener(
111
+ "scroll",
112
+ this.debounce(() => this.updateHomeBannerBlur(), 20),
113
+ );
114
+ },
115
+
116
+ updateTOCScroll() {
117
+ if (
118
+ theme.articles.toc.enable &&
119
+ initTOC().hasOwnProperty("updateActiveTOCLink")
120
+ ) {
121
+ initTOC().updateActiveTOCLink();
122
+ }
123
+ },
124
+
125
+ updateNavbarShrink() {
126
+ if (!navigationState.isNavigating) {
127
+ navbarShrink.init();
128
+ }
129
+ },
130
+
131
+ debounce(func, delay) {
132
+ let timer;
133
+ return function () {
134
+ clearTimeout(timer);
135
+ timer = setTimeout(() => func.apply(this, arguments), delay);
136
+ };
137
+ },
138
+
139
+ updateHomeBannerBlur() {
140
+ if (!this.homeBannerBackground_dom) return;
141
+
142
+ if (
143
+ theme.home_banner.style === "fixed" &&
144
+ location.pathname === config.root
145
+ ) {
146
+ const scrollY = window.scrollY || window.pageYOffset;
147
+ const blurValue = scrollY >= this.triggerViewHeight ? 15 : 0;
148
+
149
+ try {
150
+ requestAnimationFrame(() => {
151
+ this.homeBannerBackground_dom.style.filter = `blur(${blurValue}px)`;
152
+ this.homeBannerBackground_dom.style.webkitFilter = `blur(${blurValue}px)`;
153
+ });
154
+ } catch (e) {
155
+ // Handle or log the error properly
156
+ console.error("Error updating banner blur:", e);
157
+ }
158
+ }
159
+ },
160
+
161
+ updateAutoHideTools() {
162
+ const y = window.scrollY;
163
+ const height = document.body.scrollHeight;
164
+ const windowHeight = window.innerHeight;
165
+ const toolList = document.getElementsByClassName(
166
+ "right-side-tools-container",
167
+ );
168
+ const aplayer = document.getElementById("aplayer");
169
+
170
+ for (let i = 0; i < toolList.length; i++) {
171
+ const tools = toolList[i];
172
+ if (y <= 100) {
173
+ if (location.pathname === config.root) {
174
+ tools.classList.add("hide");
175
+ if (aplayer !== null) {
176
+ aplayer.classList.add("hide");
177
+ }
178
+ }
179
+ } else if (y + windowHeight >= height - 20) {
180
+ tools.classList.add("hide");
181
+ if (aplayer !== null) {
182
+ aplayer.classList.add("hide");
183
+ }
184
+ } else {
185
+ tools.classList.remove("hide");
186
+ if (aplayer !== null) {
187
+ aplayer.classList.remove("hide");
188
+ }
189
+ }
190
+ }
191
+ },
192
+
193
+ toggleToolsList() {
194
+ // Auto expand tools list if configured
195
+ if (theme.global.side_tools && theme.global.side_tools.auto_expand) {
196
+ this.toolsList.classList.add("show");
197
+ }
198
+
199
+ this.toggleButton.addEventListener("click", () => {
200
+ this.toolsList.classList.toggle("show");
201
+ });
202
+ },
203
+
204
+ fontAdjPlus_dom: document.querySelector(".tool-font-adjust-plus"),
205
+ fontAdMinus_dom: document.querySelector(".tool-font-adjust-minus"),
206
+ globalFontSizeAdjust() {
207
+ const htmlRoot = this.html_root_dom;
208
+ const fontAdjustPlus = this.fontAdjPlus_dom;
209
+ const fontAdjustMinus = this.fontAdMinus_dom;
210
+
211
+ const fontSize = document.defaultView.getComputedStyle(
212
+ document.body,
213
+ ).fontSize;
214
+ const baseFontSize = parseFloat(fontSize);
215
+
216
+ let fontSizeLevel = 0;
217
+ const styleStatus = main.getStyleStatus();
218
+ if (styleStatus) {
219
+ fontSizeLevel = styleStatus.fontSizeLevel;
220
+ setFontSize(fontSizeLevel);
221
+ }
222
+
223
+ function setFontSize(level) {
224
+ const fontSize = baseFontSize * (1 + level * 0.05);
225
+ htmlRoot.style.fontSize = `${fontSize}px`;
226
+ main.styleStatus.fontSizeLevel = level;
227
+ main.setStyleStatus();
228
+ }
229
+
230
+ function increaseFontSize() {
231
+ fontSizeLevel = Math.min(fontSizeLevel + 1, 5);
232
+ setFontSize(fontSizeLevel);
233
+ }
234
+
235
+ function decreaseFontSize() {
236
+ fontSizeLevel = Math.max(fontSizeLevel - 1, 0);
237
+ setFontSize(fontSizeLevel);
238
+ }
239
+
240
+ fontAdjustPlus.addEventListener("click", increaseFontSize);
241
+ fontAdjustMinus.addEventListener("click", decreaseFontSize);
242
+ },
243
+ // go comment anchor
244
+ goComment() {
245
+ this.goComment_dom = document.querySelector(".go-comment");
246
+ if (this.goComment_dom) {
247
+ this.goComment_dom.addEventListener("click", () => {
248
+ const target = document.querySelector("#comment-anchor");
249
+ if (target) {
250
+ const offset = target.getBoundingClientRect().top + window.scrollY;
251
+ window.scrollTo({
252
+ top: offset,
253
+ behavior: "smooth",
254
+ });
255
+ }
256
+ });
257
+ }
258
+ },
259
+
260
+ // get dom element height
261
+ getElementHeight(selectors) {
262
+ const dom = document.querySelector(selectors);
263
+ return dom ? dom.getBoundingClientRect().height : 0;
264
+ },
265
+
266
+ // init first screen height
267
+ inithomeBannerHeight() {
268
+ this.homeBanner_dom &&
269
+ (this.homeBanner_dom.style.height = this.innerHeight + "px");
270
+ },
271
+
272
+ // init page height handle
273
+ initPageHeightHandle() {
274
+ if (this.homeBanner_dom) return;
275
+ const temp_h1 = this.getElementHeight(".main-content-header");
276
+ const temp_h2 = this.getElementHeight(".main-content-body");
277
+ const temp_h3 = this.getElementHeight(".main-content-footer");
278
+ const allDomHeight = temp_h1 + temp_h2 + temp_h3;
279
+ const innerHeight = window.innerHeight;
280
+ const pb_dom = document.querySelector(".main-content-footer");
281
+ if (allDomHeight < innerHeight) {
282
+ const marginTopValue = Math.floor(innerHeight - allDomHeight);
283
+ if (marginTopValue > 0) {
284
+ pb_dom.style.marginTop = `${marginTopValue - 2}px`;
285
+ }
286
+ }
287
+ },
288
+
289
+ // set how long ago language
290
+ setHowLongAgoLanguage(p1, p2) {
291
+ return p2.replace(/%s/g, p1);
292
+ },
293
+
294
+ getHowLongAgo(timestamp) {
295
+ const l = lang_ago;
296
+
297
+ const __Y = Math.floor(timestamp / (60 * 60 * 24 * 30) / 12);
298
+ const __M = Math.floor(timestamp / (60 * 60 * 24 * 30));
299
+ const __W = Math.floor(timestamp / (60 * 60 * 24) / 7);
300
+ const __d = Math.floor(timestamp / (60 * 60 * 24));
301
+ const __h = Math.floor((timestamp / (60 * 60)) % 24);
302
+ const __m = Math.floor((timestamp / 60) % 60);
303
+ const __s = Math.floor(timestamp % 60);
304
+
305
+ if (__Y > 0) {
306
+ return this.setHowLongAgoLanguage(__Y, l.year);
307
+ } else if (__M > 0) {
308
+ return this.setHowLongAgoLanguage(__M, l.month);
309
+ } else if (__W > 0) {
310
+ return this.setHowLongAgoLanguage(__W, l.week);
311
+ } else if (__d > 0) {
312
+ return this.setHowLongAgoLanguage(__d, l.day);
313
+ } else if (__h > 0) {
314
+ return this.setHowLongAgoLanguage(__h, l.hour);
315
+ } else if (__m > 0) {
316
+ return this.setHowLongAgoLanguage(__m, l.minute);
317
+ } else if (__s > 0) {
318
+ return this.setHowLongAgoLanguage(__s, l.second);
319
+ }
320
+ },
321
+
322
+ relativeTimeInHome() {
323
+ const post = document.querySelectorAll(
324
+ ".home-article-meta-info .home-article-date",
325
+ );
326
+ const df = theme.home.article_date_format;
327
+ if (df === "relative") {
328
+ post &&
329
+ post.forEach((v) => {
330
+ const nowDate = Date.now();
331
+ const postDate = new Date(
332
+ v.dataset.date.split(" GMT")[0],
333
+ ).getTime();
334
+ v.innerHTML = this.getHowLongAgo(
335
+ Math.floor((nowDate - postDate) / 1000),
336
+ );
337
+ });
338
+ } else if (df === "auto") {
339
+ post &&
340
+ post.forEach((v) => {
341
+ const nowDate = Date.now();
342
+ const postDate = new Date(
343
+ v.dataset.date.split(" GMT")[0],
344
+ ).getTime();
345
+ const finalDays = Math.floor(
346
+ (nowDate - postDate) / (60 * 60 * 24 * 1000),
347
+ );
348
+ if (finalDays < 7) {
349
+ v.innerHTML = this.getHowLongAgo(
350
+ Math.floor((nowDate - postDate) / 1000),
351
+ );
352
+ }
353
+ });
354
+ }
355
+ },
356
+ };
357
+
358
+ utils.updateAutoHideTools();
359
+
360
+ // init scroll
361
+ utils.registerWindowScroll();
362
+
363
+ // toggle show tools list
364
+ utils.toggleToolsList();
365
+
366
+ // main font adjust
367
+ utils.globalFontSizeAdjust();
368
+
369
+ // go comment
370
+ utils.goComment();
371
+
372
+ // init page height handle
373
+ utils.initPageHeightHandle();
374
+
375
+ // init first screen height
376
+ utils.inithomeBannerHeight();
377
+
378
+ // set how long ago in home article block
379
+ utils.relativeTimeInHome();
380
+
381
+ // image viewer handle
382
+ imageViewer();
383
+ }
Binary file
Binary file
Binary file
package/vercel.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 2,
3
+ "public": false,
4
+ "github": {
5
+ "enabled": false
6
+ }
7
+ }