first commit

This commit is contained in:
Missdrop
2025-07-16 16:30:56 +00:00
commit 7ee33927cb
11326 changed files with 1230901 additions and 0 deletions

144
public/js/build.js Normal file
View File

@@ -0,0 +1,144 @@
const { minify } = require("terser");
const fs = require("fs/promises");
const path = require("path");
const glob = require("glob-promise");
const THEME_ROOT = path.join(__dirname, "../..");
const SOURCE_DIR = path.join(THEME_ROOT, "source/js");
const BUILD_DIR = path.join(THEME_ROOT, "source/js/build");
const IGNORE_PATTERNS = [
path.join(SOURCE_DIR, "libs/**"),
path.join(BUILD_DIR, "**"),
path.join(SOURCE_DIR, "build.js"),
];
const minifyOptions = {
compress: {
dead_code: true,
drop_console: false,
drop_debugger: true,
keep_classnames: true,
keep_fnames: true,
},
mangle: {
keep_classnames: true,
keep_fnames: true,
},
format: {
comments: false,
},
module: true,
sourceMap: {
filename: "source-map",
url: "source-map.map",
},
};
async function ensureDirectoryExists(dir) {
try {
await fs.mkdir(dir, { recursive: true });
} catch (err) {
if (err.code !== "EEXIST") {
throw new Error(`Failed to create directory ${dir}: ${err.message}`);
}
}
}
async function copyFile(source, destination) {
try {
const destinationDir = path.dirname(destination);
await ensureDirectoryExists(destinationDir);
await fs.copyFile(source, destination);
console.log(`✓ Copied ${source} -> ${destination}`);
} catch (err) {
console.error(`× Error copying ${source}:`, err);
throw err;
}
}
async function processFile(file) {
try {
const code = await fs.readFile(file, "utf8");
const relativePath = path.relative(SOURCE_DIR, file);
const buildPath = path.join(BUILD_DIR, relativePath);
const buildDirPath = path.dirname(buildPath);
// Update source map options for this specific file
const fileSpecificOptions = {
...minifyOptions,
sourceMap: {
...minifyOptions.sourceMap,
filename: path.basename(file),
url: `${path.basename(file)}.map`,
},
};
const minified = await minify(code, fileSpecificOptions);
await ensureDirectoryExists(buildDirPath);
// Write minified code
await fs.writeFile(buildPath, minified.code);
// Write source map if it exists
if (minified.map) {
await fs.writeFile(`${buildPath}.map`, minified.map);
}
console.log(`✓ Minified ${file} -> ${buildPath}`);
} catch (err) {
console.error(`× Error processing ${file}:`, err);
throw err; // Re-throw to handle in the main function
}
}
async function minifyJS() {
try {
await ensureDirectoryExists(BUILD_DIR);
// Get lib files to copy
const libFiles = await glob(`${SOURCE_DIR}/libs/**/*.js`);
// Get JS files to minify (excluding libs and other ignored patterns)
const files = await glob(`${SOURCE_DIR}/**/*.js`, {
ignore: IGNORE_PATTERNS,
});
if (files.length === 0 && libFiles.length === 0) {
console.log("No JavaScript files found to process");
return;
}
console.log(`Found ${files.length} files to minify and ${libFiles.length} lib files to copy...`);
// Copy lib files
for (const file of libFiles) {
const relativePath = path.relative(SOURCE_DIR, file);
const buildPath = path.join(BUILD_DIR, relativePath);
await copyFile(file, buildPath);
}
// Process remaining files in parallel with a concurrency limit
const concurrencyLimit = 4; // Adjust based on your needs
const chunks = [];
for (let i = 0; i < files.length; i += concurrencyLimit) {
chunks.push(files.slice(i, i + concurrencyLimit));
}
for (const chunk of chunks) {
await Promise.all(chunk.map(processFile));
}
console.log("\n✓ All files processed successfully!");
} catch (err) {
console.error("× Build failed:", err);
process.exit(1);
}
}
// Run the build process
minifyJS().catch((err) => {
console.error("× Unhandled error:", err);
process.exit(1);
});

View File

@@ -0,0 +1,2 @@
export default function initBookmarkNav(){const t=document.querySelectorAll(".bookmark-nav-item"),e=document.querySelectorAll("section[id]");function setActiveNavItem(){const o=window.scrollY+100;let n=null;e.forEach((t=>{const e=t.offsetTop,c=t.offsetHeight;o>=e&&o<e+c&&(n=t)})),t.forEach((t=>{t.classList.remove("bg-second-background-color"),n&&t.getAttribute("data-category")===n.getAttribute("id")&&t.classList.add("bg-second-background-color")}))}t.length&&e.length&&(window.addEventListener("scroll",function throttle(t,e){let o;return function(){const n=arguments,c=this;o||(t.apply(c,n),o=!0,setTimeout((()=>o=!1),e))}}(setActiveNavItem,100)),setActiveNavItem())}try{swup.hooks.on("page:view",initBookmarkNav)}catch(t){}document.addEventListener("DOMContentLoaded",initBookmarkNav);
//# sourceMappingURL=bookmarkNav.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"bookmarkNav.js","names":["initBookmarkNav","navItems","document","querySelectorAll","sections","setActiveNavItem","fromTop","window","scrollY","currentSection","forEach","section","sectionTop","offsetTop","sectionHeight","offsetHeight","item","classList","remove","getAttribute","add","length","addEventListener","throttle","func","limit","inThrottle","args","arguments","context","this","apply","setTimeout","swup","hooks","on","e"],"sources":["0"],"mappings":"eAAe,SAASA,kBACtB,MAAMC,EAAWC,SAASC,iBAAiB,sBACrCC,EAAWF,SAASC,iBAAiB,eAkB3C,SAASE,mBACP,MAAMC,EAAUC,OAAOC,QAAU,IACjC,IAAIC,EAAiB,KAErBL,EAASM,SAAQC,IACf,MAAMC,EAAaD,EAAQE,UACrBC,EAAgBH,EAAQI,aAE1BT,GAAWM,GAAcN,EAAUM,EAAaE,IAClDL,EAAiBE,EACnB,IAGFV,EAASS,SAAQM,IACfA,EAAKC,UAAUC,OAAO,8BAClBT,GAAkBO,EAAKG,aAAa,mBAAqBV,EAAeU,aAAa,OACvFH,EAAKC,UAAUG,IAAI,6BACrB,GAEJ,CAnCKnB,EAASoB,QAAWjB,EAASiB,SAkDlCd,OAAOe,iBAAiB,SA/CxB,SAASC,SAASC,EAAMC,GACtB,IAAIC,EACJ,OAAO,WACL,MAAMC,EAAOC,UACPC,EAAUC,KACXJ,IACHF,EAAKO,MAAMF,EAASF,GACpBD,GAAa,EACbM,YAAW,IAAMN,GAAa,GAAOD,GAEzC,CACF,CAoCkCF,CAASlB,iBAAkB,MAG7DA,mBACF,CAEA,IACE4B,KAAKC,MAAMC,GAAG,YAAanC,gBAC7B,CAAE,MAAOoC,GAAI,CAEblC,SAASoB,iBAAiB,mBAAoBtB","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
const toggleStyle=(e,t,o,l)=>{e.style[t]=e.style[t]===o?l:o},setupCategoryList=()=>{const e=Array.from(document.querySelectorAll(".all-category-list-item")).filter((e=>e.parentElement.classList.contains("all-category-list")));e.forEach((t=>{const o=t.querySelectorAll(".all-category-list-child");o.forEach((e=>{e.style.maxHeight="0px",e.style.marginTop="0px"})),t.addEventListener("click",(()=>{const l=t.offsetTop;o.forEach((e=>{toggleStyle(e,"maxHeight","0px","1000px"),toggleStyle(e,"marginTop","0px","15px")})),e.forEach((e=>{if(e.offsetTop===l&&e!==t){e.querySelectorAll(".all-category-list-child").forEach((e=>{toggleStyle(e,"maxHeight","0px","1000px"),toggleStyle(e,"marginTop","0px","15px")}))}}))}))}))};try{swup.hooks.on("page:view",setupCategoryList)}catch(e){console.error(e)}document.addEventListener("DOMContentLoaded",setupCategoryList);
//# sourceMappingURL=categoryList.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"categoryList.js","names":["toggleStyle","element","style","firstValue","secondValue","setupCategoryList","parentElements","Array","from","document","querySelectorAll","filter","item","parentElement","classList","contains","forEach","childElements","childElement","maxHeight","marginTop","addEventListener","clickedElementTopOffset","offsetTop","siblingElement","siblingChildElement","swup","hooks","on","e","console","error"],"sources":["0"],"mappings":"AAAA,MAAMA,YAAc,CAACC,EAASC,EAAOC,EAAYC,KAC/CH,EAAQC,MAAMA,GACZD,EAAQC,MAAMA,KAAWC,EAAaC,EAAcD,CAAU,EAG5DE,kBAAoB,KACxB,MAAMC,EAAiBC,MAAMC,KAC3BC,SAASC,iBAAiB,4BAC1BC,QAAQC,GACRA,EAAKC,cAAcC,UAAUC,SAAS,uBAGxCT,EAAeU,SAASH,IACtB,MAAMI,EAAgBJ,EAAcH,iBAClC,4BAEFO,EAAcD,SAASE,IACrBA,EAAahB,MAAMiB,UAAY,MAC/BD,EAAahB,MAAMkB,UAAY,KAAK,IAGtCP,EAAcQ,iBAAiB,SAAS,KACtC,MAAMC,EAA0BT,EAAcU,UAC9CN,EAAcD,SAASE,IACrBlB,YAAYkB,EAAc,YAAa,MAAO,UAC9ClB,YAAYkB,EAAc,YAAa,MAAO,OAAO,IAGvDZ,EAAeU,SAASQ,IACtB,GACEA,EAAeD,YAAcD,GAC7BE,IAAmBX,EACnB,CAC6BW,EAAed,iBAC1C,4BAEmBM,SAASS,IAC5BzB,YAAYyB,EAAqB,YAAa,MAAO,UACrDzB,YAAYyB,EAAqB,YAAa,MAAO,OAAO,GAEhE,IACA,GACF,GACF,EAGJ,IACEC,KAAKC,MAAMC,GAAG,YAAavB,kBAC7B,CAAE,MAAOwB,GACPC,QAAQC,MAAMF,EAChB,CAEApB,SAASY,iBAAiB,mBAAoBhB","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
function formatEssayDates(){const t=document.querySelectorAll(".essay-date");t&&t.forEach((function(t){const e=t.getAttribute("data-date"),a=config.language||"en",o=moment(e).locale(a).calendar();t.textContent=o}))}try{swup.hooks.on("page:view",formatEssayDates)}catch(t){console.error(t)}document.addEventListener("DOMContentLoaded",formatEssayDates);
//# sourceMappingURL=essays.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"essays.js","names":["formatEssayDates","dateElements","document","querySelectorAll","forEach","element","rawDate","getAttribute","locale","config","language","formattedDate","moment","calendar","textContent","swup","hooks","on","e","console","error","addEventListener"],"sources":["0"],"mappings":"AACA,SAASA,mBACP,MAAMC,EAAeC,SAASC,iBAAiB,eAE1CF,GAILA,EAAaG,SAAQ,SAAUC,GAC7B,MAAMC,EAAUD,EAAQE,aAAa,aAC/BC,EAASC,OAAOC,UAAY,KAE5BC,EAAgBC,OAAON,GAASE,OAAOA,GAAQK,WACrDR,EAAQS,YAAcH,CACxB,GACF,CAEA,IACEI,KAAKC,MAAMC,GAAG,YAAajB,iBAC7B,CAAE,MAAOkB,GACPC,QAAQC,MAAMF,EAChB,CAGAhB,SAASmB,iBAAiB,mBAAoBrB","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
export default function initLazyLoad(){const t=document.querySelectorAll("img"),e=new IntersectionObserver(((t,e)=>{t.forEach((t=>{if(t.isIntersecting){const r=t.target;r.src=r.getAttribute("data-src"),r.removeAttribute("lazyload"),e.unobserve(r)}}))}),{rootMargin:"0px",threshold:.1});t.forEach((t=>{t.hasAttribute("lazyload")&&e.observe(t)}))}
//# sourceMappingURL=lazyload.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"lazyload.js","names":["initLazyLoad","imgs","document","querySelectorAll","observer","IntersectionObserver","entries","forEach","entry","isIntersecting","img","target","src","getAttribute","removeAttribute","unobserve","rootMargin","threshold","hasAttribute","observe"],"sources":["0"],"mappings":"eAAe,SAASA,eACtB,MAAMC,EAAOC,SAASC,iBAAiB,OAKjCC,EAAW,IAAIC,sBAAqB,CAACC,EAASF,KAClDE,EAAQC,SAASC,IACf,GAAIA,EAAMC,eAAgB,CACxB,MAAMC,EAAMF,EAAMG,OAClBD,EAAIE,IAAMF,EAAIG,aAAa,YAC3BH,EAAII,gBAAgB,YACpBV,EAASW,UAAUL,EACrB,IACA,GAZY,CACdM,WAAY,MACZC,UAAW,KAYbhB,EAAKM,SAASG,IACRA,EAAIQ,aAAa,aACnBd,EAASe,QAAQT,EACnB,GAEJ","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
import{navigationState as e}from"../utils.js";export const navbarShrink={navbarDom:document.querySelector(".navbar-container"),leftAsideDom:document.querySelector(".page-aside"),isnavbarShrink:!1,navbarHeight:0,init(){this.navbarHeight=this.navbarDom.getBoundingClientRect().height,this.shrink(),this.togglenavbarDrawerShow(),this.toggleSubmenu(),window.addEventListener("scroll",(()=>{this.shrink()}))},shrink(){const e=document.documentElement.scrollTop||document.body.scrollTop;!this.isnavbarShrink&&e>this.navbarHeight?(this.isnavbarShrink=!0,document.body.classList.add("navbar-shrink")):this.isnavbarShrink&&e<=this.navbarHeight&&(this.isnavbarShrink=!1,document.body.classList.remove("navbar-shrink"))},togglenavbarDrawerShow(){const e=[document.querySelector(".window-mask"),document.querySelector(".navbar-bar")];document.querySelector(".navbar-drawer")&&e.push(...document.querySelectorAll(".navbar-drawer .drawer-navbar-list .drawer-navbar-item"),...document.querySelectorAll(".navbar-drawer .tag-count-item")),e.forEach((e=>{e.dataset.navbarInitialized||(e.dataset.navbarInitialized=1,e.addEventListener("click",(()=>{document.body.classList.toggle("navbar-drawer-show")})))}));const t=document.querySelector(".navbar-container .navbar-content .logo-title");t&&!t.dataset.navbarInitialized&&(t.dataset.navbarInitialized=1,t.addEventListener("click",(()=>{document.body.classList.remove("navbar-drawer-show")})))},toggleSubmenu(){document.querySelectorAll("[navbar-data-toggle]").forEach((e=>{e.dataset.eventListenerAdded||(e.dataset.eventListenerAdded="true",e.addEventListener("click",(function(){const e=document.querySelector('[data-target="'+this.getAttribute("navbar-data-toggle")+'"]'),t=e.children,a=this.querySelector(".fa-chevron-right");if(e){const n=!e.classList.contains("hidden");a&&a.classList.toggle("icon-rotated",!n),n?anime({targets:t,opacity:0,translateY:-10,duration:300,easing:"easeInQuart",delay:anime.stagger(80,{start:20,direction:"reverse"}),complete:function(){e.classList.add("hidden")}}):(e.classList.remove("hidden"),anime({targets:t,opacity:[0,1],translateY:[10,0],duration:300,easing:"easeOutQuart",delay:anime.stagger(80,{start:20})}))}})))}))}};try{swup.hooks.on("page:view",(()=>{navbarShrink.init(),e.isNavigating=!1})),swup.hooks.on("visit:start",(()=>{e.isNavigating=!0,document.body.classList.remove("navbar-shrink")}))}catch(e){}document.addEventListener("DOMContentLoaded",(()=>{navbarShrink.init()}));
//# sourceMappingURL=navbarShrink.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"navbarShrink.js","names":["navigationState","navbarShrink","navbarDom","document","querySelector","leftAsideDom","isnavbarShrink","navbarHeight","init","this","getBoundingClientRect","height","shrink","togglenavbarDrawerShow","toggleSubmenu","window","addEventListener","scrollTop","documentElement","body","classList","add","remove","domList","push","querySelectorAll","forEach","v","dataset","navbarInitialized","toggle","logoTitleDom","eventListenerAdded","target","getAttribute","submenuItems","children","icon","isVisible","contains","anime","targets","opacity","translateY","duration","easing","delay","stagger","start","direction","complete","swup","hooks","on","isNavigating","error"],"sources":["0"],"mappings":"0BAASA,MAAuB,qBAEzB,MAAMC,aAAe,CAC1BC,UAAWC,SAASC,cAAc,qBAClCC,aAAcF,SAASC,cAAc,eACrCE,gBAAgB,EAChBC,aAAc,EAEd,IAAAC,GACEC,KAAKF,aAAeE,KAAKP,UAAUQ,wBAAwBC,OAC3DF,KAAKG,SACLH,KAAKI,yBACLJ,KAAKK,gBACLC,OAAOC,iBAAiB,UAAU,KAChCP,KAAKG,QAAQ,GAEjB,EAEA,MAAAA,GACE,MAAMK,EACJd,SAASe,gBAAgBD,WAAad,SAASgB,KAAKF,WAEjDR,KAAKH,gBAAkBW,EAAYR,KAAKF,cAC3CE,KAAKH,gBAAiB,EACtBH,SAASgB,KAAKC,UAAUC,IAAI,kBACnBZ,KAAKH,gBAAkBW,GAAaR,KAAKF,eAClDE,KAAKH,gBAAiB,EACtBH,SAASgB,KAAKC,UAAUE,OAAO,iBAEnC,EAEA,sBAAAT,GACE,MAAMU,EAAU,CACdpB,SAASC,cAAc,gBACvBD,SAASC,cAAc,gBAGrBD,SAASC,cAAc,mBACzBmB,EAAQC,QACHrB,SAASsB,iBACV,6DAECtB,SAASsB,iBAAiB,mCAIjCF,EAAQG,SAASC,IACVA,EAAEC,QAAQC,oBACbF,EAAEC,QAAQC,kBAAoB,EAC9BF,EAAEX,iBAAiB,SAAS,KAC1Bb,SAASgB,KAAKC,UAAUU,OAAO,qBAAqB,IAExD,IAGF,MAAMC,EAAe5B,SAASC,cAC5B,iDAEE2B,IAAiBA,EAAaH,QAAQC,oBACxCE,EAAaH,QAAQC,kBAAoB,EACzCE,EAAaf,iBAAiB,SAAS,KACrCb,SAASgB,KAAKC,UAAUE,OAAO,qBAAqB,IAG1D,EAEA,aAAAR,GACyBX,SAASsB,iBAAiB,wBAElCC,SAASI,IACjBA,EAAOF,QAAQI,qBAClBF,EAAOF,QAAQI,mBAAqB,OACpCF,EAAOd,iBAAiB,SAAS,WAE/B,MAAMiB,EAAS9B,SAASC,cACtB,iBAAmBK,KAAKyB,aAAa,sBAAwB,MAEzDC,EAAeF,EAAOG,SACtBC,EAAO5B,KAAKL,cAAc,qBAEhC,GAAI6B,EAAQ,CACV,MAAMK,GAAaL,EAAOb,UAAUmB,SAAS,UAEzCF,GACFA,EAAKjB,UAAUU,OAAO,gBAAiBQ,GAGrCA,EAEFE,MAAM,CACJC,QAASN,EACTO,QAAS,EACTC,YAAa,GACbC,SAAU,IACVC,OAAQ,cACRC,MAAON,MAAMO,QAAQ,GAAI,CAAEC,MAAO,GAAIC,UAAW,YACjDC,SAAU,WACRjB,EAAOb,UAAUC,IAAI,SACvB,KAIFY,EAAOb,UAAUE,OAAO,UAExBkB,MAAM,CACJC,QAASN,EACTO,QAAS,CAAC,EAAG,GACbC,WAAY,CAAC,GAAI,GACjBC,SAAU,IACVC,OAAQ,eACRC,MAAON,MAAMO,QAAQ,GAAI,CAAEC,MAAO,OAGxC,CACF,IACF,GAEJ,GAGF,IACEG,KAAKC,MAAMC,GAAG,aAAa,KACzBpD,aAAaO,OACbR,EAAgBsD,cAAe,CAAK,IAGtCH,KAAKC,MAAMC,GAAG,eAAe,KAC3BrD,EAAgBsD,cAAe,EAC/BnD,SAASgB,KAAKC,UAAUE,OAAO,gBAAgB,GAEnD,CAAE,MAAOiC,GAAQ,CAEjBpD,SAASa,iBAAiB,oBAAoB,KAC5Cf,aAAaO,MAAM","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
import{initTocToggle as e}from"../tools/tocToggle.js";import{main as t}from"../main.js";export function initTOC(){const o={navItems:document.querySelectorAll(".post-toc-wrap .post-toc li"),updateActiveTOCLink(){if(!Array.isArray(o.sections))return;let e=o.sections.findIndex((e=>e&&e.getBoundingClientRect().top-100>0));-1===e?e=o.sections.length-1:e>0&&e--,this.activateTOCLink(e)},registerTOCScroll(){o.sections=[...document.querySelectorAll(".post-toc li a.nav-link")].map((e=>document.getElementById(decodeURI(e.getAttribute("href")).replace("#",""))))},activateTOCLink(e){const t=document.querySelectorAll(".post-toc li a.nav-link")[e];if(!t||t.classList.contains("active-current"))return;document.querySelectorAll(".post-toc .active").forEach((e=>{e.classList.remove("active","active-current")})),t.classList.add("active","active-current");const o=document.querySelector(".toc-content-container"),n=o.getBoundingClientRect().top,i=o.offsetHeight>window.innerHeight?(o.offsetHeight-window.innerHeight)/2:0,c=t.getBoundingClientRect().top-n-Math.max(document.documentElement.clientHeight,window.innerHeight||0)/2+t.offsetHeight/2-i,r=o.scrollTop+c;o.scrollTo({top:r,behavior:"smooth"})},showTOCAside(){const openHandle=()=>{const o=t.getStyleStatus(),n="isOpenPageAside";o&&o.hasOwnProperty(n)?e().pageAsideHandleOfTOC(o[n]):e().pageAsideHandleOfTOC(!0)},o="init_open";theme.articles.toc.hasOwnProperty(o)?theme.articles.toc[o]?openHandle():e().pageAsideHandleOfTOC(!1):openHandle()}};return o.navItems.length>0?(o.showTOCAside(),o.registerTOCScroll()):document.querySelectorAll(".toc-content-container, .toc-marker").forEach((e=>{e.remove()})),o}try{swup.hooks.on("page:view",(()=>{initTOC()}))}catch(o){}document.addEventListener("DOMContentLoaded",initTOC);
//# sourceMappingURL=toc.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"toc.js","names":["initTocToggle","main","initTOC","utils","navItems","document","querySelectorAll","updateActiveTOCLink","Array","isArray","sections","index","findIndex","element","getBoundingClientRect","top","length","this","activateTOCLink","registerTOCScroll","map","getElementById","decodeURI","getAttribute","replace","target","classList","contains","forEach","remove","add","tocElement","querySelector","tocTop","scrollTopOffset","offsetHeight","window","innerHeight","distanceToCenter","Math","max","documentElement","clientHeight","scrollTop","scrollTo","behavior","showTOCAside","openHandle","styleStatus","getStyleStatus","key","hasOwnProperty","pageAsideHandleOfTOC","initOpenKey","theme","articles","toc","elem","swup","hooks","on","e","addEventListener"],"sources":["0"],"mappings":"wBAESA,MAAqB,uCACrBC,MAAY,oBACd,SAASC,UACd,MAAMC,EAAQ,CACZC,SAAUC,SAASC,iBAAiB,+BAEpC,mBAAAC,GACE,IAAKC,MAAMC,QAAQN,EAAMO,UAAW,OACpC,IAAIC,EAAQR,EAAMO,SAASE,WAAWC,GAC7BA,GAAWA,EAAQC,wBAAwBC,IAAM,IAAM,KAEjD,IAAXJ,EACFA,EAAQR,EAAMO,SAASM,OAAS,EACvBL,EAAQ,GACjBA,IAEFM,KAAKC,gBAAgBP,EACvB,EAEA,iBAAAQ,GACEhB,EAAMO,SAAW,IACZL,SAASC,iBAAiB,4BAC7Bc,KAAKP,GACUR,SAASgB,eACtBC,UAAUT,EAAQU,aAAa,SAASC,QAAQ,IAAK,MAI3D,EAEA,eAAAN,CAAgBP,GACd,MAAMc,EAASpB,SAASC,iBAAiB,2BACvCK,GAGF,IAAKc,GAAUA,EAAOC,UAAUC,SAAS,kBACvC,OAGFtB,SAASC,iBAAiB,qBAAqBsB,SAASf,IACtDA,EAAQa,UAAUG,OAAO,SAAU,iBAAiB,IAEtDJ,EAAOC,UAAUI,IAAI,SAAU,kBAE/B,MAAMC,EAAa1B,SAAS2B,cAAc,0BACpCC,EAASF,EAAWjB,wBAAwBC,IAC5CmB,EACJH,EAAWI,aAAeC,OAAOC,aAC5BN,EAAWI,aAAeC,OAAOC,aAAe,EACjD,EAMAC,EALYb,EAAOX,wBAAwBC,IAAMkB,EAChCM,KAAKC,IAC1BnC,SAASoC,gBAAgBC,aACzBN,OAAOC,aAAe,GAIL,EACjBZ,EAAOU,aAAe,EACtBD,EACIS,EAAYZ,EAAWY,UAAYL,EAEzCP,EAAWa,SAAS,CAClB7B,IAAK4B,EACLE,SAAU,UAEd,EAEA,YAAAC,GACE,MAAMC,WAAa,KACjB,MAAMC,EAAc/C,EAAKgD,iBACnBC,EAAM,kBACRF,GAAeA,EAAYG,eAAeD,GAC5ClD,IAAgBoD,qBAAqBJ,EAAYE,IAEjDlD,IAAgBoD,sBAAqB,EACvC,EAGIC,EAAc,YAEhBC,MAAMC,SAASC,IAAIL,eAAeE,GACpCC,MAAMC,SAASC,IAAIH,GACfN,aACA/C,IAAgBoD,sBAAqB,GAEzCL,YAEJ,GAcF,OAXI5C,EAAMC,SAASY,OAAS,GAC1Bb,EAAM2C,eACN3C,EAAMgB,qBAENd,SACGC,iBAAiB,uCACjBsB,SAAS6B,IACRA,EAAK5B,QAAQ,IAIZ1B,CACT,CAGA,IACEuD,KAAKC,MAAMC,GAAG,aAAa,KACzB1D,SAAS,GAEb,CAAE,MAAO2D,GAAI,CAEbxD,SAASyD,iBAAiB,mBAAoB5D","ignoreList":[]}

