2021-01-23 01:02:56 +08:00
|
|
|
/* global KEEP */
|
|
|
|
|
2020-03-29 19:54:28 +08:00
|
|
|
window.addEventListener('DOMContentLoaded', () => {
|
2020-11-24 20:06:08 +08:00
|
|
|
|
|
|
|
KEEP.themeInfo = {
|
2021-01-07 17:04:53 +08:00
|
|
|
theme: `Keep v${KEEP.theme_config.version}`,
|
2020-11-24 20:06:08 +08:00
|
|
|
author: 'XPoet',
|
|
|
|
repository: 'https://github.com/XPoet/hexo-theme-keep'
|
|
|
|
}
|
|
|
|
|
2021-01-23 01:02:56 +08:00
|
|
|
KEEP.localStorageKey = 'KEEP-THEME-STATUS';
|
|
|
|
|
|
|
|
KEEP.styleStatus = {
|
|
|
|
isExpandPageWidth: false,
|
|
|
|
isDark: false,
|
2021-01-24 19:54:44 +08:00
|
|
|
fontSizeLevel: 0,
|
|
|
|
isOpenPageAside: true
|
2021-01-23 01:02:56 +08:00
|
|
|
}
|
|
|
|
|
2021-01-07 15:23:31 +08:00
|
|
|
// print theme base info
|
|
|
|
KEEP.printThemeInfo = () => {
|
2021-01-07 17:04:53 +08:00
|
|
|
console.log(`\n %c ${KEEP.themeInfo.theme} %c ${KEEP.themeInfo.repository} \n`, `color: #fadfa3; background: #333; padding: 5px 0;`, `background: #fadfa3; padding: 5px 0;`);
|
2021-01-07 15:23:31 +08:00
|
|
|
}
|
|
|
|
|
2021-01-23 01:02:56 +08:00
|
|
|
// set styleStatus to localStorage
|
|
|
|
KEEP.setStyleStatus = () => {
|
|
|
|
localStorage.setItem(KEEP.localStorageKey, JSON.stringify(KEEP.styleStatus));
|
|
|
|
}
|
|
|
|
|
|
|
|
// get styleStatus from localStorage
|
|
|
|
KEEP.getStyleStatus = () => {
|
|
|
|
let temp = localStorage.getItem(KEEP.localStorageKey);
|
|
|
|
if (temp) {
|
|
|
|
temp = JSON.parse(temp);
|
|
|
|
for (let key in KEEP.styleStatus) {
|
|
|
|
KEEP.styleStatus[key] = temp[key];
|
|
|
|
}
|
|
|
|
return temp;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-30 18:11:46 +08:00
|
|
|
KEEP.refresh = () => {
|
|
|
|
KEEP.initUtils();
|
|
|
|
KEEP.initHeaderShrink();
|
|
|
|
KEEP.initModeToggle();
|
|
|
|
KEEP.initBack2Top();
|
2021-01-05 17:01:15 +08:00
|
|
|
|
|
|
|
if (KEEP.theme_config.local_search.enable === true) {
|
|
|
|
KEEP.initLocalSearch();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (KEEP.theme_config.code_copy.enable === true) {
|
|
|
|
KEEP.initCodeCopy();
|
|
|
|
}
|
2021-01-07 15:15:39 +08:00
|
|
|
|
|
|
|
if (KEEP.theme_config.lazyload.enable === true) {
|
|
|
|
KEEP.initLazyLoad();
|
|
|
|
}
|
2020-12-30 18:11:46 +08:00
|
|
|
}
|
2020-11-24 20:06:08 +08:00
|
|
|
|
2021-01-07 15:23:31 +08:00
|
|
|
KEEP.printThemeInfo();
|
2020-12-30 18:11:46 +08:00
|
|
|
KEEP.refresh();
|
2020-07-22 17:08:07 +08:00
|
|
|
});
|