1
1
/* global KEEP */
2
2
3
3
window . addEventListener ( 'DOMContentLoaded' , ( ) => {
4
- const { version, local_search, code_block , lazyload } = KEEP . theme_config
4
+ const { version, local_search, lazyload } = KEEP . theme_config
5
5
6
6
KEEP . themeInfo = {
7
7
theme : `Keep v${ version } ` ,
8
8
author : 'XPoet' ,
9
- repository : 'https://github.com/XPoet/hexo-theme-keep'
10
- }
11
-
12
- KEEP . localStorageKey = 'KEEP-THEME-STATUS'
13
-
14
- KEEP . styleStatus = {
15
- isDark : false ,
16
- fontSizeLevel : 0 ,
17
- isShowToc : true
9
+ repository : 'https://github.com/XPoet/hexo-theme-keep' ,
10
+ localStorageKey : 'KEEP-THEME-STATUS' ,
11
+ styleStatus : {
12
+ isDark : false ,
13
+ fontSizeLevel : 0 ,
14
+ isShowToc : true
15
+ }
18
16
}
19
17
20
18
// print theme base info
@@ -37,23 +35,33 @@ window.addEventListener('DOMContentLoaded', () => {
37
35
38
36
// set styleStatus to localStorage
39
37
KEEP . setStyleStatus = ( ) => {
40
- localStorage . setItem ( KEEP . localStorageKey , JSON . stringify ( KEEP . styleStatus ) )
38
+ localStorage . setItem ( KEEP . themeInfo . localStorageKey , JSON . stringify ( KEEP . themeInfo . styleStatus ) )
41
39
}
42
40
43
41
// get styleStatus from localStorage
44
42
KEEP . getStyleStatus = ( ) => {
45
- let temp = localStorage . getItem ( KEEP . localStorageKey )
43
+ let temp = localStorage . getItem ( KEEP . themeInfo . localStorageKey )
46
44
if ( temp ) {
47
45
temp = JSON . parse ( temp )
48
- for ( let key in KEEP . styleStatus ) {
49
- KEEP . styleStatus [ key ] = temp [ key ]
46
+ for ( let key in KEEP . themeInfo . styleStatus ) {
47
+ KEEP . themeInfo . styleStatus [ key ] = temp [ key ]
50
48
}
51
49
return temp
52
50
} else {
53
51
return null
54
52
}
55
53
}
56
54
55
+ // init prototype function
56
+ KEEP . initPrototype = ( ) => {
57
+ HTMLElement . prototype . wrap = function ( wrapper ) {
58
+ this . parentNode . insertBefore ( wrapper , this )
59
+ this . parentNode . removeChild ( this )
60
+ wrapper . appendChild ( this )
61
+ }
62
+ }
63
+ KEEP . initPrototype ( )
64
+
57
65
KEEP . initExecute = ( ) => {
58
66
KEEP . initUtils ( )
59
67
KEEP . initHeaderShrink ( )
0 commit comments