2
public/js/build/libs/APlayer.min.js vendored Normal file

File diff suppressed because one or more lines are too long

2
public/js/build/libs/Swup.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t||self).SwupScriptsPlugin=e()}(this,function(){function t(){return t=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},t.apply(this,arguments)}const e=t=>String(t).split(".").map(t=>String(parseInt(t||"0",10))).concat(["0","0"]).slice(0,3).join(".");class r{constructor(){this.isSwupPlugin=!0,this.swup=void 0,this.version=void 0,this.requires={},this.handlersToUnregister=[]}mount(){}unmount(){this.handlersToUnregister.forEach(t=>t()),this.handlersToUnregister=[]}_beforeMount(){if(!this.name)throw new Error("You must define a name of plugin when creating a class.")}_afterUnmount(){}_checkRequirements(){return"object"!=typeof this.requires||Object.entries(this.requires).forEach(([t,r])=>{if(!function(t,r,n){const o=function(t,e){var r;if("swup"===t)return null!=(r=e.version)?r:"";{var n;const r=e.findPlugin(t);return null!=(n=null==r?void 0:r.version)?n:""}}(t,n);return!!o&&((t,r)=>r.every(r=>{const[,n,o]=r.match(/^([\D]+)?(.*)$/)||[];var s,i;return((t,e)=>{const r={"":t=>0===t,">":t=>t>0,">=":t=>t>=0,"<":t=>t<0,"<=":t=>t<=0};return(r[e]||r[""])(t)})((i=o,s=e(s=t),i=e(i),s.localeCompare(i,void 0,{numeric:!0})),n||">=")}))(o,r)}(t,r=Array.isArray(r)?r:[r],this.swup)){const e=`${t} ${r.join(", ")}`;throw new Error(`Plugin version mismatch: ${this.name} requires ${e}`)}}),!0}on(t,e,r={}){var n;e=!(n=e).name.startsWith("bound ")||n.hasOwnProperty("prototype")?e.bind(this):e;const o=this.swup.hooks.on(t,e,r);return this.handlersToUnregister.push(o),o}once(e,r,n={}){return this.on(e,r,t({},n,{once:!0}))}before(e,r,n={}){return this.on(e,r,t({},n,{before:!0}))}replace(e,r,n={}){return this.on(e,r,t({},n,{replace:!0}))}off(t,e){return this.swup.hooks.off(t,e)}}return class extends r{constructor(t){void 0===t&&(t={}),super(),this.name="SwupScriptsPlugin",this.requires={swup:">=4"},this.defaults={head:!0,body:!0,optin:!1},this.options={...this.defaults,...t}}mount(){this.on("content:replace",this.runScripts)}runScripts(){const{head:t,body:e,optin:r}=this.options,n=this.getScope({head:t,body:e});if(!n)return;const o=Array.from(n.querySelectorAll(r?"script[data-swup-reload-script]":"script:not([data-swup-ignore-script])"));o.forEach(t=>this.runScript(t)),this.swup.log(`Executed ${o.length} scripts.`)}runScript(t){const e=document.createElement("script");for(const{name:r,value:n}of t.attributes)e.setAttribute(r,n);return e.textContent=t.textContent,t.replaceWith(e),e}getScope(t){let{head:e,body:r}=t;return e&&r?document:e?document.head:r?document.body:null}}});

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).SwupSlideTheme=t()}(this,function(){function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},e.apply(this,arguments)}const t=e=>String(e).split(".").map(e=>String(parseInt(e||"0",10))).concat(["0","0"]).slice(0,3).join(".");class s{constructor(){this.isSwupPlugin=!0,this.swup=void 0,this.version=void 0,this.requires={},this.handlersToUnregister=[]}mount(){}unmount(){this.handlersToUnregister.forEach(e=>e()),this.handlersToUnregister=[]}_beforeMount(){if(!this.name)throw new Error("You must define a name of plugin when creating a class.")}_afterUnmount(){}_checkRequirements(){return"object"!=typeof this.requires||Object.entries(this.requires).forEach(([e,s])=>{if(!function(e,s,n){const r=function(e,t){var s;if("swup"===e)return null!=(s=t.version)?s:"";{var n;const s=t.findPlugin(e);return null!=(n=null==s?void 0:s.version)?n:""}}(e,n);return!!r&&((e,s)=>s.every(s=>{const[,n,r]=s.match(/^([\D]+)?(.*)$/)||[];var i,o;return((e,t)=>{const s={"":e=>0===e,">":e=>e>0,">=":e=>e>=0,"<":e=>e<0,"<=":e=>e<=0};return(s[t]||s[""])(e)})((o=r,i=t(i=e),o=t(o),i.localeCompare(o,void 0,{numeric:!0})),n||">=")}))(r,s)}(e,s=Array.isArray(s)?s:[s],this.swup)){const t=`${e} ${s.join(", ")}`;throw new Error(`Plugin version mismatch: ${this.name} requires ${t}`)}}),!0}on(e,t,s={}){var n;t=!(n=t).name.startsWith("bound ")||n.hasOwnProperty("prototype")?t.bind(this):t;const r=this.swup.hooks.on(e,t,s);return this.handlersToUnregister.push(r),r}once(t,s,n={}){return this.on(t,s,e({},n,{once:!0}))}before(t,s,n={}){return this.on(t,s,e({},n,{before:!0}))}replace(t,s,n={}){return this.on(t,s,e({},n,{replace:!0}))}off(e,t){return this.swup.hooks.off(e,t)}}class n extends s{constructor(...e){super(...e),this._addedStyleElements=[],this._addedHTMLContent=[],this._classNameAddedToElements=[],this._addClassNameToElement=()=>{this._classNameAddedToElements.forEach(e=>{Array.from(document.querySelectorAll(e.selector)).forEach(t=>{t.classList.add(`swup-transition-${e.name}`)})})}}_beforeMount(){this._originalAnimationSelectorOption=String(this.swup.options.animationSelector),this.swup.options.animationSelector='[class*="swup-transition-"]',this.swup.hooks.on("content:replace",this._addClassNameToElement)}_afterUnmount(){this.swup.options.animationSelector=this._originalAnimationSelectorOption,this._addedStyleElements.forEach(e=>{e.outerHTML="",e=null}),this._addedHTMLContent.forEach(e=>{e.outerHTML="",e=null}),this._classNameAddedToElements.forEach(e=>{Array.from(document.querySelectorAll(e.selector)).forEach(e=>{e.className.split(" ").forEach(t=>{new RegExp("^swup-transition-").test(t)&&e.classList.remove(t)})})}),this.swup.hooks.off("content:replace",this._addClassNameToElement)}applyStyles(e){const t=document.createElement("style");t.setAttribute("data-swup-theme",""),t.appendChild(document.createTextNode(e)),document.head.prepend(t),this._addedStyleElements.push(t)}applyHTML(e){const t=document.createElement("div");t.innerHTML=e,document.body.appendChild(t),this._addedHTMLContent.push(t)}addClassName(e,t){this._classNameAddedToElements.push({selector:e,name:t}),this._addClassNameToElement()}}return class extends n{constructor(e){void 0===e&&(e={}),super(),this.name="SwupSlideTheme",this.defaults={mainElement:"#swup",reversed:!1},this.options={...this.defaults,...e}}mount(){this.applyStyles("html{--swup-slide-theme-direction:1;--swup-slide-theme-translate:60px;--swup-slide-theme-duration-fade:.3s;--swup-slide-theme-duration-slide:.4s;--swup-slide-theme-translate-forward:calc(var(--swup-slide-theme-direction)*var(--swup-slide-theme-translate));--swup-slide-theme-translate-backward:calc(var(--swup-slide-theme-translate-forward)*-1)}html.swup-theme-reverse{--swup-slide-theme-direction:-1}html.is-changing .swup-transition-main{opacity:1;transform:translateZ(0);transition:opacity var(--swup-slide-theme-duration-fade),transform var(--swup-slide-theme-duration-slide)}html.is-animating .swup-transition-main{opacity:0;transform:translate3d(0,var(--swup-slide-theme-translate-backward),0)}html.is-animating.is-leaving .swup-transition-main{transform:translate3d(0,var(--swup-slide-theme-translate-forward),0)}"),this.addClassName(this.options.mainElement,"main"),this.options.reversed&&document.documentElement.classList.add("swup-theme-reverse")}unmount(){document.documentElement.classList.remove("swup-theme-reverse")}}});

