1/* main function */ 2import initUtils from "./utils.js"; 3import initTyped from "./plugins/typed.js"; 4import initModeToggle from "./tools/lightDarkSwitch.js"; 5import initLazyLoad from "./layouts/lazyload.js"; 6import initScrollTopBottom from "./tools/scrollTopBottom.js"; 7import initLocalSearch from "./tools/localSearch.js"; 8import initCopyCode from "./tools/codeBlock.js"; 9 10export const main = { 11 themeInfo: { 12 theme: `Redefine v${theme.version}`, 13 author: "EvanNotFound", 14 repository: "https://github.com/EvanNotFound/hexo-theme-redefine", 15 }, 16 localStorageKey: "REDEFINE-THEME-STATUS", 17 styleStatus: { 18 isExpandPageWidth: false, 19 isDark: theme.colors.default_mode && theme.colors.default_mode === "dark", 20 fontSizeLevel: 0, 21 isOpenPageAside: true, 22 }, 23 printThemeInfo: () => { 24 console.log( 25 ` ______ __ __ ______ __ __ ______ \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`, 26 ); // console log message 27 }, 28 setStyleStatus: () => { 29 localStorage.setItem( 30 main.localStorageKey, 31 JSON.stringify(main.styleStatus), 32 ); 33 }, 34 getStyleStatus: () => { 35 let temp = localStorage.getItem(main.localStorageKey); 36 if (temp) { 37 temp = JSON.parse(temp); 38 for (let key in main.styleStatus) { 39 main.styleStatus[key] = temp[key]; 40 } 41 return temp; 42 } else { 43 return null; 44 } 45 }, 46 refresh: () => { 47 initUtils(); 48 initModeToggle(); 49 initScrollTopBottom(); 50 if ( 51 theme.home_banner.subtitle.text.length !== 0 && 52 location.pathname === config.root 53 ) { 54 initTyped("subtitle"); 55 } 56 57 if (theme.navbar.search.enable === true) { 58 initLocalSearch(); 59 } 60 61 if (theme.articles.code_block.copy === true) { 62 initCopyCode(); 63 } 64 65 if (theme.articles.lazyload === true) { 66 initLazyLoad(); 67 } 68 }, 69}; 70 71export function initMain() { 72 main.printThemeInfo(); 73 main.refresh(); 74} 75 76document.addEventListener("DOMContentLoaded", initMain); 77 78try { 79 swup.hooks.on("page:view", () => { 80 main.refresh(); 81 }); 82} catch (e) {}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.