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.
- package/.github/ISSUE_TEMPLATE/bug-chinese.yml +115 -0
- package/.github/ISSUE_TEMPLATE/bug-english.yml +106 -0
- package/.github/ISSUE_TEMPLATE/enhancement-chinese.yml +55 -0
- package/.github/ISSUE_TEMPLATE/enhancement-english.yml +55 -0
- package/.github/workflows/build-and-commit.yml +49 -0
- package/.github/workflows/npm-publish.yml +34 -0
- package/.github/workflows/stale-issues.yml +20 -0
- package/CHANGELOG_REDEFINE_X.md +236 -0
- package/CODE_OF_CONDUCT.md +128 -0
- package/CONTRIBUTING.md +51 -0
- package/DONATION.md +82 -0
- package/LICENSE +674 -0
- package/README.md +135 -0
- package/README_zh-CN.md +138 -0
- package/README_zh-TW.md +137 -0
- package/TODO.md +215 -0
- package/_config.yml +489 -0
- package/languages/en.yml +93 -0
- package/languages/es.yml +92 -0
- package/languages/fr.yml +92 -0
- package/languages/ja.yml +92 -0
- package/languages/zh-CN.yml +95 -0
- package/languages/zh-TW.yml +94 -0
- package/layout/404.ejs +1 -0
- package/layout/archive.ejs +1 -0
- package/layout/category.ejs +1 -0
- package/layout/components/comments/comment.ejs +22 -0
- package/layout/components/comments/giscus.ejs +42 -0
- package/layout/components/comments/gitalk.ejs +47 -0
- package/layout/components/comments/twikoo.ejs +50 -0
- package/layout/components/comments/waline.ejs +34 -0
- package/layout/components/footer/footer.ejs +99 -0
- package/layout/components/header/head.ejs +222 -0
- package/layout/components/header/navbar.ejs +163 -0
- package/layout/components/header/preloader.ejs +148 -0
- package/layout/components/header/progress-bar.ejs +12 -0
- package/layout/components/plugins/aplayer.ejs +3 -0
- package/layout/components/scripts.ejs +90 -0
- package/layout/components/sidebar/author.ejs +6 -0
- package/layout/components/sidebar/avatar.ejs +3 -0
- package/layout/components/sidebar/statistics.ejs +14 -0
- package/layout/components/swup.ejs +27 -0
- package/layout/index.ejs +1 -0
- package/layout/layout.ejs +13 -0
- package/layout/page.ejs +57 -0
- package/layout/pages/archive/archive.ejs +3 -0
- package/layout/pages/bookmarks/bookmarks.ejs +68 -0
- package/layout/pages/category/categories.ejs +11 -0
- package/layout/pages/category/category-detail.ejs +6 -0
- package/layout/pages/friends/friends-link.ejs +59 -0
- package/layout/pages/home/home-article.ejs +52 -0
- package/layout/pages/home/home-background.ejs +33 -0
- package/layout/pages/home/home-banner.ejs +234 -0
- package/layout/pages/home/home-content.ejs +62 -0
- package/layout/pages/home/home-sidebar.ejs +78 -0
- package/layout/pages/masonry/masonry.ejs +28 -0
- package/layout/pages/notfound/notfound.ejs +8 -0
- package/layout/pages/page-template.ejs +23 -0
- package/layout/pages/post/article-content.ejs +153 -0
- package/layout/pages/post/article-copyright.ejs +69 -0
- package/layout/pages/post/article-info.ejs +78 -0
- package/layout/pages/post/post-tools.ejs +17 -0
- package/layout/pages/post/toc.ejs +15 -0
- package/layout/pages/shuoshuo/essays.ejs +23 -0
- package/layout/pages/tag/tag-detail.ejs +6 -0
- package/layout/pages/tag/tags.ejs +24 -0
- package/layout/post.ejs +1 -0
- package/layout/tag.ejs +1 -0
- package/layout/tags.ejs +1 -0
- package/layout/utils/image-viewer.ejs +3 -0
- package/layout/utils/local-search.ejs +20 -0
- package/layout/utils/paginator.ejs +8 -0
- package/layout/utils/posts-list.ejs +28 -0
- package/layout/utils/side-tools.ejs +51 -0
- package/package.json +45 -0
- package/scripts/config-export.js +66 -0
- package/scripts/data-handle.js +37 -0
- package/scripts/events/404.js +16 -0
- package/scripts/events/welcome.js +141 -0
- package/scripts/filters/delete-mask-handle.js +27 -0
- package/scripts/filters/encrypt.js +202 -0
- package/scripts/filters/img-handle.js +9 -0
- package/scripts/filters/lazyload-handle.js +350 -0
- package/scripts/filters/lib/hbe.default.js +15 -0
- package/scripts/filters/link-handle.js +42 -0
- package/scripts/filters/stylus-handle.js +9 -0
- package/scripts/filters/table-handle.js +11 -0
- package/scripts/helpers/meta-helpers.js +38 -0
- package/scripts/helpers/page-helpers.js +153 -0
- package/scripts/helpers/recommendation-helpers.js +367 -0
- package/scripts/helpers/theme-helpers.js +251 -0
- package/scripts/helpers/waline-helpers.js +33 -0
- package/scripts/modules/btn.js +85 -0
- package/scripts/modules/btns.js +71 -0
- package/scripts/modules/folding.js +34 -0
- package/scripts/modules/note-large.js +72 -0
- package/scripts/modules/note.js +64 -0
- package/scripts/modules/tabs.js +99 -0
- package/source/assets/hbe.style.css +220 -0
- package/source/assets/odometer-theme-minimal.css +81 -0
- package/source/css/build/tailwind.css +2 -0
- package/source/css/common/animated.styl +71 -0
- package/source/css/common/basic.styl +239 -0
- package/source/css/common/codeblock/code-block.styl +158 -0
- package/source/css/common/codeblock/code-theme.styl +82 -0
- package/source/css/common/codeblock/highlight.styl +189 -0
- package/source/css/common/codeblock/hljs-themes/dark/a11y-dark.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/dark/agate.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/dark/atom-one-dark.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/dark/github-dark.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/dark/monokai-sublime.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/dark/night-owl.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/dark/nord.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/dark/tokyo-night-dark.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/dark/vs2015.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/light/atom-one-light.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/light/default.styl +18 -0
- package/source/css/common/codeblock/hljs-themes/light/github.styl +18 -0
- package/source/css/common/colors.styl +112 -0
- package/source/css/common/markdown.styl +337 -0
- package/source/css/common/redefine-theme.styl +65 -0
- package/source/css/common/theme.styl +72 -0
- package/source/css/common/variables.styl +145 -0
- package/source/css/layout/_modules/aplayer.styl +799 -0
- package/source/css/layout/_modules/buttons.styl +42 -0
- package/source/css/layout/_modules/folding.styl +180 -0
- package/source/css/layout/_modules/notes.styl +181 -0
- package/source/css/layout/_modules/tabs.styl +105 -0
- package/source/css/layout/_partials/404.styl +14 -0
- package/source/css/layout/_partials/archive-list.styl +49 -0
- package/source/css/layout/_partials/article-copyright-info.styl +27 -0
- package/source/css/layout/_partials/article-meta-info.styl +62 -0
- package/source/css/layout/_partials/comments/comment.styl +11 -0
- package/source/css/layout/_partials/comments/gitalk.styl +529 -0
- package/source/css/layout/_partials/comments/twikoo.styl +62 -0
- package/source/css/layout/_partials/comments/waline.styl +1151 -0
- package/source/css/layout/_partials/footer.styl +59 -0
- package/source/css/layout/_partials/home-banner.styl +48 -0
- package/source/css/layout/_partials/image-viewer.styl +37 -0
- package/source/css/layout/_partials/local-search.styl +137 -0
- package/source/css/layout/_partials/navbar.styl +309 -0
- package/source/css/layout/_partials/page-template.styl +147 -0
- package/source/css/layout/_partials/paginator.styl +65 -0
- package/source/css/layout/_partials/post-tools.styl +43 -0
- package/source/css/layout/_partials/progress-bar.styl +33 -0
- package/source/css/layout/_partials/side-tools.styl +87 -0
- package/source/css/layout/_partials/tagcloud.styl +136 -0
- package/source/css/layout/_partials/toc.styl +105 -0
- package/source/css/layout/animations.styl +42 -0
- package/source/css/layout/archive-content.styl +8 -0
- package/source/css/layout/article-content.styl +257 -0
- package/source/css/layout/bookmarks.styl +8 -0
- package/source/css/layout/category-content.styl +21 -0
- package/source/css/layout/category-list.styl +119 -0
- package/source/css/layout/home-content.styl +114 -0
- package/source/css/layout/home-sidebar.styl +126 -0
- package/source/css/layout/page.styl +144 -0
- package/source/css/layout/tag-content.styl +30 -0
- package/source/css/style.styl +26 -0
- package/source/css/tailwind.source.css +236 -0
- package/source/fontawesome/all.min.css +6 -0
- package/source/fontawesome/brands.min.css +6 -0
- package/source/fontawesome/duotone.min.css +6 -0
- package/source/fontawesome/fontawesome.min.css +6 -0
- package/source/fontawesome/light.min.css +6 -0
- package/source/fontawesome/regular.min.css +6 -0
- package/source/fontawesome/sharp-solid.min.css +6 -0
- package/source/fontawesome/solid.min.css +6 -0
- package/source/fontawesome/svg-with-js.min.css +6 -0
- package/source/fontawesome/thin.min.css +6 -0
- package/source/fontawesome/v4-font-face.min.css +6 -0
- package/source/fontawesome/v4-shims.min.css +6 -0
- package/source/fontawesome/v5-font-face.min.css +6 -0
- package/source/fonts/Chillax/Chillax-Variable.eot +0 -0
- package/source/fonts/Chillax/Chillax-Variable.ttf +0 -0
- package/source/fonts/Chillax/Chillax-Variable.woff +0 -0
- package/source/fonts/Chillax/Chillax-Variable.woff2 +0 -0
- package/source/fonts/Chillax/chillax.css +39 -0
- package/source/fonts/Geist/GeistVF.ttf +0 -0
- package/source/fonts/Geist/GeistVF.woff +0 -0
- package/source/fonts/Geist/GeistVF.woff2 +0 -0
- package/source/fonts/Geist/geist.css +16 -0
- package/source/fonts/GeistMono/GeistMonoVF.ttf +0 -0
- package/source/fonts/GeistMono/GeistMonoVF.woff +0 -0
- package/source/fonts/GeistMono/GeistMonoVF.woff2 +0 -0
- package/source/fonts/GeistMono/geist-mono.css +16 -0
- package/source/images/bookmark-placeholder.svg +9 -0
- package/source/images/loading.svg +5 -0
- package/source/images/redefine-avatar.svg +1 -0
- package/source/images/redefine-favicon.svg +1 -0
- package/source/images/redefine-logo.svg +1 -0
- package/source/images/redefine-logo.webp +0 -0
- package/source/images/redefine-og.webp +0 -0
- package/source/images/wallhaven-wqery6-dark.webp +0 -0
- package/source/images/wallhaven-wqery6-light.webp +0 -0
- package/source/js/build/layouts/bookmarkNav.js +2 -0
- package/source/js/build/layouts/bookmarkNav.js.map +1 -0
- package/source/js/build/layouts/categoryList.js +2 -0
- package/source/js/build/layouts/categoryList.js.map +1 -0
- package/source/js/build/layouts/essays.js +2 -0
- package/source/js/build/layouts/essays.js.map +1 -0
- package/source/js/build/layouts/lazyload.js +2 -0
- package/source/js/build/layouts/lazyload.js.map +1 -0
- package/source/js/build/layouts/navbarShrink.js +2 -0
- package/source/js/build/layouts/navbarShrink.js.map +1 -0
- package/source/js/build/layouts/toc.js +2 -0
- package/source/js/build/layouts/toc.js.map +1 -0
- package/source/js/build/libs/APlayer.min.js +2 -0
- package/source/js/build/libs/Swup.min.js +2 -0
- package/source/js/build/libs/SwupPreloadPlugin.min.js +1 -0
- package/source/js/build/libs/SwupProgressPlugin.min.js +1 -0
- package/source/js/build/libs/SwupScriptsPlugin.min.js +1 -0
- package/source/js/build/libs/SwupScrollPlugin.min.js +1 -0
- package/source/js/build/libs/SwupSlideTheme.min.js +1 -0
- package/source/js/build/libs/Typed.min.js +10 -0
- package/source/js/build/libs/anime.min.js +8 -0
- package/source/js/build/libs/mermaid.min.js +2314 -0
- package/source/js/build/libs/minimasonry.min.js +1 -0
- package/source/js/build/libs/moment-with-locales.min.js +2 -0
- package/source/js/build/libs/moment.min.js +2 -0
- package/source/js/build/libs/odometer.min.js +2 -0
- package/source/js/build/libs/pangu.min.js +9 -0
- package/source/js/build/libs/pjax.min.js +1 -0
- package/source/js/build/libs/waline.js +84 -0
- package/source/js/build/main.js +2 -0
- package/source/js/build/main.js.map +1 -0
- package/source/js/build/plugins/aplayer.js +2 -0
- package/source/js/build/plugins/aplayer.js.map +1 -0
- package/source/js/build/plugins/hbe.js +2 -0
- package/source/js/build/plugins/hbe.js.map +1 -0
- package/source/js/build/plugins/masonry.js +2 -0
- package/source/js/build/plugins/masonry.js.map +1 -0
- package/source/js/build/plugins/mermaid.js +2 -0
- package/source/js/build/plugins/mermaid.js.map +1 -0
- package/source/js/build/plugins/pangu.js +2 -0
- package/source/js/build/plugins/pangu.js.map +1 -0
- package/source/js/build/plugins/tabs.js +2 -0
- package/source/js/build/plugins/tabs.js.map +1 -0
- package/source/js/build/plugins/typed.js +2 -0
- package/source/js/build/plugins/typed.js.map +1 -0
- package/source/js/build/tools/codeBlock.js +2 -0
- package/source/js/build/tools/codeBlock.js.map +1 -0
- package/source/js/build/tools/imageViewer.js +2 -0
- package/source/js/build/tools/imageViewer.js.map +1 -0
- package/source/js/build/tools/lightDarkSwitch.js +2 -0
- package/source/js/build/tools/lightDarkSwitch.js.map +1 -0
- package/source/js/build/tools/localSearch.js +2 -0
- package/source/js/build/tools/localSearch.js.map +1 -0
- package/source/js/build/tools/runtime.js +2 -0
- package/source/js/build/tools/runtime.js.map +1 -0
- package/source/js/build/tools/scrollTopBottom.js +2 -0
- package/source/js/build/tools/scrollTopBottom.js.map +1 -0
- package/source/js/build/tools/tocToggle.js +2 -0
- package/source/js/build/tools/tocToggle.js.map +1 -0
- package/source/js/build/utils.js +2 -0
- package/source/js/build/utils.js.map +1 -0
- package/source/js/build.js +148 -0
- package/source/js/layouts/bookmarkNav.js +65 -0
- package/source/js/layouts/categoryList.js +53 -0
- package/source/js/layouts/essays.js +25 -0
- package/source/js/layouts/lazyload.js +199 -0
- package/source/js/layouts/navbarShrink.js +135 -0
- package/source/js/layouts/toc.js +115 -0
- package/source/js/libs/APlayer.min.js +2 -0
- package/source/js/libs/APlayer.min.js.map +1 -0
- package/source/js/libs/Swup.min.js +2 -0
- package/source/js/libs/Swup.min.js.map +1 -0
- package/source/js/libs/SwupPreloadPlugin.min.js +1 -0
- package/source/js/libs/SwupPreloadPlugin.min.js.map +1 -0
- package/source/js/libs/SwupProgressPlugin.min.js +1 -0
- package/source/js/libs/SwupScriptsPlugin.min.js +1 -0
- package/source/js/libs/SwupScrollPlugin.min.js +1 -0
- package/source/js/libs/SwupScrollPlugin.min.js.map +1 -0
- package/source/js/libs/SwupSlideTheme.min.js +1 -0
- package/source/js/libs/Typed.min.js +10 -0
- package/source/js/libs/anime.min.js +8 -0
- package/source/js/libs/mermaid.min.js +2314 -0
- package/source/js/libs/mermaid.min.js.map +7 -0
- package/source/js/libs/minimasonry.min.js +1 -0
- package/source/js/libs/moment-with-locales.min.js +2 -0
- package/source/js/libs/moment.min.js +2 -0
- package/source/js/libs/odometer.min.js +2 -0
- package/source/js/libs/pangu.min.js +9 -0
- package/source/js/libs/pjax.min.js +1 -0
- package/source/js/libs/waline.js +84 -0
- package/source/js/libs/waline.js.map +1 -0
- package/source/js/main.js +95 -0
- package/source/js/plugins/aplayer.js +33 -0
- package/source/js/plugins/hbe.js +350 -0
- package/source/js/plugins/masonry.js +115 -0
- package/source/js/plugins/mermaid.js +7 -0
- package/source/js/plugins/pangu.js +12 -0
- package/source/js/plugins/tabs.js +29 -0
- package/source/js/plugins/typed.js +62 -0
- package/source/js/tools/codeBlock.js +48 -0
- package/source/js/tools/imageViewer.js +194 -0
- package/source/js/tools/lightDarkSwitch.js +165 -0
- package/source/js/tools/localSearch.js +327 -0
- package/source/js/tools/runtime.js +28 -0
- package/source/js/tools/scrollTopBottom.js +34 -0
- package/source/js/tools/tocToggle.js +58 -0
- package/source/js/utils.js +383 -0
- package/source/webfonts/fa-brands-400.ttf +0 -0
- package/source/webfonts/fa-brands-400.woff2 +0 -0
- package/source/webfonts/fa-duotone-900.ttf +0 -0
- package/source/webfonts/fa-duotone-900.woff2 +0 -0
- package/source/webfonts/fa-light-300.ttf +0 -0
- package/source/webfonts/fa-light-300.woff2 +0 -0
- package/source/webfonts/fa-regular-400.ttf +0 -0
- package/source/webfonts/fa-regular-400.woff2 +0 -0
- package/source/webfonts/fa-sharp-solid-900.ttf +0 -0
- package/source/webfonts/fa-sharp-solid-900.woff2 +0 -0
- package/source/webfonts/fa-solid-900.ttf +0 -0
- package/source/webfonts/fa-solid-900.woff2 +0 -0
- package/source/webfonts/fa-thin-100.ttf +0 -0
- package/source/webfonts/fa-thin-100.woff2 +0 -0
- package/source/webfonts/fa-v4compatibility.ttf +0 -0
- package/source/webfonts/fa-v4compatibility.woff2 +0 -0
- package/vercel.json +7 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* main function */
|
|
2
|
+
import initUtils from "./utils.js";
|
|
3
|
+
import initTyped from "./plugins/typed.js";
|
|
4
|
+
import initModeToggle from "./tools/lightDarkSwitch.js";
|
|
5
|
+
import initLazyLoad from "./layouts/lazyload.js";
|
|
6
|
+
import initScrollTopBottom from "./tools/scrollTopBottom.js";
|
|
7
|
+
import initLocalSearch from "./tools/localSearch.js";
|
|
8
|
+
import initCopyCode from "./tools/codeBlock.js";
|
|
9
|
+
import initBookmarkNav from "./layouts/bookmarkNav.js";
|
|
10
|
+
|
|
11
|
+
export const main = {
|
|
12
|
+
themeInfo: {
|
|
13
|
+
theme: `Redefine v${theme.version}`,
|
|
14
|
+
author: "Jason-JP-Yang",
|
|
15
|
+
repository: "https://github.com/Jason-JP-Yang/hexo-theme-Redefine-X",
|
|
16
|
+
},
|
|
17
|
+
localStorageKey: "REDEFINE-X-STATUS",
|
|
18
|
+
styleStatus: {
|
|
19
|
+
isExpandPageWidth: false,
|
|
20
|
+
isDark: theme.colors.default_mode && theme.colors.default_mode === "dark",
|
|
21
|
+
fontSizeLevel: 0,
|
|
22
|
+
isOpenPageAside: true,
|
|
23
|
+
},
|
|
24
|
+
printThemeInfo: () => {
|
|
25
|
+
console.log(`
|
|
26
|
+
+=====================================================================================+
|
|
27
|
+
| |
|
|
28
|
+
| ██████╗ ███████╗██████╗ ███████╗███████╗██╗███╗ ██╗███████╗ ██╗ ██╗ |
|
|
29
|
+
| ██╔══██╗██╔════╝██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔════╝ ╚██╗██╔╝ |
|
|
30
|
+
| ██████╔╝█████╗ ██║ ██║█████╗ █████╗ ██║██╔██╗ ██║█████╗█████╗╚███╔╝ |
|
|
31
|
+
| ██╔══██╗██╔══╝ ██║ ██║██╔══╝ ██╔══╝ ██║██║╚██╗██║██╔══╝╚════╝██╔██╗ |
|
|
32
|
+
| ██║ ██║███████╗██████╔╝███████╗██║ ██║██║ ╚████║███████╗ ██╔╝ ██╗ |
|
|
33
|
+
| ╚═╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚═╝ |
|
|
34
|
+
| |
|
|
35
|
+
| https://github.com/Jason-JP-Yang/hexo-theme-Redefine-X |
|
|
36
|
+
+=====================================================================================+
|
|
37
|
+
`); // console log message
|
|
38
|
+
},
|
|
39
|
+
setStyleStatus: () => {
|
|
40
|
+
localStorage.setItem(
|
|
41
|
+
main.localStorageKey,
|
|
42
|
+
JSON.stringify(main.styleStatus),
|
|
43
|
+
);
|
|
44
|
+
},
|
|
45
|
+
getStyleStatus: () => {
|
|
46
|
+
let temp = localStorage.getItem(main.localStorageKey);
|
|
47
|
+
if (temp) {
|
|
48
|
+
temp = JSON.parse(temp);
|
|
49
|
+
for (let key in main.styleStatus) {
|
|
50
|
+
main.styleStatus[key] = temp[key];
|
|
51
|
+
}
|
|
52
|
+
return temp;
|
|
53
|
+
} else {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
refresh: () => {
|
|
58
|
+
initUtils();
|
|
59
|
+
initModeToggle();
|
|
60
|
+
initScrollTopBottom();
|
|
61
|
+
initBookmarkNav();
|
|
62
|
+
|
|
63
|
+
if (
|
|
64
|
+
theme.home_banner.subtitle.text.length !== 0 &&
|
|
65
|
+
location.pathname === config.root
|
|
66
|
+
) {
|
|
67
|
+
initTyped("subtitle");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (theme.navbar.search.enable === true) {
|
|
71
|
+
initLocalSearch();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (theme.articles.code_block.copy === true) {
|
|
75
|
+
initCopyCode();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (theme.articles.lazyload === true) {
|
|
79
|
+
initLazyLoad();
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export function initMain() {
|
|
85
|
+
main.printThemeInfo();
|
|
86
|
+
main.refresh();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
document.addEventListener("DOMContentLoaded", initMain);
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
swup.hooks.on("page:view", () => {
|
|
93
|
+
main.refresh();
|
|
94
|
+
});
|
|
95
|
+
} catch (e) {}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
const audioList = [];
|
|
3
|
+
const isFixed = theme.plugins.aplayer.type === "fixed";
|
|
4
|
+
const isMini = theme.plugins.aplayer.type === "mini";
|
|
5
|
+
|
|
6
|
+
for (const audio of theme.plugins.aplayer.audios) {
|
|
7
|
+
const audioObj = {
|
|
8
|
+
name: audio.name,
|
|
9
|
+
artist: audio.artist,
|
|
10
|
+
url: audio.url,
|
|
11
|
+
cover: audio.cover,
|
|
12
|
+
lrc: audio.lrc,
|
|
13
|
+
theme: audio.theme,
|
|
14
|
+
};
|
|
15
|
+
audioList.push(audioObj);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (isMini) {
|
|
19
|
+
new APlayer({
|
|
20
|
+
container: document.getElementById("aplayer"),
|
|
21
|
+
mini: true,
|
|
22
|
+
audio: audioList,
|
|
23
|
+
});
|
|
24
|
+
} else if (isFixed) {
|
|
25
|
+
const player = new APlayer({
|
|
26
|
+
container: document.getElementById("aplayer"),
|
|
27
|
+
fixed: true,
|
|
28
|
+
lrcType: 3,
|
|
29
|
+
audio: audioList,
|
|
30
|
+
});
|
|
31
|
+
document.querySelector(".aplayer-icon-lrc").click();
|
|
32
|
+
}
|
|
33
|
+
})();
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import { main } from "../main.js";
|
|
2
|
+
import { initTOC } from "../layouts/toc.js";
|
|
3
|
+
|
|
4
|
+
export function initHBE() {
|
|
5
|
+
const cryptoObj = window.crypto || window.msCrypto;
|
|
6
|
+
const storage = window.localStorage;
|
|
7
|
+
|
|
8
|
+
const storageName = "hexo-blog-encrypt:#" + window.location.pathname;
|
|
9
|
+
const keySalt = textToArray("too young too simple");
|
|
10
|
+
const ivSalt = textToArray("sometimes naive!");
|
|
11
|
+
|
|
12
|
+
// As we can't detect the wrong password with AES-CBC,
|
|
13
|
+
// so adding an empty div and check it when decrption.
|
|
14
|
+
const knownPrefix = "<hbe-prefix></hbe-prefix>";
|
|
15
|
+
|
|
16
|
+
const mainElement = document.getElementById("hexo-blog-encrypt");
|
|
17
|
+
const wrongPassMessage = mainElement.dataset["wpm"];
|
|
18
|
+
const wrongHashMessage = mainElement.dataset["whm"];
|
|
19
|
+
const dataElement = mainElement.getElementsByTagName("script")["hbeData"];
|
|
20
|
+
const encryptedData = dataElement.innerText;
|
|
21
|
+
const HmacDigist = dataElement.dataset["hmacdigest"];
|
|
22
|
+
|
|
23
|
+
function hexToArray(s) {
|
|
24
|
+
return new Uint8Array(
|
|
25
|
+
s.match(/[\da-f]{2}/gi).map((h) => {
|
|
26
|
+
return parseInt(h, 16);
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function textToArray(s) {
|
|
32
|
+
var i = s.length;
|
|
33
|
+
var n = 0;
|
|
34
|
+
var ba = new Array();
|
|
35
|
+
|
|
36
|
+
for (var j = 0; j < i; ) {
|
|
37
|
+
var c = s.codePointAt(j);
|
|
38
|
+
if (c < 128) {
|
|
39
|
+
ba[n++] = c;
|
|
40
|
+
j++;
|
|
41
|
+
} else if (c > 127 && c < 2048) {
|
|
42
|
+
ba[n++] = (c >> 6) | 192;
|
|
43
|
+
ba[n++] = (c & 63) | 128;
|
|
44
|
+
j++;
|
|
45
|
+
} else if (c > 2047 && c < 65536) {
|
|
46
|
+
ba[n++] = (c >> 12) | 224;
|
|
47
|
+
ba[n++] = ((c >> 6) & 63) | 128;
|
|
48
|
+
ba[n++] = (c & 63) | 128;
|
|
49
|
+
j++;
|
|
50
|
+
} else {
|
|
51
|
+
ba[n++] = (c >> 18) | 240;
|
|
52
|
+
ba[n++] = ((c >> 12) & 63) | 128;
|
|
53
|
+
ba[n++] = ((c >> 6) & 63) | 128;
|
|
54
|
+
ba[n++] = (c & 63) | 128;
|
|
55
|
+
j += 2;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return new Uint8Array(ba);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function arrayBufferToHex(arrayBuffer) {
|
|
62
|
+
if (
|
|
63
|
+
typeof arrayBuffer !== "object" ||
|
|
64
|
+
arrayBuffer === null ||
|
|
65
|
+
typeof arrayBuffer.byteLength !== "number"
|
|
66
|
+
) {
|
|
67
|
+
throw new TypeError("Expected input to be an ArrayBuffer");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
var view = new Uint8Array(arrayBuffer);
|
|
71
|
+
var result = "";
|
|
72
|
+
var value;
|
|
73
|
+
|
|
74
|
+
for (var i = 0; i < view.length; i++) {
|
|
75
|
+
value = view[i].toString(16);
|
|
76
|
+
result += value.length === 1 ? "0" + value : value;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function getExecutableScript(oldElem) {
|
|
83
|
+
let out = document.createElement("script");
|
|
84
|
+
const attList = [
|
|
85
|
+
"type",
|
|
86
|
+
"text",
|
|
87
|
+
"src",
|
|
88
|
+
"crossorigin",
|
|
89
|
+
"defer",
|
|
90
|
+
"referrerpolicy",
|
|
91
|
+
];
|
|
92
|
+
attList.forEach((att) => {
|
|
93
|
+
if (oldElem[att]) out[att] = oldElem[att];
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function convertHTMLToElement(content) {
|
|
100
|
+
let out = document.createElement("div");
|
|
101
|
+
out.innerHTML = content;
|
|
102
|
+
out.querySelectorAll("script").forEach(async (elem) => {
|
|
103
|
+
elem.replaceWith(await getExecutableScript(elem));
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function getKeyMaterial(password) {
|
|
110
|
+
let encoder = new TextEncoder();
|
|
111
|
+
return cryptoObj.subtle.importKey(
|
|
112
|
+
"raw",
|
|
113
|
+
encoder.encode(password),
|
|
114
|
+
{
|
|
115
|
+
name: "PBKDF2",
|
|
116
|
+
},
|
|
117
|
+
false,
|
|
118
|
+
["deriveKey", "deriveBits"],
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function getHmacKey(keyMaterial) {
|
|
123
|
+
return cryptoObj.subtle.deriveKey(
|
|
124
|
+
{
|
|
125
|
+
name: "PBKDF2",
|
|
126
|
+
hash: "SHA-256",
|
|
127
|
+
salt: keySalt.buffer,
|
|
128
|
+
iterations: 1024,
|
|
129
|
+
},
|
|
130
|
+
keyMaterial,
|
|
131
|
+
{
|
|
132
|
+
name: "HMAC",
|
|
133
|
+
hash: "SHA-256",
|
|
134
|
+
length: 256,
|
|
135
|
+
},
|
|
136
|
+
true,
|
|
137
|
+
["verify"],
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function getDecryptKey(keyMaterial) {
|
|
142
|
+
return cryptoObj.subtle.deriveKey(
|
|
143
|
+
{
|
|
144
|
+
name: "PBKDF2",
|
|
145
|
+
hash: "SHA-256",
|
|
146
|
+
salt: keySalt.buffer,
|
|
147
|
+
iterations: 1024,
|
|
148
|
+
},
|
|
149
|
+
keyMaterial,
|
|
150
|
+
{
|
|
151
|
+
name: "AES-CBC",
|
|
152
|
+
length: 256,
|
|
153
|
+
},
|
|
154
|
+
true,
|
|
155
|
+
["decrypt"],
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function getIv(keyMaterial) {
|
|
160
|
+
return cryptoObj.subtle.deriveBits(
|
|
161
|
+
{
|
|
162
|
+
name: "PBKDF2",
|
|
163
|
+
hash: "SHA-256",
|
|
164
|
+
salt: ivSalt.buffer,
|
|
165
|
+
iterations: 512,
|
|
166
|
+
},
|
|
167
|
+
keyMaterial,
|
|
168
|
+
16 * 8,
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async function verifyContent(key, content) {
|
|
173
|
+
const encoder = new TextEncoder();
|
|
174
|
+
const encoded = encoder.encode(content);
|
|
175
|
+
|
|
176
|
+
let signature = hexToArray(HmacDigist);
|
|
177
|
+
|
|
178
|
+
const result = await cryptoObj.subtle.verify(
|
|
179
|
+
{
|
|
180
|
+
name: "HMAC",
|
|
181
|
+
hash: "SHA-256",
|
|
182
|
+
},
|
|
183
|
+
key,
|
|
184
|
+
signature,
|
|
185
|
+
encoded,
|
|
186
|
+
);
|
|
187
|
+
console.log(`Verification result: ${result}`);
|
|
188
|
+
if (!result) {
|
|
189
|
+
alert(wrongHashMessage);
|
|
190
|
+
console.log(`${wrongHashMessage}, got `, signature, ` but proved wrong.`);
|
|
191
|
+
}
|
|
192
|
+
return result;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async function decrypt(decryptKey, iv, hmacKey) {
|
|
196
|
+
let typedArray = hexToArray(encryptedData);
|
|
197
|
+
|
|
198
|
+
const result = await cryptoObj.subtle
|
|
199
|
+
.decrypt(
|
|
200
|
+
{
|
|
201
|
+
name: "AES-CBC",
|
|
202
|
+
iv: iv,
|
|
203
|
+
},
|
|
204
|
+
decryptKey,
|
|
205
|
+
typedArray.buffer,
|
|
206
|
+
)
|
|
207
|
+
.then(async (result) => {
|
|
208
|
+
const decoder = new TextDecoder();
|
|
209
|
+
const decoded = decoder.decode(result);
|
|
210
|
+
|
|
211
|
+
// check the prefix, if not then we can sure here is wrong password.
|
|
212
|
+
if (!decoded.startsWith(knownPrefix)) {
|
|
213
|
+
throw "Decode successfully but not start with KnownPrefix.";
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const hideButton = document.createElement("button");
|
|
217
|
+
hideButton.textContent = "Encrypt again";
|
|
218
|
+
hideButton.type = "button";
|
|
219
|
+
hideButton.classList.add("hbe-button");
|
|
220
|
+
hideButton.addEventListener("click", () => {
|
|
221
|
+
window.localStorage.removeItem(storageName);
|
|
222
|
+
window.location.reload();
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
document.getElementById("hexo-blog-encrypt").style.display = "inline";
|
|
226
|
+
document.getElementById("hexo-blog-encrypt").innerHTML = "";
|
|
227
|
+
document
|
|
228
|
+
.getElementById("hexo-blog-encrypt")
|
|
229
|
+
.appendChild(await convertHTMLToElement(decoded));
|
|
230
|
+
document.getElementById("hexo-blog-encrypt").appendChild(hideButton);
|
|
231
|
+
|
|
232
|
+
// Trigger lazy loading for any preloaders in decrypted content
|
|
233
|
+
import("../layouts/lazyload.js").then((module) => {
|
|
234
|
+
if (module.forceLoadAllPreloaders) {
|
|
235
|
+
module.forceLoadAllPreloaders();
|
|
236
|
+
}
|
|
237
|
+
}).catch(() => {
|
|
238
|
+
// Fallback: try to load preloaders directly
|
|
239
|
+
document.querySelectorAll(".img-preloader").forEach((preloader) => {
|
|
240
|
+
if (preloader.dataset.loaded !== "true") {
|
|
241
|
+
const src = preloader.dataset.src;
|
|
242
|
+
if (src) {
|
|
243
|
+
const img = document.createElement("img");
|
|
244
|
+
img.src = src;
|
|
245
|
+
img.alt = preloader.dataset.alt || "";
|
|
246
|
+
if (preloader.parentNode) {
|
|
247
|
+
preloader.parentNode.replaceChild(img, preloader);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
// // load Redefine Page components
|
|
255
|
+
main.refresh();
|
|
256
|
+
initTOC();
|
|
257
|
+
|
|
258
|
+
// trigger event
|
|
259
|
+
var event = new Event("hexo-blog-decrypt");
|
|
260
|
+
window.dispatchEvent(event);
|
|
261
|
+
|
|
262
|
+
return await verifyContent(hmacKey, decoded);
|
|
263
|
+
})
|
|
264
|
+
.catch((e) => {
|
|
265
|
+
alert(wrongPassMessage);
|
|
266
|
+
console.log(e);
|
|
267
|
+
return false;
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
return result;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function hbeLoader() {
|
|
274
|
+
const oldStorageData = JSON.parse(storage.getItem(storageName));
|
|
275
|
+
|
|
276
|
+
if (oldStorageData) {
|
|
277
|
+
console.log(
|
|
278
|
+
`Password got from localStorage(${storageName}): `,
|
|
279
|
+
oldStorageData,
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
const sIv = hexToArray(oldStorageData.iv).buffer;
|
|
283
|
+
const sDk = oldStorageData.dk;
|
|
284
|
+
const sHmk = oldStorageData.hmk;
|
|
285
|
+
|
|
286
|
+
cryptoObj.subtle
|
|
287
|
+
.importKey(
|
|
288
|
+
"jwk",
|
|
289
|
+
sDk,
|
|
290
|
+
{
|
|
291
|
+
name: "AES-CBC",
|
|
292
|
+
length: 256,
|
|
293
|
+
},
|
|
294
|
+
true,
|
|
295
|
+
["decrypt"],
|
|
296
|
+
)
|
|
297
|
+
.then((dkCK) => {
|
|
298
|
+
cryptoObj.subtle
|
|
299
|
+
.importKey(
|
|
300
|
+
"jwk",
|
|
301
|
+
sHmk,
|
|
302
|
+
{
|
|
303
|
+
name: "HMAC",
|
|
304
|
+
hash: "SHA-256",
|
|
305
|
+
length: 256,
|
|
306
|
+
},
|
|
307
|
+
true,
|
|
308
|
+
["verify"],
|
|
309
|
+
)
|
|
310
|
+
.then((hmkCK) => {
|
|
311
|
+
decrypt(dkCK, sIv, hmkCK).then((result) => {
|
|
312
|
+
if (!result) {
|
|
313
|
+
storage.removeItem(storageName);
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
mainElement.addEventListener("keydown", async (event) => {
|
|
321
|
+
if (event.isComposing || event.key === "Enter") {
|
|
322
|
+
const password = document.getElementById("hbePass").value;
|
|
323
|
+
const keyMaterial = await getKeyMaterial(password);
|
|
324
|
+
const hmacKey = await getHmacKey(keyMaterial);
|
|
325
|
+
const decryptKey = await getDecryptKey(keyMaterial);
|
|
326
|
+
const iv = await getIv(keyMaterial);
|
|
327
|
+
|
|
328
|
+
decrypt(decryptKey, iv, hmacKey).then((result) => {
|
|
329
|
+
console.log(`Decrypt result: ${result}`);
|
|
330
|
+
if (result) {
|
|
331
|
+
cryptoObj.subtle.exportKey("jwk", decryptKey).then((dk) => {
|
|
332
|
+
cryptoObj.subtle.exportKey("jwk", hmacKey).then((hmk) => {
|
|
333
|
+
const newStorageData = {
|
|
334
|
+
dk: dk,
|
|
335
|
+
iv: arrayBufferToHex(iv),
|
|
336
|
+
hmk: hmk,
|
|
337
|
+
};
|
|
338
|
+
storage.setItem(storageName, JSON.stringify(newStorageData));
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
hbeLoader();
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// initHBE();
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export function initMasonry() {
|
|
2
|
+
var loadingPlaceholder = document.querySelector(".loading-placeholder");
|
|
3
|
+
var masonryContainer = document.querySelector("#masonry-container");
|
|
4
|
+
if (!loadingPlaceholder || !masonryContainer) return;
|
|
5
|
+
|
|
6
|
+
loadingPlaceholder.style.display = "block";
|
|
7
|
+
masonryContainer.style.display = "none";
|
|
8
|
+
|
|
9
|
+
// Get both regular images and preloader divs
|
|
10
|
+
var images = document.querySelectorAll(
|
|
11
|
+
"#masonry-container .masonry-item img",
|
|
12
|
+
);
|
|
13
|
+
var preloaders = document.querySelectorAll(
|
|
14
|
+
"#masonry-container .masonry-item .img-preloader",
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
var totalCount = images.length + preloaders.length;
|
|
18
|
+
var loadedCount = 0;
|
|
19
|
+
|
|
20
|
+
function onItemReady() {
|
|
21
|
+
loadedCount++;
|
|
22
|
+
if (loadedCount === totalCount) {
|
|
23
|
+
initializeMasonryLayout();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Handle regular images
|
|
28
|
+
for (var i = 0; i < images.length; i++) {
|
|
29
|
+
var img = images[i];
|
|
30
|
+
if (img.complete) {
|
|
31
|
+
onItemReady();
|
|
32
|
+
} else {
|
|
33
|
+
img.addEventListener("load", onItemReady);
|
|
34
|
+
img.addEventListener("error", onItemReady); // Also count errors to prevent blocking
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Handle preloaders - force load them and wait
|
|
39
|
+
if (preloaders.length > 0) {
|
|
40
|
+
import("../layouts/lazyload.js").then((module) => {
|
|
41
|
+
preloaders.forEach((preloader) => {
|
|
42
|
+
// If already loaded, count it
|
|
43
|
+
if (preloader.dataset.loaded === "true" || preloader.tagName === "IMG") {
|
|
44
|
+
onItemReady();
|
|
45
|
+
} else {
|
|
46
|
+
// Set up observer for when it gets replaced with an image
|
|
47
|
+
const observer = new MutationObserver((mutations, obs) => {
|
|
48
|
+
mutations.forEach((mutation) => {
|
|
49
|
+
mutation.addedNodes.forEach((node) => {
|
|
50
|
+
if (node.tagName === "IMG") {
|
|
51
|
+
if (node.complete) {
|
|
52
|
+
onItemReady();
|
|
53
|
+
} else {
|
|
54
|
+
node.addEventListener("load", onItemReady);
|
|
55
|
+
node.addEventListener("error", onItemReady);
|
|
56
|
+
}
|
|
57
|
+
obs.disconnect();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
observer.observe(preloader.parentNode, { childList: true });
|
|
64
|
+
|
|
65
|
+
// Force trigger the preloader to load
|
|
66
|
+
if (module.forceLoadAllPreloaders) {
|
|
67
|
+
module.forceLoadAllPreloaders();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}).catch(() => {
|
|
72
|
+
// Fallback: just count all preloaders as ready
|
|
73
|
+
preloaders.forEach(() => onItemReady());
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Handle case where there are no items
|
|
78
|
+
if (totalCount === 0) {
|
|
79
|
+
initializeMasonryLayout();
|
|
80
|
+
} else if (loadedCount === totalCount) {
|
|
81
|
+
initializeMasonryLayout();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function initializeMasonryLayout() {
|
|
85
|
+
loadingPlaceholder.style.opacity = 0;
|
|
86
|
+
setTimeout(() => {
|
|
87
|
+
loadingPlaceholder.style.display = "none";
|
|
88
|
+
masonryContainer.style.display = "block";
|
|
89
|
+
var screenWidth = window.innerWidth;
|
|
90
|
+
var baseWidth;
|
|
91
|
+
if (screenWidth >= 768) {
|
|
92
|
+
baseWidth = 255;
|
|
93
|
+
} else {
|
|
94
|
+
baseWidth = 150;
|
|
95
|
+
}
|
|
96
|
+
var masonry = new MiniMasonry({
|
|
97
|
+
baseWidth: baseWidth,
|
|
98
|
+
container: masonryContainer,
|
|
99
|
+
gutterX: 10,
|
|
100
|
+
gutterY: 10,
|
|
101
|
+
surroundingGutter: false,
|
|
102
|
+
});
|
|
103
|
+
masonry.layout();
|
|
104
|
+
masonryContainer.style.opacity = 1;
|
|
105
|
+
}, 100);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (data.masonry) {
|
|
110
|
+
try {
|
|
111
|
+
swup.hooks.on("page:view", initMasonry);
|
|
112
|
+
} catch (e) {}
|
|
113
|
+
|
|
114
|
+
document.addEventListener("DOMContentLoaded", initMasonry);
|
|
115
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function initPanguJS() {
|
|
2
|
+
// Add space between Chinese and English
|
|
3
|
+
pangu.spacingElementByClassName("markdown-body");
|
|
4
|
+
|
|
5
|
+
pangu.autoSpacingPage();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
document.addEventListener("DOMContentLoaded", initPanguJS);
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
swup.hooks.on("page:view", initPanguJS);
|
|
12
|
+
} catch (e) {}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function setTabs() {
|
|
2
|
+
let tabs = document.querySelectorAll(".tabs .nav-tabs");
|
|
3
|
+
if (!tabs) return;
|
|
4
|
+
|
|
5
|
+
tabs.forEach((tab) => {
|
|
6
|
+
tab.querySelectorAll("a").forEach((link) => {
|
|
7
|
+
link.addEventListener("click", (e) => {
|
|
8
|
+
e.preventDefault();
|
|
9
|
+
e.stopPropagation();
|
|
10
|
+
|
|
11
|
+
const parentTab = e.target.parentElement.parentElement.parentElement;
|
|
12
|
+
parentTab.querySelector(".nav-tabs .active").classList.remove("active");
|
|
13
|
+
e.target.parentElement.classList.add("active");
|
|
14
|
+
parentTab
|
|
15
|
+
.querySelector(".tab-content .active")
|
|
16
|
+
.classList.remove("active");
|
|
17
|
+
parentTab.querySelector(e.target.className).classList.add("active");
|
|
18
|
+
|
|
19
|
+
return false;
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
swup.hooks.on("page:view", setTabs);
|
|
27
|
+
} catch (e) {}
|
|
28
|
+
|
|
29
|
+
document.addEventListener("DOMContentLoaded", setTabs);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
author: @jiangwen5945 & EvanNotFound
|
|
3
|
+
*/
|
|
4
|
+
export const config = {
|
|
5
|
+
usrTypeSpeed: theme.home_banner.subtitle.typing_speed,
|
|
6
|
+
usrBackSpeed: theme.home_banner.subtitle.backing_speed,
|
|
7
|
+
usrBackDelay: theme.home_banner.subtitle.backing_delay,
|
|
8
|
+
usrStartDelay: theme.home_banner.subtitle.starting_delay,
|
|
9
|
+
usrLoop: theme.home_banner.subtitle.loop,
|
|
10
|
+
usrSmartBackspace: theme.home_banner.subtitle.smart_backspace,
|
|
11
|
+
usrHitokotoAPI: theme.home_banner.subtitle.hitokoto.api,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default function initTyped(id) {
|
|
15
|
+
const {
|
|
16
|
+
usrTypeSpeed,
|
|
17
|
+
usrBackSpeed,
|
|
18
|
+
usrBackDelay,
|
|
19
|
+
usrStartDelay,
|
|
20
|
+
usrLoop,
|
|
21
|
+
usrSmartBackspace,
|
|
22
|
+
usrHitokotoAPI,
|
|
23
|
+
} = config;
|
|
24
|
+
|
|
25
|
+
function typing(dataList) {
|
|
26
|
+
const st = new Typed("#" + id, {
|
|
27
|
+
strings: [dataList],
|
|
28
|
+
typeSpeed: usrTypeSpeed || 100,
|
|
29
|
+
smartBackspace: usrSmartBackspace || false,
|
|
30
|
+
backSpeed: usrBackSpeed || 80,
|
|
31
|
+
backDelay: usrBackDelay || 1500,
|
|
32
|
+
loop: usrLoop || false,
|
|
33
|
+
startDelay: usrStartDelay || 500,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (theme.home_banner.subtitle.hitokoto.enable) {
|
|
38
|
+
fetch(usrHitokotoAPI)
|
|
39
|
+
.then((response) => response.json())
|
|
40
|
+
.then((data) => {
|
|
41
|
+
if (data.from_who && theme.home_banner.subtitle.hitokoto.show_author) {
|
|
42
|
+
typing(data.hitokoto + "——" + data.from_who);
|
|
43
|
+
} else {
|
|
44
|
+
typing(data.hitokoto);
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
.catch(console.error);
|
|
48
|
+
} else {
|
|
49
|
+
const sentenceList = [...theme.home_banner.subtitle.text];
|
|
50
|
+
if (document.getElementById(id)) {
|
|
51
|
+
const st = new Typed("#" + id, {
|
|
52
|
+
strings: sentenceList,
|
|
53
|
+
typeSpeed: usrTypeSpeed || 100,
|
|
54
|
+
smartBackspace: usrSmartBackspace || false,
|
|
55
|
+
backSpeed: usrBackSpeed || 80,
|
|
56
|
+
backDelay: usrBackDelay || 1500,
|
|
57
|
+
loop: usrLoop || false,
|
|
58
|
+
startDelay: usrStartDelay || 500,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|