10
public/js/build/libs/Typed.min.js vendored Normal file

File diff suppressed because one or more lines are too long

8
public/js/build/libs/anime.min.js vendored Normal file

File diff suppressed because one or more lines are too long

2314
public/js/build/libs/mermaid.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
var MiniMasonry=function(){"use strict";function t(t){return this._sizes=[],this._columns=[],this._container=null,this._count=null,this._width=0,this._removeListener=null,this._currentGutterX=null,this._currentGutterY=null,this._resizeTimeout=null,this.conf={baseWidth:255,gutterX:null,gutterY:null,gutter:10,container:null,minify:!0,ultimateGutter:5,surroundingGutter:!0,direction:"ltr",wedge:!1},this.init(t),this}return t.prototype.init=function(t){for(var i in this.conf)null!=t[i]&&(this.conf[i]=t[i]);if(null!=this.conf.gutterX&&null!=this.conf.gutterY||(this.conf.gutterX=this.conf.gutterY=this.conf.gutter),this._currentGutterX=this.conf.gutterX,this._currentGutterY=this.conf.gutterY,this._container="object"==typeof this.conf.container&&this.conf.container.nodeName?this.conf.container:document.querySelector(this.conf.container),!this._container)throw new Error("Container not found or missing");var e=this.resizeThrottler.bind(this);window.addEventListener("resize",e),this._removeListener=function(){window.removeEventListener("resize",e),null!=this._resizeTimeout&&(window.clearTimeout(this._resizeTimeout),this._resizeTimeout=null)},this.layout()},t.prototype.reset=function(){this._sizes=[],this._columns=[],this._count=null,this._width=this._container.clientWidth;var t=this.conf.baseWidth;this._width<t&&(this._width=t,this._container.style.minWidth=t+"px"),1==this.getCount()?(this._currentGutterX=this.conf.ultimateGutter,this._count=1):this._width<this.conf.baseWidth+2*this._currentGutterX?this._currentGutterX=0:this._currentGutterX=this.conf.gutterX},t.prototype.getCount=function(){return this.conf.surroundingGutter?Math.floor((this._width-this._currentGutterX)/(this.conf.baseWidth+this._currentGutterX)):Math.floor((this._width+this._currentGutterX)/(this.conf.baseWidth+this._currentGutterX))},t.prototype.computeWidth=function(){var t=this.conf.surroundingGutter?(this._width-this._currentGutterX)/this._count-this._currentGutterX:(this._width+this._currentGutterX)/this._count-this._currentGutterX;return t=Number.parseFloat(t.toFixed(2))},t.prototype.layout=function(){if(this._container){this.reset(),null==this._count&&(this._count=this.getCount());for(var t=this.computeWidth(),i=0;i<this._count;i++)this._columns[i]=0;for(var e,n,r=this._container.children,s=0;s<r.length;s++)r[s].style.width=t+"px",this._sizes[s]=r[s].clientHeight;e="ltr"==this.conf.direction?this.conf.surroundingGutter?this._currentGutterX:0:this._width-(this.conf.surroundingGutter?this._currentGutterX:0),this._count>this._sizes.length&&(n=this._sizes.length*(t+this._currentGutterX)-this._currentGutterX,!1===this.conf.wedge?e="ltr"==this.conf.direction?(this._width-n)/2:this._width-(this._width-n)/2:"ltr"==this.conf.direction||(e=this._width-this._currentGutterX));for(var o=0;o<r.length;o++){var h=this.conf.minify?this.getShortest():this.getNextColumn(o),u=0;!this.conf.surroundingGutter&&h==this._columns.length||(u=this._currentGutterX);var c="ltr"==this.conf.direction?e+(t+u)*h:e-(t+u)*h-t,u=this._columns[h];r[o].style.transform="translate3d("+Math.round(c)+"px,"+Math.round(u)+"px,0)",this._columns[h]+=this._sizes[o]+(1<this._count?this.conf.gutterY:this.conf.ultimateGutter)}this._container.style.height=this._columns[this.getLongest()]-this._currentGutterY+"px"}else console.error("Container not found")},t.prototype.getNextColumn=function(t){return t%this._columns.length},t.prototype.getShortest=function(){for(var t=0,i=0;i<this._count;i++)this._columns[i]<this._columns[t]&&(t=i);return t},t.prototype.getLongest=function(){for(var t=0,i=0;i<this._count;i++)this._columns[i]>this._columns[t]&&(t=i);return t},t.prototype.resizeThrottler=function(){this._resizeTimeout||(this._resizeTimeout=setTimeout(function(){this._resizeTimeout=null,this._container.clientWidth!=this._width&&this.layout()}.bind(this),33))},t.prototype.destroy=function(){"function"==typeof this._removeListener&&this._removeListener();for(var t=this._container.children,i=0;i<t.length;i++)t[i].style.removeProperty("width"),t[i].style.removeProperty("transform");this._container.style.removeProperty("height"),this._container.style.removeProperty("min-width")},t}();

File diff suppressed because one or more lines are too long

2
public/js/build/libs/moment.min.js vendored Normal file

File diff suppressed because one or more lines are too long

2
public/js/build/libs/odometer.min.js vendored Normal file

File diff suppressed because one or more lines are too long

9
public/js/build/libs/pangu.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1
public/js/build/libs/pjax.min.js vendored Normal file

File diff suppressed because one or more lines are too long

2
public/js/build/main.js Normal file
View File

@@ -0,0 +1,2 @@
import _ from"./utils.js";import e from"./plugins/typed.js";import t from"./tools/lightDarkSwitch.js";import o from"./layouts/lazyload.js";import r from"./tools/scrollTopBottom.js";import n from"./tools/localSearch.js";import a from"./tools/codeBlock.js";import i from"./layouts/bookmarkNav.js";export const main={themeInfo:{theme:`Redefine v${theme.version}`,author:"EvanNotFound",repository:"https://github.com/EvanNotFound/hexo-theme-redefine"},localStorageKey:"REDEFINE-THEME-STATUS",styleStatus:{isExpandPageWidth:!1,isDark:theme.colors.default_mode&&"dark"===theme.colors.default_mode,fontSizeLevel:0,isOpenPageAside:!0},printThemeInfo:()=>{console.log(' ______ __ __ ______ __ __ ______ \r\n /\\__ _/\\ \\_\\ \\/\\ ___\\/\\ "-./ \\/\\ ___\\ \r\n \\/_/\\ \\\\ \\ __ \\ \\ __\\\\ \\ \\-./\\ \\ \\ __\\ \r\n \\ \\_\\\\ \\_\\ \\_\\ \\_____\\ \\_\\ \\ \\_\\ \\_____\\ \r\n \\/_/ \\/_/\\/_/\\/_____/\\/_/ \\/_/\\/_____/ \r\n \r\n ______ ______ _____ ______ ______ __ __ __ ______ \r\n/\\ == \\/\\ ___\\/\\ __-./\\ ___\\/\\ ___/\\ \\/\\ "-.\\ \\/\\ ___\\ \r\n\\ \\ __<\\ \\ __\\\\ \\ \\/\\ \\ \\ __\\\\ \\ __\\ \\ \\ \\ \\-. \\ \\ __\\ \r\n \\ \\_\\ \\_\\ \\_____\\ \\____-\\ \\_____\\ \\_\\ \\ \\_\\ \\_\\\\"\\_\\ \\_____\\ \r\n \\/_/ /_/\\/_____/\\/____/ \\/_____/\\/_/ \\/_/\\/_/ \\/_/\\/_____/\r\n \r\n Github: https://github.com/EvanNotFound/hexo-theme-redefine')},setStyleStatus:()=>{localStorage.setItem(main.localStorageKey,JSON.stringify(main.styleStatus))},getStyleStatus:()=>{let _=localStorage.getItem(main.localStorageKey);if(_){_=JSON.parse(_);for(let e in main.styleStatus)main.styleStatus[e]=_[e];return _}return null},refresh:()=>{_(),t(),r(),i(),0!==theme.home_banner.subtitle.text.length&&location.pathname===config.root&&e("subtitle"),!0===theme.navbar.search.enable&&n(),!0===theme.articles.code_block.copy&&a(),!0===theme.articles.lazyload&&o()}};export function initMain(){main.printThemeInfo(),main.refresh()}document.addEventListener("DOMContentLoaded",initMain);try{swup.hooks.on("page:view",(()=>{main.refresh()}))}catch(s){}
//# sourceMappingURL=main.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"main.js","names":["initUtils","initTyped","initModeToggle","initLazyLoad","initScrollTopBottom","initLocalSearch","initCopyCode","initBookmarkNav","main","themeInfo","theme","version","author","repository","localStorageKey","styleStatus","isExpandPageWidth","isDark","colors","default_mode","fontSizeLevel","isOpenPageAside","printThemeInfo","console","log","setStyleStatus","localStorage","setItem","JSON","stringify","getStyleStatus","temp","getItem","parse","key","refresh","home_banner","subtitle","text","length","location","pathname","config","root","navbar","search","enable","articles","code_block","copy","lazyload","initMain","document","addEventListener","swup","hooks","on","e"],"sources":["0"],"mappings":"OACOA,MAAe,oBACfC,MAAe,4BACfC,MAAoB,oCACpBC,MAAkB,+BAClBC,MAAyB,oCACzBC,MAAqB,gCACrBC,MAAkB,8BAClBC,MAAqB,kCAErB,MAAMC,KAAO,CAClBC,UAAW,CACTC,MAAO,aAAaA,MAAMC,UAC1BC,OAAQ,eACRC,WAAY,uDAEdC,gBAAiB,wBACjBC,YAAa,CACXC,mBAAmB,EACnBC,OAAQP,MAAMQ,OAAOC,cAA8C,SAA9BT,MAAMQ,OAAOC,aAClDC,cAAe,EACfC,iBAAiB,GAEnBC,eAAgB,KACdC,QAAQC,IACN,m/BACD,EAEHC,eAAgB,KACdC,aAAaC,QACXnB,KAAKM,gBACLc,KAAKC,UAAUrB,KAAKO,aACrB,EAEHe,eAAgB,KACd,IAAIC,EAAOL,aAAaM,QAAQxB,KAAKM,iBACrC,GAAIiB,EAAM,CACRA,EAAOH,KAAKK,MAAMF,GAClB,IAAK,IAAIG,KAAO1B,KAAKO,YACnBP,KAAKO,YAAYmB,GAAOH,EAAKG,GAE/B,OAAOH,CACT,CACE,OAAO,IACT,EAEFI,QAAS,KACPnC,IACAE,IACAE,IACAG,IAG6C,IAA3CG,MAAM0B,YAAYC,SAASC,KAAKC,QAChCC,SAASC,WAAaC,OAAOC,MAE7B1C,EAAU,aAGuB,IAA/BS,MAAMkC,OAAOC,OAAOC,QACtBzC,KAGqC,IAAnCK,MAAMqC,SAASC,WAAWC,MAC5B3C,KAG8B,IAA5BI,MAAMqC,SAASG,UACjB/C,GACF,UAIG,SAASgD,WACd3C,KAAKc,iBACLd,KAAK2B,SACP,CAEAiB,SAASC,iBAAiB,mBAAoBF,UAE9C,IACEG,KAAKC,MAAMC,GAAG,aAAa,KACzBhD,KAAK2B,SAAS,GAElB,CAAE,MAAOsB,GAAI","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
!function(){const e=[],t="fixed"===theme.plugins.aplayer.type,n="mini"===theme.plugins.aplayer.type;for(const t of theme.plugins.aplayer.audios){const n={name:t.name,artist:t.artist,url:t.url,cover:t.cover,lrc:t.lrc,theme:t.theme};e.push(n)}if(n)new APlayer({container:document.getElementById("aplayer"),mini:!0,audio:e});else if(t){new APlayer({container:document.getElementById("aplayer"),fixed:!0,lrcType:3,audio:e});document.querySelector(".aplayer-icon-lrc").click()}}();
//# sourceMappingURL=aplayer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"aplayer.js","names":["audioList","isFixed","theme","plugins","aplayer","type","isMini","audio","audios","audioObj","name","artist","url","cover","lrc","push","APlayer","container","document","getElementById","mini","fixed","lrcType","querySelector","click"],"sources":["0"],"mappings":"CAAA,WACE,MAAMA,EAAY,GACZC,EAAyC,UAA/BC,MAAMC,QAAQC,QAAQC,KAChCC,EAAwC,SAA/BJ,MAAMC,QAAQC,QAAQC,KAErC,IAAK,MAAME,KAASL,MAAMC,QAAQC,QAAQI,OAAQ,CAChD,MAAMC,EAAW,CACfC,KAAMH,EAAMG,KACZC,OAAQJ,EAAMI,OACdC,IAAKL,EAAMK,IACXC,MAAON,EAAMM,MACbC,IAAKP,EAAMO,IACXZ,MAAOK,EAAML,OAEfF,EAAUe,KAAKN,EACjB,CAEA,GAAIH,EACF,IAAIU,QAAQ,CACVC,UAAWC,SAASC,eAAe,WACnCC,MAAM,EACNb,MAAOP,SAEJ,GAAIC,EAAS,CACH,IAAIe,QAAQ,CACzBC,UAAWC,SAASC,eAAe,WACnCE,OAAO,EACPC,QAAS,EACTf,MAAOP,IAETkB,SAASK,cAAc,qBAAqBC,OAC9C,CACD,CAhCD","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
import{main as e}from"../main.js";import{initTOC as t}from"../layouts/toc.js";export function initHBE(){const n=window.crypto||window.msCrypto,r=window.localStorage,o="hexo-blog-encrypt:#"+window.location.pathname,a=textToArray("too young too simple"),i=textToArray("sometimes naive!"),c=document.getElementById("hexo-blog-encrypt"),s=c.dataset.wpm,l=c.dataset.whm,y=c.getElementsByTagName("script").hbeData,d=y.innerText,u=y.dataset.hmacdigest;function hexToArray(e){return new Uint8Array(e.match(/[\da-f]{2}/gi).map((e=>parseInt(e,16))))}function textToArray(e){for(var t=e.length,n=0,r=new Array,o=0;o<t;){var a=e.codePointAt(o);a<128?(r[n++]=a,o++):a>127&&a<2048?(r[n++]=a>>6|192,r[n++]=63&a|128,o++):a>2047&&a<65536?(r[n++]=a>>12|224,r[n++]=a>>6&63|128,r[n++]=63&a|128,o++):(r[n++]=a>>18|240,r[n++]=a>>12&63|128,r[n++]=a>>6&63|128,r[n++]=63&a|128,o+=2)}return new Uint8Array(r)}function arrayBufferToHex(e){if("object"!=typeof e||null===e||"number"!=typeof e.byteLength)throw new TypeError("Expected input to be an ArrayBuffer");for(var t,n=new Uint8Array(e),r="",o=0;o<n.length;o++)r+=1===(t=n[o].toString(16)).length?"0"+t:t;return r}async function convertHTMLToElement(e){let t=document.createElement("div");return t.innerHTML=e,t.querySelectorAll("script").forEach((async e=>{e.replaceWith(await async function getExecutableScript(e){let t=document.createElement("script");return["type","text","src","crossorigin","defer","referrerpolicy"].forEach((n=>{e[n]&&(t[n]=e[n])})),t}(e))})),t}async function decrypt(r,a,i){let c=hexToArray(d);return await n.subtle.decrypt({name:"AES-CBC",iv:a},r,c.buffer).then((async r=>{const a=(new TextDecoder).decode(r);if(!a.startsWith("<hbe-prefix></hbe-prefix>"))throw"Decode successfully but not start with KnownPrefix.";const c=document.createElement("button");c.textContent="Encrypt again",c.type="button",c.classList.add("hbe-button"),c.addEventListener("click",(()=>{window.localStorage.removeItem(o),window.location.reload()})),document.getElementById("hexo-blog-encrypt").style.display="inline",document.getElementById("hexo-blog-encrypt").innerHTML="",document.getElementById("hexo-blog-encrypt").appendChild(await convertHTMLToElement(a)),document.getElementById("hexo-blog-encrypt").appendChild(c),document.querySelectorAll("img").forEach((e=>{e.getAttribute("data-src")&&!e.src&&(e.src=e.getAttribute("data-src"))})),e.refresh(),t();var s=new Event("hexo-blog-decrypt");return window.dispatchEvent(s),await async function verifyContent(e,t){const r=(new TextEncoder).encode(t);let o=hexToArray(u);const a=await n.subtle.verify({name:"HMAC",hash:"SHA-256"},e,o,r);return console.log(`Verification result: ${a}`),a||(alert(l),console.log(`${l}, got `,o," but proved wrong.")),a}(i,a)})).catch((e=>(alert(s),console.log(e),!1)))}!function hbeLoader(){const e=JSON.parse(r.getItem(o));if(e){console.log(`Password got from localStorage(${o}): `,e);const t=hexToArray(e.iv).buffer,a=e.dk,i=e.hmk;n.subtle.importKey("jwk",a,{name:"AES-CBC",length:256},!0,["decrypt"]).then((e=>{n.subtle.importKey("jwk",i,{name:"HMAC",hash:"SHA-256",length:256},!0,["verify"]).then((n=>{decrypt(e,t,n).then((e=>{e||r.removeItem(o)}))}))}))}c.addEventListener("keydown",(async e=>{if(e.isComposing||"Enter"===e.key){const e=document.getElementById("hbePass").value,t=await function getKeyMaterial(e){let t=new TextEncoder;return n.subtle.importKey("raw",t.encode(e),{name:"PBKDF2"},!1,["deriveKey","deriveBits"])}(e),c=await function getHmacKey(e){return n.subtle.deriveKey({name:"PBKDF2",hash:"SHA-256",salt:a.buffer,iterations:1024},e,{name:"HMAC",hash:"SHA-256",length:256},!0,["verify"])}(t),s=await function getDecryptKey(e){return n.subtle.deriveKey({name:"PBKDF2",hash:"SHA-256",salt:a.buffer,iterations:1024},e,{name:"AES-CBC",length:256},!0,["decrypt"])}(t),l=await function getIv(e){return n.subtle.deriveBits({name:"PBKDF2",hash:"SHA-256",salt:i.buffer,iterations:512},e,128)}(t);decrypt(s,l,c).then((e=>{console.log(`Decrypt result: ${e}`),e&&n.subtle.exportKey("jwk",s).then((e=>{n.subtle.exportKey("jwk",c).then((t=>{const n={dk:e,iv:arrayBufferToHex(l),hmk:t};r.setItem(o,JSON.stringify(n))}))}))}))}}))}()}
//# sourceMappingURL=hbe.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export function initMasonry(){var n=document.querySelector(".loading-placeholder"),e=document.querySelector("#masonry-container");if(n&&e){n.style.display="block",e.style.display="none";for(var t=document.querySelectorAll("#masonry-container .masonry-item img"),o=0,a=0;a<t.length;a++){var i=t[a];i.complete?onImageLoad():i.addEventListener("load",onImageLoad)}o===t.length&&initializeMasonryLayout()}function onImageLoad(){++o===t.length&&initializeMasonryLayout()}function initializeMasonryLayout(){n.style.opacity=0,setTimeout((()=>{var t;n.style.display="none",e.style.display="block",t=window.innerWidth>=768?255:150,new MiniMasonry({baseWidth:t,container:e,gutterX:10,gutterY:10,surroundingGutter:!1}).layout(),e.style.opacity=1}),100)}}if(data.masonry){try{swup.hooks.on("page:view",initMasonry)}catch(n){}document.addEventListener("DOMContentLoaded",initMasonry)}
//# sourceMappingURL=masonry.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"masonry.js","names":["initMasonry","loadingPlaceholder","document","querySelector","masonryContainer","style","display","images","querySelectorAll","loadedCount","i","length","img","complete","onImageLoad","addEventListener","initializeMasonryLayout","opacity","setTimeout","baseWidth","window","innerWidth","MiniMasonry","container","gutterX","gutterY","surroundingGutter","layout","data","masonry","swup","hooks","on","e"],"sources":["0"],"mappings":"OAAO,SAASA,cACd,IAAIC,EAAqBC,SAASC,cAAc,wBAC5CC,EAAmBF,SAASC,cAAc,sBAC9C,GAAKF,GAAuBG,EAA5B,CAEAH,EAAmBI,MAAMC,QAAU,QACnCF,EAAiBC,MAAMC,QAAU,OAcjC,IAZA,IAAIC,EAASL,SAASM,iBACpB,wCAEEC,EAAc,EASTC,EAAI,EAAGA,EAAIH,EAAOI,OAAQD,IAAK,CACtC,IAAIE,EAAML,EAAOG,GACbE,EAAIC,SACNC,cAEAF,EAAIG,iBAAiB,OAAQD,YAEjC,CAEIL,IAAgBF,EAAOI,QACzBK,yBA3BkD,CAUpD,SAASF,gBACPL,IACoBF,EAAOI,QACzBK,yBAEJ,CAcA,SAASA,0BACPf,EAAmBI,MAAMY,QAAU,EACnCC,YAAW,KAGT,IACIC,EAHJlB,EAAmBI,MAAMC,QAAU,OACnCF,EAAiBC,MAAMC,QAAU,QAI/Ba,EAHgBC,OAAOC,YAEN,IACL,IAEA,IAEA,IAAIC,YAAY,CAC5BH,UAAWA,EACXI,UAAWnB,EACXoB,QAAS,GACTC,QAAS,GACTC,mBAAmB,IAEbC,SACRvB,EAAiBC,MAAMY,QAAU,CAAC,GACjC,IACL,CACF,CAEA,GAAIW,KAAKC,QAAS,CAChB,IACEC,KAAKC,MAAMC,GAAG,YAAahC,YAC7B,CAAE,MAAOiC,GAAI,CAEb/B,SAASa,iBAAiB,mBAAoBf,YAChD","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
if(!0===theme.plugins.mermaid.enable)try{swup.hooks.on("page:view",(()=>{mermaid.initialize()}))}catch(e){}
//# sourceMappingURL=mermaid.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"mermaid.js","names":["theme","plugins","mermaid","enable","swup","hooks","on","initialize","e"],"sources":["0"],"mappings":"AAAA,IAAqC,IAAjCA,MAAMC,QAAQC,QAAQC,OACxB,IACEC,KAAKC,MAAMC,GAAG,aAAa,KACzBJ,QAAQK,YAAY,GAExB,CAAE,MAAOC,GAAI","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
function initPanguJS(){pangu.spacingElementByClassName("markdown-body"),pangu.autoSpacingPage()}document.addEventListener("DOMContentLoaded",initPanguJS);try{swup.hooks.on("page:view",initPanguJS)}catch(n){}
//# sourceMappingURL=pangu.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"pangu.js","names":["initPanguJS","pangu","spacingElementByClassName","autoSpacingPage","document","addEventListener","swup","hooks","on","e"],"sources":["0"],"mappings":"AAAA,SAASA,cAEPC,MAAMC,0BAA0B,iBAEhCD,MAAME,iBACR,CAEAC,SAASC,iBAAiB,mBAAoBL,aAE9C,IACEM,KAAKC,MAAMC,GAAG,YAAaR,YAC7B,CAAE,MAAOS,GAAI","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
function setTabs(){let e=document.querySelectorAll(".tabs .nav-tabs");e&&e.forEach((e=>{e.querySelectorAll("a").forEach((e=>{e.addEventListener("click",(e=>{e.preventDefault(),e.stopPropagation();const t=e.target.parentElement.parentElement.parentElement;return t.querySelector(".nav-tabs .active").classList.remove("active"),e.target.parentElement.classList.add("active"),t.querySelector(".tab-content .active").classList.remove("active"),t.querySelector(e.target.className).classList.add("active"),!1}))}))}))}try{swup.hooks.on("page:view",setTabs)}catch(e){}document.addEventListener("DOMContentLoaded",setTabs);
//# sourceMappingURL=tabs.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"tabs.js","names":["setTabs","tabs","document","querySelectorAll","forEach","tab","link","addEventListener","e","preventDefault","stopPropagation","parentTab","target","parentElement","querySelector","classList","remove","add","className","swup","hooks","on"],"sources":["0"],"mappings":"AAAA,SAASA,UACP,IAAIC,EAAOC,SAASC,iBAAiB,mBAChCF,GAELA,EAAKG,SAASC,IACZA,EAAIF,iBAAiB,KAAKC,SAASE,IACjCA,EAAKC,iBAAiB,SAAUC,IAC9BA,EAAEC,iBACFD,EAAEE,kBAEF,MAAMC,EAAYH,EAAEI,OAAOC,cAAcA,cAAcA,cAQvD,OAPAF,EAAUG,cAAc,qBAAqBC,UAAUC,OAAO,UAC9DR,EAAEI,OAAOC,cAAcE,UAAUE,IAAI,UACrCN,EACGG,cAAc,wBACdC,UAAUC,OAAO,UACpBL,EAAUG,cAAcN,EAAEI,OAAOM,WAAWH,UAAUE,IAAI,WAEnD,CAAK,GACZ,GACF,GAEN,CAEA,IACEE,KAAKC,MAAMC,GAAG,YAAarB,QAC7B,CAAE,MAAOQ,GAAI,CAEbN,SAASK,iBAAiB,mBAAoBP","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
export const config={usrTypeSpeed:theme.home_banner.subtitle.typing_speed,usrBackSpeed:theme.home_banner.subtitle.backing_speed,usrBackDelay:theme.home_banner.subtitle.backing_delay,usrStartDelay:theme.home_banner.subtitle.starting_delay,usrLoop:theme.home_banner.subtitle.loop,usrSmartBackspace:theme.home_banner.subtitle.smart_backspace,usrHitokotoAPI:theme.home_banner.subtitle.hitokoto.api};export default function initTyped(e){const{usrTypeSpeed:t,usrBackSpeed:o,usrBackDelay:a,usrStartDelay:n,usrLoop:s,usrSmartBackspace:r,usrHitokotoAPI:i}=config;function typing(i){new Typed("#"+e,{strings:[i],typeSpeed:t||100,smartBackspace:r||!1,backSpeed:o||80,backDelay:a||1500,loop:s||!1,startDelay:n||500})}if(theme.home_banner.subtitle.hitokoto.enable)fetch(i).then((e=>e.json())).then((e=>{e.from_who&&theme.home_banner.subtitle.hitokoto.show_author?typing(e.hitokoto+"——"+e.from_who):typing(e.hitokoto)})).catch(console.error);else{const i=[...theme.home_banner.subtitle.text];if(document.getElementById(e)){new Typed("#"+e,{strings:i,typeSpeed:t||100,smartBackspace:r||!1,backSpeed:o||80,backDelay:a||1500,loop:s||!1,startDelay:n||500})}}}
//# sourceMappingURL=typed.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"typed.js","names":["config","usrTypeSpeed","theme","home_banner","subtitle","typing_speed","usrBackSpeed","backing_speed","usrBackDelay","backing_delay","usrStartDelay","starting_delay","usrLoop","loop","usrSmartBackspace","smart_backspace","usrHitokotoAPI","hitokoto","api","initTyped","id","typing","dataList","Typed","strings","typeSpeed","smartBackspace","backSpeed","backDelay","startDelay","enable","fetch","then","response","json","data","from_who","show_author","catch","console","error","sentenceList","text","document","getElementById"],"sources":["0"],"mappings":"OAGO,MAAMA,OAAS,CACpBC,aAAcC,MAAMC,YAAYC,SAASC,aACzCC,aAAcJ,MAAMC,YAAYC,SAASG,cACzCC,aAAcN,MAAMC,YAAYC,SAASK,cACzCC,cAAeR,MAAMC,YAAYC,SAASO,eAC1CC,QAASV,MAAMC,YAAYC,SAASS,KACpCC,kBAAmBZ,MAAMC,YAAYC,SAASW,gBAC9CC,eAAgBd,MAAMC,YAAYC,SAASa,SAASC,oBAGvC,SAASC,UAAUC,GAChC,MAAMnB,aACJA,EAAYK,aACZA,EAAYE,aACZA,EAAYE,cACZA,EAAaE,QACbA,EAAOE,kBACPA,EAAiBE,eACjBA,GACEhB,OAEJ,SAASqB,OAAOC,GACH,IAAIC,MAAM,IAAMH,EAAI,CAC7BI,QAAS,CAACF,GACVG,UAAWxB,GAAgB,IAC3ByB,eAAgBZ,IAAqB,EACrCa,UAAWrB,GAAgB,GAC3BsB,UAAWpB,GAAgB,KAC3BK,KAAMD,IAAW,EACjBiB,WAAYnB,GAAiB,KAEjC,CAEA,GAAIR,MAAMC,YAAYC,SAASa,SAASa,OACtCC,MAAMf,GACHgB,MAAMC,GAAaA,EAASC,SAC5BF,MAAMG,IACDA,EAAKC,UAAYlC,MAAMC,YAAYC,SAASa,SAASoB,YACvDhB,OAAOc,EAAKlB,SAAW,KAAOkB,EAAKC,UAEnCf,OAAOc,EAAKlB,SACd,IAEDqB,MAAMC,QAAQC,WACZ,CACL,MAAMC,EAAe,IAAIvC,MAAMC,YAAYC,SAASsC,MACpD,GAAIC,SAASC,eAAexB,GAAK,CACpB,IAAIG,MAAM,IAAMH,EAAI,CAC7BI,QAASiB,EACThB,UAAWxB,GAAgB,IAC3ByB,eAAgBZ,IAAqB,EACrCa,UAAWrB,GAAgB,GAC3BsB,UAAWpB,GAAgB,KAC3BK,KAAMD,IAAW,EACjBiB,WAAYnB,GAAiB,KAEjC,CACF,CACF","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
export default()=>{HTMLElement.prototype.wrap=function(e){this.parentNode.insertBefore(e,this),this.parentNode.removeChild(this),e.appendChild(this)},document.querySelectorAll("figure.highlight").forEach((e=>{const t=document.createElement("div");e.wrap(t),t.classList.add("highlight-container"),t.insertAdjacentHTML("beforeend",'<div class="copy-button"><i class="fa-regular fa-copy"></i></div>'),t.insertAdjacentHTML("beforeend",'<div class="fold-button"><i class="fa-solid fa-chevron-down"></i></div>');const o=t.querySelector(".copy-button"),a=t.querySelector(".fold-button");o.addEventListener("click",(()=>{const e=[...t.querySelectorAll(".code .line")].map((e=>e.innerText)).join("\n");navigator.clipboard.writeText(e),o.querySelector("i").className="fa-regular fa-check",setTimeout((()=>{o.querySelector("i").className="fa-regular fa-copy"}),1e3)})),a.addEventListener("click",(()=>{t.classList.toggle("folded"),a.querySelector("i").className=t.classList.contains("folded")?"fa-solid fa-chevron-up":"fa-solid fa-chevron-down"}))}))};
//# sourceMappingURL=codeBlock.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"codeBlock.js","names":["HTMLElement","prototype","wrap","wrapper","this","parentNode","insertBefore","removeChild","appendChild","document","querySelectorAll","forEach","element","container","createElement","classList","add","insertAdjacentHTML","copyButton","querySelector","foldButton","addEventListener","code","map","line","innerText","join","navigator","clipboard","writeText","className","setTimeout","toggle","contains"],"sources":["0"],"mappings":"cAAqB,KACnBA,YAAYC,UAAUC,KAAO,SAAUC,GACrCC,KAAKC,WAAWC,aAAaH,EAASC,MACtCA,KAAKC,WAAWE,YAAYH,MAC5BD,EAAQK,YAAYJ,KACtB,EAEAK,SAASC,iBAAiB,oBAAoBC,SAASC,IACrD,MAAMC,EAAYJ,SAASK,cAAc,OACzCF,EAAQV,KAAKW,GACbA,EAAUE,UAAUC,IAAI,uBACxBH,EAAUI,mBACR,YACA,qEAEFJ,EAAUI,mBACR,YACA,2EAEF,MAAMC,EAAaL,EAAUM,cAAc,gBACrCC,EAAaP,EAAUM,cAAc,gBAC3CD,EAAWG,iBAAiB,SAAS,KACnC,MACMC,EADY,IAAIT,EAAUH,iBAAiB,gBAC1Ba,KAAKC,GAASA,EAAKC,YAAWC,KAAK,MAG1DC,UAAUC,UAAUC,UAAUP,GAG9BJ,EAAWC,cAAc,KAAKW,UAAY,sBAG1CC,YAAW,KACTb,EAAWC,cAAc,KAAKW,UAAY,oBAAoB,GAC7D,IAAK,IAEVV,EAAWC,iBAAiB,SAAS,KACnCR,EAAUE,UAAUiB,OAAO,UAC3BZ,EAAWD,cAAc,KAAKW,UAAYjB,EAAUE,UAAUkB,SAC5D,UAEE,yBACA,0BAA0B,GAC9B,GACF","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
export default function imageViewer(){let e=!1,t=1,n=!1,r=!1,i=0,o=0,s=0,a=0,c=0;const l=document.querySelector(".image-viewer-container");if(!l)return void console.warn("Image viewer container not found. Exiting imageViewer function.");const d=l.querySelector("img");if(!d)return void console.warn("Target image not found in image viewer container. Exiting imageViewer function.");const showHandle=e=>{document.body.style.overflow=e?"hidden":"auto",e?l.classList.add("active"):l.classList.remove("active")};let u=0;const dragEndHandle=e=>{n&&e.stopPropagation(),n=!1,d.style.cursor="grab"};d.addEventListener("wheel",(e=>{e.preventDefault();const n=d.getBoundingClientRect(),r=e.clientX-n.left,i=e.clientY-n.top,o=r-n.width/2,s=i-n.height/2,l=t;t+=-.001*e.deltaY,t=Math.min(Math.max(.8,t),4),l<t?(a-=o*(t-l),c-=s*(t-l)):(a=0,c=0),d.style.transform=`translate(${a}px, ${c}px) scale(${t})`}),{passive:!1}),d.addEventListener("mousedown",(e=>{e.preventDefault(),n=!0,o=e.clientX,s=e.clientY,d.style.cursor="grabbing"}),{passive:!1}),d.addEventListener("mousemove",(e=>{if(n){const n=(new Date).getTime();if(n-u<100)return;u=n;const i=e.clientX-o,l=e.clientY-s;a+=i,c+=l,o=e.clientX,s=e.clientY,d.style.transform=`translate(${a}px, ${c}px) scale(${t})`,r=!0}}),{passive:!1}),d.addEventListener("mouseup",dragEndHandle,{passive:!1}),d.addEventListener("mouseleave",dragEndHandle,{passive:!1}),l.addEventListener("click",(n=>{r||(e=!1,showHandle(e),t=1,a=0,c=0,d.style.transform=`translate(${a}px, ${c}px) scale(${t})`),r=!1}));const m=document.querySelectorAll(".markdown-body img, .masonry-item img, #shuoshuo-content img"),escapeKeyListener=n=>{"Escape"===n.key&&e&&(e=!1,showHandle(e),t=1,a=0,c=0,d.style.transform=`translate(${a}px, ${c}px) scale(${t})`,document.removeEventListener("keydown",escapeKeyListener))};if(m.length>0){m.forEach(((t,n)=>{t.addEventListener("click",(()=>{i=n,e=!0,showHandle(e),d.src=t.src,document.addEventListener("keydown",escapeKeyListener)}))}));const handleArrowKeys=t=>{if(!e)return;if("ArrowUp"===t.key||"ArrowLeft"===t.key)i=(i-1+m.length)%m.length;else{if("ArrowDown"!==t.key&&"ArrowRight"!==t.key)return;i=(i+1)%m.length}const n=m[i];let r=n.src;n.hasAttribute("lazyload")&&(r=n.getAttribute("data-src"),n.src=r,n.removeAttribute("lazyload")),d.src=r};document.addEventListener("keydown",handleArrowKeys)}}
//# sourceMappingURL=imageViewer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"imageViewer.js","names":["imageViewer","isBigImage","scale","isMouseDown","dragged","currentImgIndex","lastMouseX","lastMouseY","translateX","translateY","maskDom","document","querySelector","console","warn","targetImg","showHandle","isShow","body","style","overflow","classList","add","remove","lastTime","dragEndHandle","event","stopPropagation","cursor","addEventListener","preventDefault","rect","getBoundingClientRect","offsetX","clientX","left","offsetY","clientY","top","dx","width","dy","height","oldScale","deltaY","Math","min","max","transform","passive","currentTime","Date","getTime","deltaX","imgDoms","querySelectorAll","escapeKeyListener","key","removeEventListener","length","forEach","img","index","src","handleArrowKeys","currentImg","newSrc","hasAttribute","getAttribute","removeAttribute"],"sources":["0"],"mappings":"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","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
import{main as e}from"../main.js";const t=".mermaid";export const ModeToggle={modeToggleButton_dom:null,iconDom:null,mermaidLightTheme:null,mermaidDarkTheme:null,async mermaidInit(e){window.mermaid&&(await new Promise(((e,i)=>{try{var o=document.querySelectorAll(t),a=o.length;o.forEach((t=>{null!=t.getAttribute("data-original-code")&&(t.removeAttribute("data-processed"),t.innerHTML=t.getAttribute("data-original-code")),0==--a&&e()}))}catch(e){i(e)}})),mermaid.initialize({theme:e}),mermaid.init({theme:e},document.querySelectorAll(t)))},enableLightMode(){document.body.classList.remove("dark-mode"),document.documentElement.classList.remove("dark"),document.body.classList.add("light-mode"),document.documentElement.classList.add("light"),this.iconDom.className="fa-regular fa-moon",e.styleStatus.isDark=!1,e.setStyleStatus(),this.mermaidInit(this.mermaidLightTheme),this.setGiscusTheme()},enableDarkMode(){document.body.classList.remove("light-mode"),document.documentElement.classList.remove("light"),document.body.classList.add("dark-mode"),document.documentElement.classList.add("dark"),this.iconDom.className="fa-regular fa-brightness",e.styleStatus.isDark=!0,e.setStyleStatus(),this.mermaidInit(this.mermaidDarkTheme),this.setGiscusTheme()},async setGiscusTheme(t){if(document.querySelector("#giscus-container")){let i=document.querySelector("iframe.giscus-frame");for(;!i;)await new Promise((e=>setTimeout(e,1e3))),i=document.querySelector("iframe.giscus-frame");for(;i.classList.contains("giscus-frame--loading");)await new Promise((e=>setTimeout(e,1e3)));t??=e.styleStatus.isDark?"dark":"light",i.contentWindow.postMessage({giscus:{setConfig:{theme:t}}},"https://giscus.app")}},isDarkPrefersColorScheme:()=>window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)"),initModeStatus(){const t=e.getStyleStatus();t?t.isDark?this.enableDarkMode():this.enableLightMode():this.isDarkPrefersColorScheme().matches?this.enableDarkMode():this.enableLightMode()},initModeToggleButton(){this.modeToggleButton_dom.addEventListener("click",(()=>{document.body.classList.contains("dark-mode")?this.enableLightMode():this.enableDarkMode()}))},initModeAutoTrigger(){this.isDarkPrefersColorScheme().addEventListener("change",(e=>{e.matches?this.enableDarkMode():this.enableLightMode()}))},async init(){this.modeToggleButton_dom=document.querySelector(".tool-dark-light-toggle"),this.iconDom=document.querySelector(".tool-dark-light-toggle i"),this.mermaidLightTheme=void 0!==theme.mermaid&&void 0!==theme.mermaid.style&&void 0!==theme.mermaid.style.light?theme.mermaid.style.light:"default",this.mermaidDarkTheme=void 0!==theme.mermaid&&void 0!==theme.mermaid.style&&void 0!==theme.mermaid.style.dark?theme.mermaid.style.dark:"dark",this.initModeStatus(),this.initModeToggleButton(),this.initModeAutoTrigger();try{await new Promise(((e,i)=>{try{var o=document.querySelectorAll(t),a=o.length;o.forEach((t=>{t.setAttribute("data-original-code",t.innerHTML),0==--a&&e()}))}catch(e){i(e)}})).catch(console.error)}catch(e){}}};export default function initModeToggle(){ModeToggle.init()}
//# sourceMappingURL=lightDarkSwitch.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"lightDarkSwitch.js","names":["main","elementCode","ModeToggle","modeToggleButton_dom","iconDom","mermaidLightTheme","mermaidDarkTheme","mermaidInit","theme","window","mermaid","Promise","resolve","reject","els","document","querySelectorAll","count","length","forEach","element","getAttribute","removeAttribute","innerHTML","error","initialize","init","enableLightMode","body","classList","remove","documentElement","add","this","className","styleStatus","isDark","setStyleStatus","setGiscusTheme","enableDarkMode","querySelector","giscusFrame","r","setTimeout","contains","contentWindow","postMessage","giscus","setConfig","isDarkPrefersColorScheme","matchMedia","initModeStatus","getStyleStatus","matches","initModeToggleButton","addEventListener","initModeAutoTrigger","e","style","light","dark","setAttribute","catch","console","initModeToggle"],"sources":["0"],"mappings":"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","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
export default function initLocalSearch(){let e=config.path;if(!e)return void console.warn("`hexo-generator-searchdb` plugin is not installed!");let t,n=!1,o=!0;0===e.length?e="search.xml":e.endsWith("json")&&(o=!1);const r=document.querySelector(".search-input"),l=document.getElementById("search-result"),getIndexByWord=(e,t,n)=>{let o=e.length;if(0===o)return[];let r=0,l=[],s=[];for(n||(t=t.toLowerCase(),e=e.toLowerCase());(l=t.indexOf(e,r))>-1;)s.push({position:l,word:e}),r=l+o;return s},mergeIntoSlice=(e,t,n,o)=>{let r=n[n.length-1],{position:l,word:s}=r,i=[],a=0;for(;l+s.length<=t&&0!==n.length;){s===o&&a++,i.push({position:l,length:s.length});const e=l+s.length;n.pop();for(let t=n.length-1;t>=0&&(r=n[t],l=r.position,s=r.word,!(e<=l));t--)n.pop()}return{hits:i,start:e,end:t,searchTextCount:a}},highlightKeyword=(e,t)=>{let n="",o=t.start;return t.hits.forEach((t=>{n+=e.substring(o,t.position);let r=t.position+t.length;n+=`<b class="search-keyword">${e.substring(t.position,r)}</b>`,o=r})),n+=e.substring(o,t.end),n},inputEventFunction=()=>{if(!n)return;let e=r.value.trim().toLowerCase(),o=e.split(/[-\s]+/);o.length>1&&o.push(e);let s=[];if(e.length>0&&t.forEach((({title:t,content:n,url:r})=>{let l=t.toLowerCase(),i=n.toLowerCase(),a=[],c=[],h=0;if(o.forEach((e=>{a=a.concat(getIndexByWord(e,l,!1)),c=c.concat(getIndexByWord(e,i,!1))})),a.length>0||c.length>0){let o=a.length+c.length;[a,c].forEach((e=>{e.sort(((e,t)=>t.position!==e.position?t.position-e.position:e.word.length-t.word.length))}));let l=[];if(0!==a.length){let n=mergeIntoSlice(0,t.length,a,e);h+=n.searchTextCountInSlice,l.push(n)}let i=[];for(;0!==c.length;){let t=c[c.length-1],{position:o,word:r}=t,l=o-20,s=o+80;l<0&&(l=0),s<o+r.length&&(s=o+r.length),s>n.length&&(s=n.length);let a=mergeIntoSlice(l,s,c,e);h+=a.searchTextCountInSlice,i.push(a)}i.sort(((e,t)=>e.searchTextCount!==t.searchTextCount?t.searchTextCount-e.searchTextCount:e.hits.length!==t.hits.length?t.hits.length-e.hits.length:e.start-t.start));let u=parseInt(theme.navbar.search.top_n_per_article?theme.navbar.search.top_n_per_article:1,10);u>=0&&(i=i.slice(0,u));let p="";0!==l.length?p+=`<li><a href="${r}" class="search-result-title">${highlightKeyword(t,l[0])}</a>`:p+=`<li><a href="${r}" class="search-result-title">${t}</a>`,i.forEach((e=>{p+=`<a href="${r}"><p class="search-result">${highlightKeyword(n,e)}...</p></a>`})),p+="</li>",s.push({item:p,id:s.length,hitCount:o,searchTextCount:h})}})),1===o.length&&""===o[0])l.innerHTML='<div id="no-result"><i class="fa-solid fa-magnifying-glass fa-5x"></i></div>';else if(0===s.length)l.innerHTML='<div id="no-result"><i class="fa-solid fa-box-open fa-5x"></i></div>';else{s.sort(((e,t)=>e.searchTextCount!==t.searchTextCount?t.searchTextCount-e.searchTextCount:e.hitCount!==t.hitCount?t.hitCount-e.hitCount:t.id-e.id));let e='<ul class="search-result-list">';s.forEach((t=>{e+=t.item})),e+="</ul>",l.innerHTML=e,window.pjax&&window.pjax.refresh(l)}},fetchData=()=>{fetch(config.root+e).then((e=>e.text())).then((e=>{n=!0,t=o?[...(new DOMParser).parseFromString(e,"text/xml").querySelectorAll("entry")].map((e=>({title:e.querySelector("title").textContent,content:e.querySelector("content").textContent,url:e.querySelector("url").textContent}))):JSON.parse(e),t=t.filter((e=>e.title)).map((e=>(e.title=e.title.trim(),e.content=e.content?e.content.trim().replace(/<[^>]+>/g,""):"",e.url=decodeURIComponent(e.url).replace(/\/{2,}/g,"/"),e)));const r=document.querySelector("#no-result");r&&(r.innerHTML='<i class="fa-solid fa-magnifying-glass fa-5x"></i>')}))};theme.navbar.search.preload&&fetchData(),r&&r.addEventListener("input",inputEventFunction),document.querySelectorAll(".search-popup-trigger").forEach((e=>{e.addEventListener("click",(()=>{document.body.style.overflow="hidden",document.querySelector(".search-pop-overlay").classList.add("active"),setTimeout((()=>r.focus()),500),n||fetchData()}))}));const onPopupClose=()=>{document.body.style.overflow="",document.querySelector(".search-pop-overlay").classList.remove("active")};document.querySelector(".search-pop-overlay").addEventListener("click",(e=>{e.target===document.querySelector(".search-pop-overlay")&&onPopupClose()})),document.querySelector(".search-input-field-pre").addEventListener("click",(()=>{r.value="",r.focus(),inputEventFunction()})),document.querySelector(".popup-btn-close").addEventListener("click",onPopupClose);try{swup.hooks.on("page:view",(e=>{onPopupClose()}))}catch(e){}window.addEventListener("keyup",(e=>{"Escape"===e.key&&onPopupClose()}))}
//# sourceMappingURL=localSearch.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
const footerRuntime=()=>{const e=theme.footerStart;window.setTimeout(footerRuntime,1e3);const t=new Date(e),n=((new Date).getTime()-t.getTime())/864e5,o=Math.floor(n),m=24*(n-o),d=Math.floor(m),r=60*(m-d),i=Math.floor(60*(m-d)),u=Math.floor(60*(r-i)),a=document.getElementById("runtime_days"),s=document.getElementById("runtime_hours"),M=document.getElementById("runtime_minutes"),c=document.getElementById("runtime_seconds");a&&(a.innerHTML=o),s&&(s.innerHTML=d),M&&(M.innerHTML=i),c&&(c.innerHTML=u)};window.addEventListener("DOMContentLoaded",footerRuntime);
//# sourceMappingURL=runtime.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"runtime.js","names":["footerRuntime","startTime","theme","footerStart","window","setTimeout","X","Date","a","getTime","A","Math","floor","b","B","c","C","D","runtime_days","document","getElementById","runtime_hours","runtime_minutes","runtime_seconds","innerHTML","addEventListener"],"sources":["0"],"mappings":"AAAA,MAAMA,cAAgB,KACpB,MAAMC,EAAYC,MAAMC,YACxBC,OAAOC,WAAWL,cAAe,KAEjC,MAAMM,EAAI,IAAIC,KAAKN,GAIbO,IAHI,IAAID,MACFE,UAAYH,EAAEG,WAChB,MAEJC,EAAIC,KAAKC,MAAMJ,GACfK,EAAc,IAATL,EAAIE,GACTI,EAAIH,KAAKC,MAAMC,GACfE,EAAc,IAATF,EAAIC,GACTE,EAAIL,KAAKC,MAAgB,IAATC,EAAIC,IACpBG,EAAIN,KAAKC,MAAgB,IAATG,EAAIC,IAEpBE,EAAeC,SAASC,eAAe,gBACvCC,EAAgBF,SAASC,eAAe,iBACxCE,EAAkBH,SAASC,eAAe,mBAC1CG,EAAkBJ,SAASC,eAAe,mBAE5CF,IAAcA,EAAaM,UAAYd,GACvCW,IAAeA,EAAcG,UAAYV,GACzCQ,IAAiBA,EAAgBE,UAAYR,GAC7CO,IAAiBA,EAAgBC,UAAYP,EAAC,EAGpDb,OAAOqB,iBAAiB,mBAAoBzB","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
export default()=>{const o=document.querySelector(".tool-scroll-to-top"),t=document.querySelector(".tool-scroll-to-bottom"),backToTop=()=>{window.scrollTo({top:0,behavior:"smooth"})},backToBottom=()=>{const o=document.body.scrollHeight;window.scrollTo({top:o,behavior:"smooth"})};o.addEventListener("click",backToTop),t.addEventListener("click",backToBottom)};
//# sourceMappingURL=scrollTopBottom.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"scrollTopBottom.js","names":["backToTopButton_dom","document","querySelector","backToBottomButton_dom","backToTop","window","scrollTo","top","behavior","backToBottom","docHeight","body","scrollHeight","addEventListener"],"sources":["0"],"mappings":"cAA4B,KAC1B,MAAMA,EAAsBC,SAASC,cAAc,uBAC7CC,EAAyBF,SAASC,cACtC,0BAGIE,UAAY,KAChBC,OAAOC,SAAS,CACdC,IAAK,EACLC,SAAU,UACV,EAGEC,aAAe,KACnB,MAAMC,EAAYT,SAASU,KAAKC,aAChCP,OAAOC,SAAS,CACdC,IAAKG,EACLF,SAAU,UACV,EAIFR,EAAoBa,iBAAiB,QAAST,WAI9CD,EAAuBU,iBAAiB,QAASJ,aAIjC","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
import{main as e}from"../main.js";export function initTocToggle(){const t={toggleBar:document.querySelector(".page-aside-toggle"),postPageContainerDom:document.querySelector(".post-page-container"),toggleBarIcon:document.querySelector(".page-aside-toggle i"),articleContentContainerDom:document.querySelector(".article-content-container"),mainContentDom:document.querySelector(".main-content"),isOpenPageAside:!1,initToggleBarButton(){this.toggleBar&&this.toggleBar.addEventListener("click",(()=>{this.isOpenPageAside=!this.isOpenPageAside,e.styleStatus.isOpenPageAside=this.isOpenPageAside,e.setStyleStatus(),this.changePageLayoutWhenOpenToggle(this.isOpenPageAside)}))},toggleClassName(e,t,o){e&&e.classList.toggle(t,o)},changePageLayoutWhenOpenToggle(e){this.toggleClassName(this.toggleBarIcon,"fas",e),this.toggleClassName(this.toggleBarIcon,"fa-indent",e),this.toggleClassName(this.toggleBarIcon,"fa-outdent",!e),this.toggleClassName(this.postPageContainerDom,"show-toc",e),this.toggleClassName(this.mainContentDom,"has-toc",e)},pageAsideHandleOfTOC(e){this.toggleBar.style.display="flex",this.isOpenPageAside=e,this.changePageLayoutWhenOpenToggle(e)}};return t.initToggleBarButton(),t}try{swup.hooks.on("page:view",(()=>{initTocToggle()}))}catch(t){}document.addEventListener("DOMContentLoaded",initTocToggle);
//# sourceMappingURL=tocToggle.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"tocToggle.js","names":["main","initTocToggle","TocToggle","toggleBar","document","querySelector","postPageContainerDom","toggleBarIcon","articleContentContainerDom","mainContentDom","isOpenPageAside","initToggleBarButton","this","addEventListener","styleStatus","setStyleStatus","changePageLayoutWhenOpenToggle","toggleClassName","element","className","condition","classList","toggle","isOpen","pageAsideHandleOfTOC","style","display","swup","hooks","on","e"],"sources":["0"],"mappings":"eAESA,MAAY,oBAEd,SAASC,gBACd,MAAMC,EAAY,CAChBC,UAAWC,SAASC,cAAc,sBAClCC,qBAAsBF,SAASC,cAAc,wBAC7CE,cAAeH,SAASC,cAAc,wBACtCG,2BAA4BJ,SAASC,cACnC,8BAEFI,eAAgBL,SAASC,cAAc,iBAEvCK,iBAAiB,EAEjB,mBAAAC,GACEC,KAAKT,WACHS,KAAKT,UAAUU,iBAAiB,SAAS,KACvCD,KAAKF,iBAAmBE,KAAKF,gBAC7BV,EAAKc,YAAYJ,gBAAkBE,KAAKF,gBACxCV,EAAKe,iBACLH,KAAKI,+BAA+BJ,KAAKF,gBAAgB,GAE/D,EAEA,eAAAO,CAAgBC,EAASC,EAAWC,GAC9BF,GACFA,EAAQG,UAAUC,OAAOH,EAAWC,EAExC,EACA,8BAAAJ,CAA+BO,GAC7BX,KAAKK,gBAAgBL,KAAKL,cAAe,MAAOgB,GAChDX,KAAKK,gBAAgBL,KAAKL,cAAe,YAAagB,GACtDX,KAAKK,gBAAgBL,KAAKL,cAAe,cAAegB,GACxDX,KAAKK,gBAAgBL,KAAKN,qBAAsB,WAAYiB,GAC5DX,KAAKK,gBAAgBL,KAAKH,eAAgB,UAAWc,EACvD,EAEA,oBAAAC,CAAqBD,GACnBX,KAAKT,UAAUsB,MAAMC,QAAU,OAC/Bd,KAAKF,gBAAkBa,EACvBX,KAAKI,+BAA+BO,EACtC,GAIF,OADArB,EAAUS,sBACHT,CACT,CAGA,IACEyB,KAAKC,MAAMC,GAAG,aAAa,KACzB5B,eAAe,GAEnB,CAAE,MAAO6B,GAAI,CAEb1B,SAASS,iBAAiB,mBAAoBZ","ignoreList":[]}

2
public/js/build/utils.js Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,65 @@
export default function initBookmarkNav() {
const navItems = document.querySelectorAll('.bookmark-nav-item');
const sections = document.querySelectorAll('section[id]');
if (!navItems.length || !sections.length) return;
// Throttle function
function throttle(func, limit) {
let inThrottle;
return function() {
const args = arguments;
const context = this;
if (!inThrottle) {
func.apply(context, args);
inThrottle = true;
setTimeout(() => inThrottle = false, limit);
}
}
}
function setActiveNavItem() {
const fromTop = window.scrollY + 100;
let currentSection = null;
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionHeight = section.offsetHeight;
if (fromTop >= sectionTop && fromTop < sectionTop + sectionHeight) {
currentSection = section;
}
});
navItems.forEach(item => {
item.classList.remove('bg-second-background-color');
if (currentSection && item.getAttribute('data-category') === currentSection.getAttribute('id')) {
item.classList.add('bg-second-background-color');
}
});
}
// // Handle click events on nav items
// navItems.forEach(item => {
// item.addEventListener('click', (e) => {
// e.preventDefault();
// const targetId = item.getAttribute('data-category');
// const targetSection = document.getElementById(targetId);
// if (targetSection) {
// targetSection.scrollIntoView();
// }
// });
// });
// Throttle scroll handler to run at most every 100ms
window.addEventListener('scroll', throttle(setActiveNavItem, 100));
// Initial check
setActiveNavItem();
}
try {
swup.hooks.on("page:view", initBookmarkNav);
} catch (e) {}
document.addEventListener("DOMContentLoaded", initBookmarkNav);

View File

@@ -0,0 +1,53 @@
const toggleStyle = (element, style, firstValue, secondValue) => {
element.style[style] =
element.style[style] === firstValue ? secondValue : firstValue;
};
const setupCategoryList = () => {
const parentElements = Array.from(
document.querySelectorAll(".all-category-list-item"),
).filter((item) =>
item.parentElement.classList.contains("all-category-list"),
);
parentElements.forEach((parentElement) => {
const childElements = parentElement.querySelectorAll(
".all-category-list-child",
);
childElements.forEach((childElement) => {
childElement.style.maxHeight = "0px";
childElement.style.marginTop = "0px";
});
parentElement.addEventListener("click", () => {
const clickedElementTopOffset = parentElement.offsetTop;
childElements.forEach((childElement) => {
toggleStyle(childElement, "maxHeight", "0px", "1000px");
toggleStyle(childElement, "marginTop", "0px", "15px");
});
parentElements.forEach((siblingElement) => {
if (
siblingElement.offsetTop === clickedElementTopOffset &&
siblingElement !== parentElement
) {
const siblingChildElements = siblingElement.querySelectorAll(
".all-category-list-child",
);
siblingChildElements.forEach((siblingChildElement) => {
toggleStyle(siblingChildElement, "maxHeight", "0px", "1000px");
toggleStyle(siblingChildElement, "marginTop", "0px", "15px");
});
}
});
});
});
};
try {
swup.hooks.on("page:view", setupCategoryList);
} catch (e) {
console.error(e);
}
document.addEventListener("DOMContentLoaded", setupCategoryList);

View File

@@ -0,0 +1,25 @@
// Function to format the dates
function formatEssayDates() {
const dateElements = document.querySelectorAll(".essay-date");
if (!dateElements) {
return;
}
dateElements.forEach(function (element) {
const rawDate = element.getAttribute("data-date");
const locale = config.language || "en";
const formattedDate = moment(rawDate).locale(locale).calendar();
element.textContent = formattedDate;
});
}
try {
swup.hooks.on("page:view", formatEssayDates);
} catch (e) {
console.error(e);
}
// Initial call for the first page load
document.addEventListener("DOMContentLoaded", formatEssayDates);

View File

@@ -0,0 +1,22 @@
export default function initLazyLoad() {
const imgs = document.querySelectorAll("img");
const options = {
rootMargin: "0px",
threshold: 0.1,
};
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
const img = entry.target;
img.src = img.getAttribute("data-src");
img.removeAttribute("lazyload");
observer.unobserve(img);
}
});
}, options);
imgs.forEach((img) => {
if (img.hasAttribute("lazyload")) {
observer.observe(img);
}
});
}

View File

@@ -0,0 +1,135 @@
import { navigationState } from "../utils.js";
export const navbarShrink = {
navbarDom: document.querySelector(".navbar-container"),
leftAsideDom: document.querySelector(".page-aside"),
isnavbarShrink: false,
navbarHeight: 0,
init() {
this.navbarHeight = this.navbarDom.getBoundingClientRect().height;
this.shrink();
this.togglenavbarDrawerShow();
this.toggleSubmenu();
window.addEventListener("scroll", () => {
this.shrink();
});
},
shrink() {
const scrollTop =
document.documentElement.scrollTop || document.body.scrollTop;
if (!this.isnavbarShrink && scrollTop > this.navbarHeight) {
this.isnavbarShrink = true;
document.body.classList.add("navbar-shrink");
} else if (this.isnavbarShrink && scrollTop <= this.navbarHeight) {
this.isnavbarShrink = false;
document.body.classList.remove("navbar-shrink");
}
},
togglenavbarDrawerShow() {
const domList = [
document.querySelector(".window-mask"),
document.querySelector(".navbar-bar"),
];
if (document.querySelector(".navbar-drawer")) {
domList.push(
...document.querySelectorAll(
".navbar-drawer .drawer-navbar-list .drawer-navbar-item",
),
...document.querySelectorAll(".navbar-drawer .tag-count-item"),
);
}
domList.forEach((v) => {
if (!v.dataset.navbarInitialized) {
v.dataset.navbarInitialized = 1;
v.addEventListener("click", () => {
document.body.classList.toggle("navbar-drawer-show");
});
}
});
const logoTitleDom = document.querySelector(
".navbar-container .navbar-content .logo-title",
);
if (logoTitleDom && !logoTitleDom.dataset.navbarInitialized) {
logoTitleDom.dataset.navbarInitialized = 1;
logoTitleDom.addEventListener("click", () => {
document.body.classList.remove("navbar-drawer-show");
});
}
},
toggleSubmenu() {
const toggleElements = document.querySelectorAll("[navbar-data-toggle]");
toggleElements.forEach((toggle) => {
if (!toggle.dataset.eventListenerAdded) {
toggle.dataset.eventListenerAdded = "true";
toggle.addEventListener("click", function () {
// console.log("click");
const target = document.querySelector(
'[data-target="' + this.getAttribute("navbar-data-toggle") + '"]',
);
const submenuItems = target.children; // Get submenu items
const icon = this.querySelector(".fa-chevron-right");
if (target) {
const isVisible = !target.classList.contains("hidden");
if (icon) {
icon.classList.toggle("icon-rotated", !isVisible);
}
if (isVisible) {
// Animate to hide (reverse stagger effect)
anime({
targets: submenuItems,
opacity: 0,
translateY: -10,
duration: 300,
easing: "easeInQuart",
delay: anime.stagger(80, { start: 20, direction: "reverse" }),
complete: function () {
target.classList.add("hidden");
},
});
} else {
// Animate to show with stagger effect
target.classList.remove("hidden");
anime({
targets: submenuItems,
opacity: [0, 1],
translateY: [10, 0],
duration: 300,
easing: "easeOutQuart",
delay: anime.stagger(80, { start: 20 }),
});
}
}
});
}
});
},
};
try {
swup.hooks.on("page:view", () => {
navbarShrink.init();
navigationState.isNavigating = false;
});
swup.hooks.on("visit:start", () => {
navigationState.isNavigating = true;
document.body.classList.remove("navbar-shrink");
});
} catch (error) {}
document.addEventListener("DOMContentLoaded", () => {
navbarShrink.init();
});

115
public/js/layouts/toc.js Normal file
View File

@@ -0,0 +1,115 @@
/* main function */
import { initTocToggle } from "../tools/tocToggle.js";
import { main } from "../main.js";
export function initTOC() {
const utils = {
navItems: document.querySelectorAll(".post-toc-wrap .post-toc li"),
updateActiveTOCLink() {
if (!Array.isArray(utils.sections)) return;
let index = utils.sections.findIndex((element) => {
return element && element.getBoundingClientRect().top - 100 > 0;
});
if (index === -1) {
index = utils.sections.length - 1;
} else if (index > 0) {
index--;
}
this.activateTOCLink(index);
},
registerTOCScroll() {
utils.sections = [
...document.querySelectorAll(".post-toc li a.nav-link"),
].map((element) => {
const target = document.getElementById(
decodeURI(element.getAttribute("href")).replace("#", ""),
);
return target;
});
},
activateTOCLink(index) {
const target = document.querySelectorAll(".post-toc li a.nav-link")[
index
];
if (!target || target.classList.contains("active-current")) {
return;
}
document.querySelectorAll(".post-toc .active").forEach((element) => {
element.classList.remove("active", "active-current");
});
target.classList.add("active", "active-current");
// Scroll to the active TOC item
const tocElement = document.querySelector(".toc-content-container");
const tocTop = tocElement.getBoundingClientRect().top;
const scrollTopOffset =
tocElement.offsetHeight > window.innerHeight
? (tocElement.offsetHeight - window.innerHeight) / 2
: 0;
const targetTop = target.getBoundingClientRect().top - tocTop;
const viewportHeight = Math.max(
document.documentElement.clientHeight,
window.innerHeight || 0,
);
const distanceToCenter =
targetTop -
viewportHeight / 2 +
target.offsetHeight / 2 -
scrollTopOffset;
const scrollTop = tocElement.scrollTop + distanceToCenter;
tocElement.scrollTo({
top: scrollTop,
behavior: "smooth", // Smooth scroll
});
},
showTOCAside() {
const openHandle = () => {
const styleStatus = main.getStyleStatus();
const key = "isOpenPageAside";
if (styleStatus && styleStatus.hasOwnProperty(key)) {
initTocToggle().pageAsideHandleOfTOC(styleStatus[key]);
} else {
initTocToggle().pageAsideHandleOfTOC(true);
}
};
const initOpenKey = "init_open";
if (theme.articles.toc.hasOwnProperty(initOpenKey)) {
theme.articles.toc[initOpenKey]
? openHandle()
: initTocToggle().pageAsideHandleOfTOC(false);
} else {
openHandle();
}
},
};
if (utils.navItems.length > 0) {
utils.showTOCAside();
utils.registerTOCScroll();
} else {
document
.querySelectorAll(".toc-content-container, .toc-marker")
.forEach((elem) => {
elem.remove();
});
}
return utils;
}
// Event listeners
try {
swup.hooks.on("page:view", () => {
initTOC();
});
} catch (e) {}
document.addEventListener("DOMContentLoaded", initTOC);

2
public/js/libs/APlayer.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
public/js/libs/Swup.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t||self).SwupScriptsPlugin=e()}(this,function(){function t(){return t=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},t.apply(this,arguments)}const e=t=>String(t).split(".").map(t=>String(parseInt(t||"0",10))).concat(["0","0"]).slice(0,3).join(".");class r{constructor(){this.isSwupPlugin=!0,this.swup=void 0,this.version=void 0,this.requires={},this.handlersToUnregister=[]}mount(){}unmount(){this.handlersToUnregister.forEach(t=>t()),this.handlersToUnregister=[]}_beforeMount(){if(!this.name)throw new Error("You must define a name of plugin when creating a class.")}_afterUnmount(){}_checkRequirements(){return"object"!=typeof this.requires||Object.entries(this.requires).forEach(([t,r])=>{if(!function(t,r,n){const o=function(t,e){var r;if("swup"===t)return null!=(r=e.version)?r:"";{var n;const r=e.findPlugin(t);return null!=(n=null==r?void 0:r.version)?n:""}}(t,n);return!!o&&((t,r)=>r.every(r=>{const[,n,o]=r.match(/^([\D]+)?(.*)$/)||[];var s,i;return((t,e)=>{const r={"":t=>0===t,">":t=>t>0,">=":t=>t>=0,"<":t=>t<0,"<=":t=>t<=0};return(r[e]||r[""])(t)})((i=o,s=e(s=t),i=e(i),s.localeCompare(i,void 0,{numeric:!0})),n||">=")}))(o,r)}(t,r=Array.isArray(r)?r:[r],this.swup)){const e=`${t} ${r.join(", ")}`;throw new Error(`Plugin version mismatch: ${this.name} requires ${e}`)}}),!0}on(t,e,r={}){var n;e=!(n=e).name.startsWith("bound ")||n.hasOwnProperty("prototype")?e.bind(this):e;const o=this.swup.hooks.on(t,e,r);return this.handlersToUnregister.push(o),o}once(e,r,n={}){return this.on(e,r,t({},n,{once:!0}))}before(e,r,n={}){return this.on(e,r,t({},n,{before:!0}))}replace(e,r,n={}){return this.on(e,r,t({},n,{replace:!0}))}off(t,e){return this.swup.hooks.off(t,e)}}return class extends r{constructor(t){void 0===t&&(t={}),super(),this.name="SwupScriptsPlugin",this.requires={swup:">=4"},this.defaults={head:!0,body:!0,optin:!1},this.options={...this.defaults,...t}}mount(){this.on("content:replace",this.runScripts)}runScripts(){const{head:t,body:e,optin:r}=this.options,n=this.getScope({head:t,body:e});if(!n)return;const o=Array.from(n.querySelectorAll(r?"script[data-swup-reload-script]":"script:not([data-swup-ignore-script])"));o.forEach(t=>this.runScript(t)),this.swup.log(`Executed ${o.length} scripts.`)}runScript(t){const e=document.createElement("script");for(const{name:r,value:n}of t.attributes)e.setAttribute(r,n);return e.textContent=t.textContent,t.replaceWith(e),e}getScope(t){let{head:e,body:r}=t;return e&&r?document:e?document.head:r?document.body:null}}});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
public/js/libs/SwupSlideTheme.min.js vendored Normal file
View File

@@ -0,0 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).SwupSlideTheme=t()}(this,function(){function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},e.apply(this,arguments)}const t=e=>String(e).split(".").map(e=>String(parseInt(e||"0",10))).concat(["0","0"]).slice(0,3).join(".");class s{constructor(){this.isSwupPlugin=!0,this.swup=void 0,this.version=void 0,this.requires={},this.handlersToUnregister=[]}mount(){}unmount(){this.handlersToUnregister.forEach(e=>e()),this.handlersToUnregister=[]}_beforeMount(){if(!this.name)throw new Error("You must define a name of plugin when creating a class.")}_afterUnmount(){}_checkRequirements(){return"object"!=typeof this.requires||Object.entries(this.requires).forEach(([e,s])=>{if(!function(e,s,n){const r=function(e,t){var s;if("swup"===e)return null!=(s=t.version)?s:"";{var n;const s=t.findPlugin(e);return null!=(n=null==s?void 0:s.version)?n:""}}(e,n);return!!r&&((e,s)=>s.every(s=>{const[,n,r]=s.match(/^([\D]+)?(.*)$/)||[];var i,o;return((e,t)=>{const s={"":e=>0===e,">":e=>e>0,">=":e=>e>=0,"<":e=>e<0,"<=":e=>e<=0};return(s[t]||s[""])(e)})((o=r,i=t(i=e),o=t(o),i.localeCompare(o,void 0,{numeric:!0})),n||">=")}))(r,s)}(e,s=Array.isArray(s)?s:[s],this.swup)){const t=`${e} ${s.join(", ")}`;throw new Error(`Plugin version mismatch: ${this.name} requires ${t}`)}}),!0}on(e,t,s={}){var n;t=!(n=t).name.startsWith("bound ")||n.hasOwnProperty("prototype")?t.bind(this):t;const r=this.swup.hooks.on(e,t,s);return this.handlersToUnregister.push(r),r}once(t,s,n={}){return this.on(t,s,e({},n,{once:!0}))}before(t,s,n={}){return this.on(t,s,e({},n,{before:!0}))}replace(t,s,n={}){return this.on(t,s,e({},n,{replace:!0}))}off(e,t){return this.swup.hooks.off(e,t)}}class n extends s{constructor(...e){super(...e),this._addedStyleElements=[],this._addedHTMLContent=[],this._classNameAddedToElements=[],this._addClassNameToElement=()=>{this._classNameAddedToElements.forEach(e=>{Array.from(document.querySelectorAll(e.selector)).forEach(t=>{t.classList.add(`swup-transition-${e.name}`)})})}}_beforeMount(){this._originalAnimationSelectorOption=String(this.swup.options.animationSelector),this.swup.options.animationSelector='[class*="swup-transition-"]',this.swup.hooks.on("content:replace",this._addClassNameToElement)}_afterUnmount(){this.swup.options.animationSelector=this._originalAnimationSelectorOption,this._addedStyleElements.forEach(e=>{e.outerHTML="",e=null}),this._addedHTMLContent.forEach(e=>{e.outerHTML="",e=null}),this._classNameAddedToElements.forEach(e=>{Array.from(document.querySelectorAll(e.selector)).forEach(e=>{e.className.split(" ").forEach(t=>{new RegExp("^swup-transition-").test(t)&&e.classList.remove(t)})})}),this.swup.hooks.off("content:replace",this._addClassNameToElement)}applyStyles(e){const t=document.createElement("style");t.setAttribute("data-swup-theme",""),t.appendChild(document.createTextNode(e)),document.head.prepend(t),this._addedStyleElements.push(t)}applyHTML(e){const t=document.createElement("div");t.innerHTML=e,document.body.appendChild(t),this._addedHTMLContent.push(t)}addClassName(e,t){this._classNameAddedToElements.push({selector:e,name:t}),this._addClassNameToElement()}}return class extends n{constructor(e){void 0===e&&(e={}),super(),this.name="SwupSlideTheme",this.defaults={mainElement:"#swup",reversed:!1},this.options={...this.defaults,...e}}mount(){this.applyStyles("html{--swup-slide-theme-direction:1;--swup-slide-theme-translate:60px;--swup-slide-theme-duration-fade:.3s;--swup-slide-theme-duration-slide:.4s;--swup-slide-theme-translate-forward:calc(var(--swup-slide-theme-direction)*var(--swup-slide-theme-translate));--swup-slide-theme-translate-backward:calc(var(--swup-slide-theme-translate-forward)*-1)}html.swup-theme-reverse{--swup-slide-theme-direction:-1}html.is-changing .swup-transition-main{opacity:1;transform:translateZ(0);transition:opacity var(--swup-slide-theme-duration-fade),transform var(--swup-slide-theme-duration-slide)}html.is-animating .swup-transition-main{opacity:0;transform:translate3d(0,var(--swup-slide-theme-translate-backward),0)}html.is-animating.is-leaving .swup-transition-main{transform:translate3d(0,var(--swup-slide-theme-translate-forward),0)}"),this.addClassName(this.options.mainElement,"main"),this.options.reversed&&document.documentElement.classList.add("swup-theme-reverse")}unmount(){document.documentElement.classList.remove("swup-theme-reverse")}}});

10
public/js/libs/Typed.min.js vendored Normal file

File diff suppressed because one or more lines are too long

8
public/js/libs/anime.min.js vendored Normal file

File diff suppressed because one or more lines are too long

2314
public/js/libs/mermaid.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
public/js/libs/minimasonry.min.js vendored Normal file
View File

@@ -0,0 +1 @@
var MiniMasonry=function(){"use strict";function t(t){return this._sizes=[],this._columns=[],this._container=null,this._count=null,this._width=0,this._removeListener=null,this._currentGutterX=null,this._currentGutterY=null,this._resizeTimeout=null,this.conf={baseWidth:255,gutterX:null,gutterY:null,gutter:10,container:null,minify:!0,ultimateGutter:5,surroundingGutter:!0,direction:"ltr",wedge:!1},this.init(t),this}return t.prototype.init=function(t){for(var i in this.conf)null!=t[i]&&(this.conf[i]=t[i]);if(null!=this.conf.gutterX&&null!=this.conf.gutterY||(this.conf.gutterX=this.conf.gutterY=this.conf.gutter),this._currentGutterX=this.conf.gutterX,this._currentGutterY=this.conf.gutterY,this._container="object"==typeof this.conf.container&&this.conf.container.nodeName?this.conf.container:document.querySelector(this.conf.container),!this._container)throw new Error("Container not found or missing");var e=this.resizeThrottler.bind(this);window.addEventListener("resize",e),this._removeListener=function(){window.removeEventListener("resize",e),null!=this._resizeTimeout&&(window.clearTimeout(this._resizeTimeout),this._resizeTimeout=null)},this.layout()},t.prototype.reset=function(){this._sizes=[],this._columns=[],this._count=null,this._width=this._container.clientWidth;var t=this.conf.baseWidth;this._width<t&&(this._width=t,this._container.style.minWidth=t+"px"),1==this.getCount()?(this._currentGutterX=this.conf.ultimateGutter,this._count=1):this._width<this.conf.baseWidth+2*this._currentGutterX?this._currentGutterX=0:this._currentGutterX=this.conf.gutterX},t.prototype.getCount=function(){return this.conf.surroundingGutter?Math.floor((this._width-this._currentGutterX)/(this.conf.baseWidth+this._currentGutterX)):Math.floor((this._width+this._currentGutterX)/(this.conf.baseWidth+this._currentGutterX))},t.prototype.computeWidth=function(){var t=this.conf.surroundingGutter?(this._width-this._currentGutterX)/this._count-this._currentGutterX:(this._width+this._currentGutterX)/this._count-this._currentGutterX;return t=Number.parseFloat(t.toFixed(2))},t.prototype.layout=function(){if(this._container){this.reset(),null==this._count&&(this._count=this.getCount());for(var t=this.computeWidth(),i=0;i<this._count;i++)this._columns[i]=0;for(var e,n,r=this._container.children,s=0;s<r.length;s++)r[s].style.width=t+"px",this._sizes[s]=r[s].clientHeight;e="ltr"==this.conf.direction?this.conf.surroundingGutter?this._currentGutterX:0:this._width-(this.conf.surroundingGutter?this._currentGutterX:0),this._count>this._sizes.length&&(n=this._sizes.length*(t+this._currentGutterX)-this._currentGutterX,!1===this.conf.wedge?e="ltr"==this.conf.direction?(this._width-n)/2:this._width-(this._width-n)/2:"ltr"==this.conf.direction||(e=this._width-this._currentGutterX));for(var o=0;o<r.length;o++){var h=this.conf.minify?this.getShortest():this.getNextColumn(o),u=0;!this.conf.surroundingGutter&&h==this._columns.length||(u=this._currentGutterX);var c="ltr"==this.conf.direction?e+(t+u)*h:e-(t+u)*h-t,u=this._columns[h];r[o].style.transform="translate3d("+Math.round(c)+"px,"+Math.round(u)+"px,0)",this._columns[h]+=this._sizes[o]+(1<this._count?this.conf.gutterY:this.conf.ultimateGutter)}this._container.style.height=this._columns[this.getLongest()]-this._currentGutterY+"px"}else console.error("Container not found")},t.prototype.getNextColumn=function(t){return t%this._columns.length},t.prototype.getShortest=function(){for(var t=0,i=0;i<this._count;i++)this._columns[i]<this._columns[t]&&(t=i);return t},t.prototype.getLongest=function(){for(var t=0,i=0;i<this._count;i++)this._columns[i]>this._columns[t]&&(t=i);return t},t.prototype.resizeThrottler=function(){this._resizeTimeout||(this._resizeTimeout=setTimeout(function(){this._resizeTimeout=null,this._container.clientWidth!=this._width&&this.layout()}.bind(this),33))},t.prototype.destroy=function(){"function"==typeof this._removeListener&&this._removeListener();for(var t=this._container.children,i=0;i<t.length;i++)t[i].style.removeProperty("width"),t[i].style.removeProperty("transform");this._container.style.removeProperty("height"),this._container.style.removeProperty("min-width")},t}();

File diff suppressed because one or more lines are too long

2
public/js/libs/moment.min.js vendored Normal file

File diff suppressed because one or more lines are too long

2
public/js/libs/odometer.min.js vendored Normal file

File diff suppressed because one or more lines are too long

9
public/js/libs/pangu.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1
public/js/libs/pjax.min.js vendored Normal file

File diff suppressed because one or more lines are too long

84
public/js/libs/waline.mjs Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

85
public/js/main.js Normal file
View File

@@ -0,0 +1,85 @@
/* main function */
import initUtils from "./utils.js";
import initTyped from "./plugins/typed.js";
import initModeToggle from "./tools/lightDarkSwitch.js";
import initLazyLoad from "./layouts/lazyload.js";
import initScrollTopBottom from "./tools/scrollTopBottom.js";
import initLocalSearch from "./tools/localSearch.js";
import initCopyCode from "./tools/codeBlock.js";
import initBookmarkNav from "./layouts/bookmarkNav.js";
export const main = {
themeInfo: {
theme: `Redefine v${theme.version}`,
author: "EvanNotFound",
repository: "https://github.com/EvanNotFound/hexo-theme-redefine",
},
localStorageKey: "REDEFINE-THEME-STATUS",
styleStatus: {
isExpandPageWidth: false,
isDark: theme.colors.default_mode && theme.colors.default_mode === "dark",
fontSizeLevel: 0,
isOpenPageAside: true,
},
printThemeInfo: () => {
console.log(
` ______ __ __ ______ __ __ ______ \r\n \/\\__ _\/\\ \\_\\ \\\/\\ ___\\\/\\ \"-.\/ \\\/\\ ___\\ \r\n \\\/_\/\\ \\\\ \\ __ \\ \\ __\\\\ \\ \\-.\/\\ \\ \\ __\\ \r\n \\ \\_\\\\ \\_\\ \\_\\ \\_____\\ \\_\\ \\ \\_\\ \\_____\\ \r\n \\\/_\/ \\\/_\/\\\/_\/\\\/_____\/\\\/_\/ \\\/_\/\\\/_____\/ \r\n \r\n ______ ______ _____ ______ ______ __ __ __ ______ \r\n\/\\ == \\\/\\ ___\\\/\\ __-.\/\\ ___\\\/\\ ___\/\\ \\\/\\ \"-.\\ \\\/\\ ___\\ \r\n\\ \\ __<\\ \\ __\\\\ \\ \\\/\\ \\ \\ __\\\\ \\ __\\ \\ \\ \\ \\-. \\ \\ __\\ \r\n \\ \\_\\ \\_\\ \\_____\\ \\____-\\ \\_____\\ \\_\\ \\ \\_\\ \\_\\\\\"\\_\\ \\_____\\ \r\n \\\/_\/ \/_\/\\\/_____\/\\\/____\/ \\\/_____\/\\\/_\/ \\\/_\/\\\/_\/ \\\/_\/\\\/_____\/\r\n \r\n Github: https:\/\/github.com\/EvanNotFound\/hexo-theme-redefine`,
); // console log message
},
setStyleStatus: () => {
localStorage.setItem(
main.localStorageKey,
JSON.stringify(main.styleStatus),
);
},
getStyleStatus: () => {
let temp = localStorage.getItem(main.localStorageKey);
if (temp) {
temp = JSON.parse(temp);
for (let key in main.styleStatus) {
main.styleStatus[key] = temp[key];
}
return temp;
} else {
return null;
}
},
refresh: () => {
initUtils();
initModeToggle();
initScrollTopBottom();
initBookmarkNav();
if (
theme.home_banner.subtitle.text.length !== 0 &&
location.pathname === config.root
) {
initTyped("subtitle");
}
if (theme.navbar.search.enable === true) {
initLocalSearch();
}
if (theme.articles.code_block.copy === true) {
initCopyCode();
}
if (theme.articles.lazyload === true) {
initLazyLoad();
}
},
};
export function initMain() {
main.printThemeInfo();
main.refresh();
}
document.addEventListener("DOMContentLoaded", initMain);
try {
swup.hooks.on("page:view", () => {
main.refresh();
});
} catch (e) {}

View File

@@ -0,0 +1,33 @@
(function() {
const audioList = [];
const isFixed = theme.plugins.aplayer.type === "fixed";
const isMini = theme.plugins.aplayer.type === "mini";
for (const audio of theme.plugins.aplayer.audios) {
const audioObj = {
name: audio.name,
artist: audio.artist,
url: audio.url,
cover: audio.cover,
lrc: audio.lrc,
theme: audio.theme,
};
audioList.push(audioObj);
}
if (isMini) {
new APlayer({
container: document.getElementById("aplayer"),
mini: true,
audio: audioList,
});
} else if (isFixed) {
const player = new APlayer({
container: document.getElementById("aplayer"),
fixed: true,
lrcType: 3,
audio: audioList,
});
document.querySelector(".aplayer-icon-lrc").click();
}
})();

335
public/js/plugins/hbe.js Normal file
View File

@@ -0,0 +1,335 @@
import { main } from "../main.js";
import { initTOC } from "../layouts/toc.js";
export function initHBE() {
const cryptoObj = window.crypto || window.msCrypto;
const storage = window.localStorage;
const storageName = "hexo-blog-encrypt:#" + window.location.pathname;
const keySalt = textToArray("too young too simple");
const ivSalt = textToArray("sometimes naive!");
// As we can't detect the wrong password with AES-CBC,
// so adding an empty div and check it when decrption.
const knownPrefix = "<hbe-prefix></hbe-prefix>";
const mainElement = document.getElementById("hexo-blog-encrypt");
const wrongPassMessage = mainElement.dataset["wpm"];
const wrongHashMessage = mainElement.dataset["whm"];
const dataElement = mainElement.getElementsByTagName("script")["hbeData"];
const encryptedData = dataElement.innerText;
const HmacDigist = dataElement.dataset["hmacdigest"];
function hexToArray(s) {
return new Uint8Array(
s.match(/[\da-f]{2}/gi).map((h) => {
return parseInt(h, 16);
}),
);
}
function textToArray(s) {
var i = s.length;
var n = 0;
var ba = new Array();
for (var j = 0; j < i; ) {
var c = s.codePointAt(j);
if (c < 128) {
ba[n++] = c;
j++;
} else if (c > 127 && c < 2048) {
ba[n++] = (c >> 6) | 192;
ba[n++] = (c & 63) | 128;
j++;
} else if (c > 2047 && c < 65536) {
ba[n++] = (c >> 12) | 224;
ba[n++] = ((c >> 6) & 63) | 128;
ba[n++] = (c & 63) | 128;
j++;
} else {
ba[n++] = (c >> 18) | 240;
ba[n++] = ((c >> 12) & 63) | 128;
ba[n++] = ((c >> 6) & 63) | 128;
ba[n++] = (c & 63) | 128;
j += 2;
}
}
return new Uint8Array(ba);
}
function arrayBufferToHex(arrayBuffer) {
if (
typeof arrayBuffer !== "object" ||
arrayBuffer === null ||
typeof arrayBuffer.byteLength !== "number"
) {
throw new TypeError("Expected input to be an ArrayBuffer");
}
var view = new Uint8Array(arrayBuffer);
var result = "";
var value;
for (var i = 0; i < view.length; i++) {
value = view[i].toString(16);
result += value.length === 1 ? "0" + value : value;
}
return result;
}
async function getExecutableScript(oldElem) {
let out = document.createElement("script");
const attList = [
"type",
"text",
"src",
"crossorigin",
"defer",
"referrerpolicy",
];
attList.forEach((att) => {
if (oldElem[att]) out[att] = oldElem[att];
});
return out;
}
async function convertHTMLToElement(content) {
let out = document.createElement("div");
out.innerHTML = content;
out.querySelectorAll("script").forEach(async (elem) => {
elem.replaceWith(await getExecutableScript(elem));
});
return out;
}
function getKeyMaterial(password) {
let encoder = new TextEncoder();
return cryptoObj.subtle.importKey(
"raw",
encoder.encode(password),
{
name: "PBKDF2",
},
false,
["deriveKey", "deriveBits"],
);
}
function getHmacKey(keyMaterial) {
return cryptoObj.subtle.deriveKey(
{
name: "PBKDF2",
hash: "SHA-256",
salt: keySalt.buffer,
iterations: 1024,
},
keyMaterial,
{
name: "HMAC",
hash: "SHA-256",
length: 256,
},
true,
["verify"],
);
}
function getDecryptKey(keyMaterial) {
return cryptoObj.subtle.deriveKey(
{
name: "PBKDF2",
hash: "SHA-256",
salt: keySalt.buffer,
iterations: 1024,
},
keyMaterial,
{
name: "AES-CBC",
length: 256,
},
true,
["decrypt"],
);
}
function getIv(keyMaterial) {
return cryptoObj.subtle.deriveBits(
{
name: "PBKDF2",
hash: "SHA-256",
salt: ivSalt.buffer,
iterations: 512,
},
keyMaterial,
16 * 8,
);
}
async function verifyContent(key, content) {
const encoder = new TextEncoder();
const encoded = encoder.encode(content);
let signature = hexToArray(HmacDigist);
const result = await cryptoObj.subtle.verify(
{
name: "HMAC",
hash: "SHA-256",
},
key,
signature,
encoded,
);
console.log(`Verification result: ${result}`);
if (!result) {
alert(wrongHashMessage);
console.log(`${wrongHashMessage}, got `, signature, ` but proved wrong.`);
}
return result;
}
async function decrypt(decryptKey, iv, hmacKey) {
let typedArray = hexToArray(encryptedData);
const result = await cryptoObj.subtle
.decrypt(
{
name: "AES-CBC",
iv: iv,
},
decryptKey,
typedArray.buffer,
)
.then(async (result) => {
const decoder = new TextDecoder();
const decoded = decoder.decode(result);
// check the prefix, if not then we can sure here is wrong password.
if (!decoded.startsWith(knownPrefix)) {
throw "Decode successfully but not start with KnownPrefix.";
}
const hideButton = document.createElement("button");
hideButton.textContent = "Encrypt again";
hideButton.type = "button";
hideButton.classList.add("hbe-button");
hideButton.addEventListener("click", () => {
window.localStorage.removeItem(storageName);
window.location.reload();
});
document.getElementById("hexo-blog-encrypt").style.display = "inline";
document.getElementById("hexo-blog-encrypt").innerHTML = "";
document
.getElementById("hexo-blog-encrypt")
.appendChild(await convertHTMLToElement(decoded));
document.getElementById("hexo-blog-encrypt").appendChild(hideButton);
// support html5 lazyload functionality.
document.querySelectorAll("img").forEach((elem) => {
if (elem.getAttribute("data-src") && !elem.src) {
elem.src = elem.getAttribute("data-src");
}
});
// // load Redefine Page components
main.refresh();
initTOC();
// trigger event
var event = new Event("hexo-blog-decrypt");
window.dispatchEvent(event);
return await verifyContent(hmacKey, decoded);
})
.catch((e) => {
alert(wrongPassMessage);
console.log(e);
return false;
});
return result;
}
function hbeLoader() {
const oldStorageData = JSON.parse(storage.getItem(storageName));
if (oldStorageData) {
console.log(
`Password got from localStorage(${storageName}): `,
oldStorageData,
);
const sIv = hexToArray(oldStorageData.iv).buffer;
const sDk = oldStorageData.dk;
const sHmk = oldStorageData.hmk;
cryptoObj.subtle
.importKey(
"jwk",
sDk,
{
name: "AES-CBC",
length: 256,
},
true,
["decrypt"],
)
.then((dkCK) => {
cryptoObj.subtle
.importKey(
"jwk",
sHmk,
{
name: "HMAC",
hash: "SHA-256",
length: 256,
},
true,
["verify"],
)
.then((hmkCK) => {
decrypt(dkCK, sIv, hmkCK).then((result) => {
if (!result) {
storage.removeItem(storageName);
}
});
});
});
}
mainElement.addEventListener("keydown", async (event) => {
if (event.isComposing || event.key === "Enter") {
const password = document.getElementById("hbePass").value;
const keyMaterial = await getKeyMaterial(password);
const hmacKey = await getHmacKey(keyMaterial);
const decryptKey = await getDecryptKey(keyMaterial);
const iv = await getIv(keyMaterial);
decrypt(decryptKey, iv, hmacKey).then((result) => {
console.log(`Decrypt result: ${result}`);
if (result) {
cryptoObj.subtle.exportKey("jwk", decryptKey).then((dk) => {
cryptoObj.subtle.exportKey("jwk", hmacKey).then((hmk) => {
const newStorageData = {
dk: dk,
iv: arrayBufferToHex(iv),
hmk: hmk,
};
storage.setItem(storageName, JSON.stringify(newStorageData));
});
});
}
});
}
});
}
hbeLoader();
}
// initHBE();

View File

@@ -0,0 +1,64 @@
export function initMasonry() {
var loadingPlaceholder = document.querySelector(".loading-placeholder");
var masonryContainer = document.querySelector("#masonry-container");
if (!loadingPlaceholder || !masonryContainer) return;
loadingPlaceholder.style.display = "block";
masonryContainer.style.display = "none";
var images = document.querySelectorAll(
"#masonry-container .masonry-item img",
);
var loadedCount = 0;
function onImageLoad() {
loadedCount++;
if (loadedCount === images.length) {
initializeMasonryLayout();
}
}
for (var i = 0; i < images.length; i++) {
var img = images[i];
if (img.complete) {
onImageLoad();
} else {
img.addEventListener("load", onImageLoad);
}
}
if (loadedCount === images.length) {
initializeMasonryLayout();
}
function initializeMasonryLayout() {
loadingPlaceholder.style.opacity = 0;
setTimeout(() => {
loadingPlaceholder.style.display = "none";
masonryContainer.style.display = "block";
var screenWidth = window.innerWidth;
var baseWidth;
if (screenWidth >= 768) {
baseWidth = 255;
} else {
baseWidth = 150;
}
var masonry = new MiniMasonry({
baseWidth: baseWidth,
container: masonryContainer,
gutterX: 10,
gutterY: 10,
surroundingGutter: false,
});
masonry.layout();
masonryContainer.style.opacity = 1;
}, 100);
}
}
if (data.masonry) {
try {
swup.hooks.on("page:view", initMasonry);
} catch (e) {}
document.addEventListener("DOMContentLoaded", initMasonry);
}

View File

@@ -0,0 +1,7 @@
if (theme.plugins.mermaid.enable === true) {
try {
swup.hooks.on("page:view", () => {
mermaid.initialize();
});
} catch (e) {}
}

View File

@@ -0,0 +1,12 @@
function initPanguJS() {
// Add space between Chinese and English
pangu.spacingElementByClassName("markdown-body");
pangu.autoSpacingPage();
}
document.addEventListener("DOMContentLoaded", initPanguJS);
try {
swup.hooks.on("page:view", initPanguJS);
} catch (e) {}

29
public/js/plugins/tabs.js Normal file
View File

@@ -0,0 +1,29 @@
function setTabs() {
let tabs = document.querySelectorAll(".tabs .nav-tabs");
if (!tabs) return;
tabs.forEach((tab) => {
tab.querySelectorAll("a").forEach((link) => {
link.addEventListener("click", (e) => {
e.preventDefault();
e.stopPropagation();
const parentTab = e.target.parentElement.parentElement.parentElement;
parentTab.querySelector(".nav-tabs .active").classList.remove("active");
e.target.parentElement.classList.add("active");
parentTab
.querySelector(".tab-content .active")
.classList.remove("active");
parentTab.querySelector(e.target.className).classList.add("active");
return false;
});
});
});
}
try {
swup.hooks.on("page:view", setTabs);
} catch (e) {}
document.addEventListener("DOMContentLoaded", setTabs);

View File

@@ -0,0 +1,62 @@
/*
author: @jiangwen5945 & EvanNotFound
*/
export const config = {
usrTypeSpeed: theme.home_banner.subtitle.typing_speed,
usrBackSpeed: theme.home_banner.subtitle.backing_speed,
usrBackDelay: theme.home_banner.subtitle.backing_delay,
usrStartDelay: theme.home_banner.subtitle.starting_delay,
usrLoop: theme.home_banner.subtitle.loop,
usrSmartBackspace: theme.home_banner.subtitle.smart_backspace,
usrHitokotoAPI: theme.home_banner.subtitle.hitokoto.api,
};
export default function initTyped(id) {
const {
usrTypeSpeed,
usrBackSpeed,
usrBackDelay,
usrStartDelay,
usrLoop,
usrSmartBackspace,
usrHitokotoAPI,
} = config;
function typing(dataList) {
const st = new Typed("#" + id, {
strings: [dataList],
typeSpeed: usrTypeSpeed || 100,
smartBackspace: usrSmartBackspace || false,
backSpeed: usrBackSpeed || 80,
backDelay: usrBackDelay || 1500,
loop: usrLoop || false,
startDelay: usrStartDelay || 500,
});
}
if (theme.home_banner.subtitle.hitokoto.enable) {
fetch(usrHitokotoAPI)
.then((response) => response.json())
.then((data) => {
if (data.from_who && theme.home_banner.subtitle.hitokoto.show_author) {
typing(data.hitokoto + "——" + data.from_who);
} else {
typing(data.hitokoto);
}
})
.catch(console.error);
} else {
const sentenceList = [...theme.home_banner.subtitle.text];
if (document.getElementById(id)) {
const st = new Typed("#" + id, {
strings: sentenceList,
typeSpeed: usrTypeSpeed || 100,
smartBackspace: usrSmartBackspace || false,
backSpeed: usrBackSpeed || 80,
backDelay: usrBackDelay || 1500,
loop: usrLoop || false,
startDelay: usrStartDelay || 500,
});
}
}
}

View File

@@ -0,0 +1,48 @@
const initCopyCode = () => {
HTMLElement.prototype.wrap = function (wrapper) {
this.parentNode.insertBefore(wrapper, this);
this.parentNode.removeChild(this);
wrapper.appendChild(this);
};
document.querySelectorAll("figure.highlight").forEach((element) => {
const container = document.createElement("div");
element.wrap(container);
container.classList.add("highlight-container");
container.insertAdjacentHTML(
"beforeend",
'<div class="copy-button"><i class="fa-regular fa-copy"></i></div>',
);
container.insertAdjacentHTML(
"beforeend",
'<div class="fold-button"><i class="fa-solid fa-chevron-down"></i></div>',
);
const copyButton = container.querySelector(".copy-button");
const foldButton = container.querySelector(".fold-button");
copyButton.addEventListener("click", () => {
const codeLines = [...container.querySelectorAll(".code .line")];
const code = codeLines.map((line) => line.innerText).join("\n");
// Copy code to clipboard
navigator.clipboard.writeText(code);
// Display 'copied' icon
copyButton.querySelector("i").className = "fa-regular fa-check";
// Reset icon after a while
setTimeout(() => {
copyButton.querySelector("i").className = "fa-regular fa-copy";
}, 1000);
});
foldButton.addEventListener("click", () => {
container.classList.toggle("folded");
foldButton.querySelector("i").className = container.classList.contains(
"folded",
)
? "fa-solid fa-chevron-up"
: "fa-solid fa-chevron-down";
});
});
};
export default initCopyCode;

View File

@@ -0,0 +1,170 @@
export default function imageViewer() {
let isBigImage = false;
let scale = 1;
let isMouseDown = false;
let dragged = false;
let currentImgIndex = 0;
let lastMouseX = 0;
let lastMouseY = 0;
let translateX = 0;
let translateY = 0;
const maskDom = document.querySelector(".image-viewer-container");
if (!maskDom) {
console.warn(
"Image viewer container not found. Exiting imageViewer function.",
);
return;
}
const targetImg = maskDom.querySelector("img");
if (!targetImg) {
console.warn(
"Target image not found in image viewer container. Exiting imageViewer function.",
);
return;
}
const showHandle = (isShow) => {
document.body.style.overflow = isShow ? "hidden" : "auto";
isShow
? maskDom.classList.add("active")
: maskDom.classList.remove("active");
};
const zoomHandle = (event) => {
event.preventDefault();
const rect = targetImg.getBoundingClientRect();
const offsetX = event.clientX - rect.left;
const offsetY = event.clientY - rect.top;
const dx = offsetX - rect.width / 2;
const dy = offsetY - rect.height / 2;
const oldScale = scale;
scale += event.deltaY * -0.001;
scale = Math.min(Math.max(0.8, scale), 4);
if (oldScale < scale) {
// Zooming in
translateX -= dx * (scale - oldScale);
translateY -= dy * (scale - oldScale);
} else {
// Zooming out
translateX = 0;
translateY = 0;
}
targetImg.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scale})`;
};
const dragStartHandle = (event) => {
event.preventDefault();
isMouseDown = true;
lastMouseX = event.clientX;
lastMouseY = event.clientY;
targetImg.style.cursor = "grabbing";
};
let lastTime = 0;
const throttle = 100;
const dragHandle = (event) => {
if (isMouseDown) {
const currentTime = new Date().getTime();
if (currentTime - lastTime < throttle) {
return;
}
lastTime = currentTime;
const deltaX = event.clientX - lastMouseX;
const deltaY = event.clientY - lastMouseY;
translateX += deltaX;
translateY += deltaY;
lastMouseX = event.clientX;
lastMouseY = event.clientY;
targetImg.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scale})`;
dragged = true;
}
};
const dragEndHandle = (event) => {
if (isMouseDown) {
event.stopPropagation();
}
isMouseDown = false;
targetImg.style.cursor = "grab";
};
targetImg.addEventListener("wheel", zoomHandle, { passive: false });
targetImg.addEventListener("mousedown", dragStartHandle, { passive: false });
targetImg.addEventListener("mousemove", dragHandle, { passive: false });
targetImg.addEventListener("mouseup", dragEndHandle, { passive: false });
targetImg.addEventListener("mouseleave", dragEndHandle, { passive: false });
maskDom.addEventListener("click", (event) => {
if (!dragged) {
isBigImage = false;
showHandle(isBigImage);
scale = 1;
translateX = 0;
translateY = 0;
targetImg.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scale})`;
}
dragged = false;
});
const imgDoms = document.querySelectorAll(
".markdown-body img, .masonry-item img, #shuoshuo-content img",
);
const escapeKeyListener = (event) => {
if (event.key === "Escape" && isBigImage) {
isBigImage = false;
showHandle(isBigImage);
scale = 1;
translateX = 0;
translateY = 0;
targetImg.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scale})`;
// Remove the event listener when the image viewer is closed
document.removeEventListener("keydown", escapeKeyListener);
}
};
if (imgDoms.length > 0) {
imgDoms.forEach((img, index) => {
img.addEventListener("click", () => {
currentImgIndex = index;
isBigImage = true;
showHandle(isBigImage);
targetImg.src = img.src;
document.addEventListener("keydown", escapeKeyListener);
});
});
const handleArrowKeys = (event) => {
if (!isBigImage) return;
if (event.key === "ArrowUp" || event.key === "ArrowLeft") {
currentImgIndex =
(currentImgIndex - 1 + imgDoms.length) % imgDoms.length;
} else if (event.key === "ArrowDown" || event.key === "ArrowRight") {
currentImgIndex = (currentImgIndex + 1) % imgDoms.length;
} else {
return;
}
const currentImg = imgDoms[currentImgIndex];
let newSrc = currentImg.src;
if (currentImg.hasAttribute("lazyload")) {
newSrc = currentImg.getAttribute("data-src");
currentImg.src = newSrc;
currentImg.removeAttribute("lazyload");
}
targetImg.src = newSrc;
};
document.addEventListener("keydown", handleArrowKeys);
} else {
// console.warn("No images found to attach image viewer functionality.");
}
}

Some files were not shown because too many files have changed in this diff Show More