hexo-theme-shokax 0.2.10 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +68 -81
- package/README.md +17 -6
- package/UsageRestrictions.md +21 -0
- package/_config.yml +5 -12
- package/layout/_mixin/comment.pug +1 -2
- package/layout/_mixin/widgets.pug +2 -1
- package/layout/_partials/layout.pug +23 -23
- package/package.json +16 -12
- package/scripts/generaters/script.js +29 -8
- package/scripts/helpers/summary_ai.js +0 -1
- package/scripts/plugin/check.js +30 -0
- package/scripts/plugin/index.js +5 -0
- package/source/css/_common/components/tags/tabs.styl +0 -2
- package/source/css/_common/scaffolding/normalize.styl +165 -180
- package/source/js/_app/globals/globalVars.js +26 -0
- package/source/js/_app/globals/handles.js +105 -0
- package/source/js/_app/globals/themeColor.js +48 -0
- package/source/js/_app/globals/thirdparty.js +60 -0
- package/source/js/_app/globals/tools.js +75 -0
- package/source/js/_app/library/anime.js +85 -0
- package/source/js/_app/library/dom.js +22 -0
- package/source/js/_app/library/loadFile.js +32 -0
- package/source/js/_app/library/proto.js +105 -0
- package/source/js/_app/library/scriptPjax.js +57 -0
- package/source/js/_app/library/storage.js +11 -0
- package/source/js/_app/page/comment.js +19 -0
- package/source/js/_app/page/common.js +57 -0
- package/source/js/_app/page/fancybox.js +59 -0
- package/source/js/_app/page/post.js +232 -0
- package/source/js/_app/page/search.js +111 -0
- package/source/js/_app/page/tab.js +50 -0
- package/source/js/_app/pjax/domInit.js +68 -0
- package/source/js/_app/pjax/refresh.js +42 -0
- package/source/js/_app/pjax/siteInit.js +34 -0
- package/source/js/_app/player.js +1 -1
- package/source/js/_app/global.js +0 -314
- package/source/js/_app/library.js +0 -312
- package/source/js/_app/page.js +0 -673
- /package/source/js/_app/{components.js → components/sidebar.js} +0 -0
- /package/source/js/_app/{vue.js → library/vue.js} +0 -0
@@ -1,108 +1,116 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
/*! modern-normalize v2.0.0 | MIT License | https://github.com/sindresorhus/modern-normalize */
|
2
|
+
|
3
|
+
/*
|
4
|
+
Document
|
5
|
+
========
|
6
|
+
*/
|
7
|
+
|
4
8
|
/**
|
5
|
-
|
6
|
-
|
7
|
-
|
9
|
+
Use a better box model (opinionated).
|
10
|
+
*/
|
11
|
+
|
12
|
+
*,
|
13
|
+
::before,
|
14
|
+
::after {
|
15
|
+
box-sizing: border-box;
|
16
|
+
}
|
17
|
+
|
8
18
|
html {
|
9
|
-
|
10
|
-
-
|
19
|
+
/* Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3) */
|
20
|
+
font-family:
|
21
|
+
system-ui,
|
22
|
+
'Segoe UI',
|
23
|
+
Roboto,
|
24
|
+
Helvetica,
|
25
|
+
Arial,
|
26
|
+
sans-serif,
|
27
|
+
'Apple Color Emoji',
|
28
|
+
'Segoe UI Emoji';
|
29
|
+
line-height: 1.15; /* 1. Correct the line height in all browsers. */
|
30
|
+
-webkit-text-size-adjust: 100%; /* 2. Prevent adjustments of font size after orientation changes in iOS. */
|
31
|
+
-moz-tab-size: 4; /* 3. Use a more readable tab size (opinionated). */
|
32
|
+
tab-size: 4; /* 3 */
|
11
33
|
}
|
12
34
|
|
13
|
-
/*
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
35
|
+
/*
|
36
|
+
Sections
|
37
|
+
========
|
38
|
+
*/
|
39
|
+
|
18
40
|
body {
|
19
|
-
margin: 0;
|
41
|
+
margin: 0; /* Remove the margin in all browsers. */
|
20
42
|
}
|
21
43
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
display: block;
|
27
|
-
}
|
44
|
+
/*
|
45
|
+
Grouping content
|
46
|
+
================
|
47
|
+
*/
|
28
48
|
|
29
49
|
/**
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
h1 {
|
34
|
-
font-size: 2em;
|
35
|
-
margin: .67em 0;
|
36
|
-
}
|
50
|
+
1. Add the correct height in Firefox.
|
51
|
+
2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
|
52
|
+
*/
|
37
53
|
|
38
|
-
/* Grouping content
|
39
|
-
========================================================================== */
|
40
|
-
/**
|
41
|
-
* 1. Add the correct box sizing in Firefox.
|
42
|
-
* 2. Show the overflow in Edge and IE.
|
43
|
-
*/
|
44
54
|
hr {
|
45
|
-
box-sizing: content-box; /* 1 */
|
46
55
|
height: 0; /* 1 */
|
47
|
-
|
56
|
+
color: inherit; /* 2 */
|
48
57
|
}
|
49
58
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
pre {
|
55
|
-
font-family: monospace, monospace; /* 1 */
|
56
|
-
font-size: 1em; /* 2 */
|
57
|
-
}
|
59
|
+
/*
|
60
|
+
Text-level semantics
|
61
|
+
====================
|
62
|
+
*/
|
58
63
|
|
59
|
-
/* Text-level semantics
|
60
|
-
========================================================================== */
|
61
64
|
/**
|
62
|
-
|
63
|
-
|
64
|
-
a {
|
65
|
-
background: transparent;
|
66
|
-
}
|
65
|
+
Add the correct text decoration in Chrome, Edge, and Safari.
|
66
|
+
*/
|
67
67
|
|
68
|
-
/**
|
69
|
-
* 1. Remove the bottom border in Chrome 57-
|
70
|
-
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
|
71
|
-
*/
|
72
68
|
abbr[title] {
|
73
|
-
|
74
|
-
text-decoration: underline; /* 2 */
|
75
|
-
//text-decoration: underline dotted; /* 2 */
|
69
|
+
text-decoration: underline dotted;
|
76
70
|
}
|
77
71
|
|
78
72
|
/**
|
79
|
-
|
80
|
-
|
81
|
-
|
73
|
+
Add the correct font weight in Edge and Safari.
|
74
|
+
*/
|
75
|
+
|
76
|
+
b,
|
77
|
+
strong {
|
82
78
|
font-weight: bolder;
|
83
79
|
}
|
84
80
|
|
85
81
|
/**
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
82
|
+
1. Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
|
83
|
+
2. Correct the odd 'em' font sizing in all browsers.
|
84
|
+
*/
|
85
|
+
|
86
|
+
code,
|
87
|
+
kbd,
|
88
|
+
samp,
|
89
|
+
pre {
|
90
|
+
font-family:
|
91
|
+
ui-monospace,
|
92
|
+
SFMono-Regular,
|
93
|
+
Consolas,
|
94
|
+
'Liberation Mono',
|
95
|
+
Menlo,
|
96
|
+
monospace; /* 1 */
|
91
97
|
font-size: 1em; /* 2 */
|
92
98
|
}
|
93
99
|
|
94
100
|
/**
|
95
|
-
|
96
|
-
|
101
|
+
Add the correct font size in all browsers.
|
102
|
+
*/
|
103
|
+
|
97
104
|
small {
|
98
105
|
font-size: 80%;
|
99
106
|
}
|
100
107
|
|
101
108
|
/**
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
sub,
|
109
|
+
Prevent 'sub' and 'sup' elements from affecting the line height in all browsers.
|
110
|
+
*/
|
111
|
+
|
112
|
+
sub,
|
113
|
+
sup {
|
106
114
|
font-size: 75%;
|
107
115
|
line-height: 0;
|
108
116
|
position: relative;
|
@@ -110,29 +118,43 @@ sub, sup {
|
|
110
118
|
}
|
111
119
|
|
112
120
|
sub {
|
113
|
-
bottom:
|
121
|
+
bottom: -0.25em;
|
114
122
|
}
|
115
123
|
|
116
124
|
sup {
|
117
|
-
top:
|
125
|
+
top: -0.5em;
|
118
126
|
}
|
119
127
|
|
120
|
-
/*
|
121
|
-
|
128
|
+
/*
|
129
|
+
Tabular data
|
130
|
+
============
|
131
|
+
*/
|
132
|
+
|
122
133
|
/**
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
134
|
+
1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
|
135
|
+
2. Correct table border color inheritance in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
|
136
|
+
*/
|
137
|
+
|
138
|
+
table {
|
139
|
+
text-indent: 0; /* 1 */
|
140
|
+
border-color: inherit; /* 2 */
|
127
141
|
}
|
128
142
|
|
129
|
-
/*
|
130
|
-
|
143
|
+
/*
|
144
|
+
Forms
|
145
|
+
=====
|
146
|
+
*/
|
147
|
+
|
131
148
|
/**
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
149
|
+
1. Change the font styles in all browsers.
|
150
|
+
2. Remove the margin in Firefox and Safari.
|
151
|
+
*/
|
152
|
+
|
153
|
+
button,
|
154
|
+
input,
|
155
|
+
optgroup,
|
156
|
+
select,
|
157
|
+
textarea {
|
136
158
|
font-family: inherit; /* 1 */
|
137
159
|
font-size: 100%; /* 1 */
|
138
160
|
line-height: 1.15; /* 1 */
|
@@ -140,150 +162,113 @@ button, input, optgroup, select, textarea {
|
|
140
162
|
}
|
141
163
|
|
142
164
|
/**
|
143
|
-
|
144
|
-
|
145
|
-
*/
|
146
|
-
button, input {
|
147
|
-
/* 1 */
|
148
|
-
overflow: visible;
|
149
|
-
}
|
165
|
+
Remove the inheritance of text transform in Edge and Firefox.
|
166
|
+
*/
|
150
167
|
|
151
|
-
|
152
|
-
|
153
|
-
* 1. Remove the inheritance of text transform in Firefox.
|
154
|
-
*/
|
155
|
-
button, select {
|
156
|
-
/* 1 */
|
168
|
+
button,
|
169
|
+
select {
|
157
170
|
text-transform: none;
|
158
171
|
}
|
159
172
|
|
160
173
|
/**
|
161
|
-
|
162
|
-
|
163
|
-
|
174
|
+
Correct the inability to style clickable types in iOS and Safari.
|
175
|
+
*/
|
176
|
+
|
177
|
+
button,
|
178
|
+
[type='button'],
|
179
|
+
[type='reset'],
|
180
|
+
[type='submit'] {
|
164
181
|
-webkit-appearance: button;
|
165
182
|
}
|
166
183
|
|
167
184
|
/**
|
168
|
-
|
169
|
-
|
170
|
-
|
185
|
+
Remove the inner border and padding in Firefox.
|
186
|
+
*/
|
187
|
+
|
188
|
+
::-moz-focus-inner {
|
171
189
|
border-style: none;
|
172
190
|
padding: 0;
|
173
191
|
}
|
174
192
|
|
175
193
|
/**
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
194
|
+
Restore the focus styles unset by the previous rule.
|
195
|
+
*/
|
196
|
+
|
197
|
+
:-moz-focusring {
|
198
|
+
outline: 1px dotted ButtonText;
|
180
199
|
}
|
181
200
|
|
182
201
|
/**
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
202
|
+
Remove the additional ':invalid' styles in Firefox.
|
203
|
+
See: https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737
|
204
|
+
*/
|
205
|
+
|
206
|
+
:-moz-ui-invalid {
|
207
|
+
box-shadow: none;
|
187
208
|
}
|
188
209
|
|
189
210
|
/**
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
* `fieldset` elements in all browsers.
|
194
|
-
*/
|
211
|
+
Remove the padding so developers are not caught out when they zero out 'fieldset' elements in all browsers.
|
212
|
+
*/
|
213
|
+
|
195
214
|
legend {
|
196
|
-
|
197
|
-
color: inherit; /* 2 */
|
198
|
-
display: table; /* 1 */
|
199
|
-
max-width: 100%; /* 1 */
|
200
|
-
padding: 0; /* 3 */
|
201
|
-
white-space: normal; /* 1 */
|
215
|
+
padding: 0;
|
202
216
|
}
|
203
217
|
|
204
218
|
/**
|
205
|
-
|
206
|
-
|
219
|
+
Add the correct vertical alignment in Chrome and Firefox.
|
220
|
+
*/
|
221
|
+
|
207
222
|
progress {
|
208
223
|
vertical-align: baseline;
|
209
224
|
}
|
210
225
|
|
211
226
|
/**
|
212
|
-
|
213
|
-
|
214
|
-
textarea {
|
215
|
-
overflow: auto;
|
216
|
-
}
|
227
|
+
Correct the cursor style of increment and decrement buttons in Safari.
|
228
|
+
*/
|
217
229
|
|
218
|
-
|
219
|
-
|
220
|
-
* 2. Remove the padding in IE 1.
|
221
|
-
*/
|
222
|
-
[type='checkbox'], [type='radio'] {
|
223
|
-
box-sizing: border-box; /* 1 */
|
224
|
-
padding: 0; /* 2 */
|
225
|
-
}
|
226
|
-
|
227
|
-
/**
|
228
|
-
* Correct the cursor style of increment and decrement buttons in Chrome.
|
229
|
-
*/
|
230
|
-
[type='number']::-webkit-inner-spin-button, [type='number']::-webkit-outer-spin-button {
|
230
|
+
::-webkit-inner-spin-button,
|
231
|
+
::-webkit-outer-spin-button {
|
231
232
|
height: auto;
|
232
233
|
}
|
233
234
|
|
234
235
|
/**
|
235
|
-
|
236
|
-
|
237
|
-
|
236
|
+
1. Correct the odd appearance in Chrome and Safari.
|
237
|
+
2. Correct the outline style in Safari.
|
238
|
+
*/
|
239
|
+
|
238
240
|
[type='search'] {
|
239
|
-
outline-offset: -.125rem; /* 2 */
|
240
241
|
-webkit-appearance: textfield; /* 1 */
|
242
|
+
outline-offset: -2px; /* 2 */
|
241
243
|
}
|
242
244
|
|
243
245
|
/**
|
244
|
-
|
245
|
-
|
246
|
-
|
246
|
+
Remove the inner padding in Chrome and Safari on macOS.
|
247
|
+
*/
|
248
|
+
|
249
|
+
::-webkit-search-decoration {
|
247
250
|
-webkit-appearance: none;
|
248
251
|
}
|
249
252
|
|
250
253
|
/**
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
+
1. Correct the inability to style clickable types in iOS and Safari.
|
255
|
+
2. Change font properties to 'inherit' in Safari.
|
256
|
+
*/
|
257
|
+
|
254
258
|
::-webkit-file-upload-button {
|
255
|
-
font: inherit; /* 2 */
|
256
259
|
-webkit-appearance: button; /* 1 */
|
260
|
+
font: inherit; /* 2 */
|
257
261
|
}
|
258
262
|
|
259
|
-
/* Interactive
|
260
|
-
========================================================================== */
|
261
263
|
/*
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
display: block;
|
266
|
-
}
|
264
|
+
Interactive
|
265
|
+
===========
|
266
|
+
*/
|
267
267
|
|
268
268
|
/*
|
269
|
-
|
270
|
-
|
269
|
+
Add the correct display in Chrome and Safari.
|
270
|
+
*/
|
271
|
+
|
271
272
|
summary {
|
272
273
|
display: list-item;
|
273
|
-
}
|
274
|
-
|
275
|
-
/* Misc
|
276
|
-
========================================================================== */
|
277
|
-
/**
|
278
|
-
* Add the correct display in IE 10+.
|
279
|
-
*/
|
280
|
-
template {
|
281
|
-
display: none;
|
282
|
-
}
|
283
|
-
|
284
|
-
/**
|
285
|
-
* Add the correct display in IE 1.
|
286
|
-
*/
|
287
|
-
[hidden] {
|
288
|
-
display: none;
|
289
|
-
}
|
274
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
const statics = CONFIG.statics.indexOf('//') > 0 ? CONFIG.statics : CONFIG.root;
|
2
|
+
const scrollAction = { x: 0, y: 0 };
|
3
|
+
let diffY = 0;
|
4
|
+
let originTitle, titleTime;
|
5
|
+
const BODY = document.getElementsByTagName('body')[0];
|
6
|
+
const HTML = document.documentElement;
|
7
|
+
const Container = $dom('#container');
|
8
|
+
const loadCat = $dom('#loading');
|
9
|
+
const siteNav = $dom('#nav');
|
10
|
+
const siteHeader = $dom('#header');
|
11
|
+
const menuToggle = siteNav.child('.toggle');
|
12
|
+
const quickBtn = $dom('#quick');
|
13
|
+
const sideBar = $dom('#sidebar');
|
14
|
+
const siteBrand = $dom('#brand');
|
15
|
+
let toolBtn = $dom('#tool');
|
16
|
+
let toolPlayer;
|
17
|
+
let backToTop;
|
18
|
+
let goToComment;
|
19
|
+
let showContents;
|
20
|
+
let siteSearch = $dom('#search');
|
21
|
+
let siteNavHeight, headerHightInner, headerHight;
|
22
|
+
let oWinHeight = window.innerHeight;
|
23
|
+
let oWinWidth = window.innerWidth;
|
24
|
+
let LOCAL_HASH = 0;
|
25
|
+
let LOCAL_URL = window.location.href;
|
26
|
+
let pjax;
|
@@ -0,0 +1,105 @@
|
|
1
|
+
const resizeHandle = () => {
|
2
|
+
siteNavHeight = siteNav.changeOrGetHeight();
|
3
|
+
headerHightInner = siteHeader.changeOrGetHeight();
|
4
|
+
headerHight = headerHightInner + $dom('#waves').changeOrGetHeight();
|
5
|
+
if (oWinWidth !== window.innerWidth) {
|
6
|
+
sideBarToggleHandle(null, 1);
|
7
|
+
}
|
8
|
+
oWinHeight = window.innerHeight;
|
9
|
+
oWinWidth = window.innerWidth;
|
10
|
+
};
|
11
|
+
const scrollHandle = () => {
|
12
|
+
const winHeight = window.innerHeight;
|
13
|
+
const docHeight = getDocHeight();
|
14
|
+
const contentVisibilityHeight = docHeight > winHeight ? docHeight - winHeight : document.body.scrollHeight - winHeight;
|
15
|
+
const SHOW = window.scrollY > headerHightInner;
|
16
|
+
const startScroll = window.scrollY > 0;
|
17
|
+
if (SHOW) {
|
18
|
+
changeMetaTheme('#FFF');
|
19
|
+
}
|
20
|
+
else {
|
21
|
+
changeMetaTheme('#222');
|
22
|
+
}
|
23
|
+
siteNav.toggleClass('show', SHOW);
|
24
|
+
toolBtn.toggleClass('affix', startScroll);
|
25
|
+
siteBrand.toggleClass('affix', startScroll);
|
26
|
+
sideBar.toggleClass('affix', window.scrollY > headerHight && document.body.offsetWidth > 991);
|
27
|
+
if (typeof scrollAction.y === 'undefined') {
|
28
|
+
scrollAction.y = window.scrollY;
|
29
|
+
}
|
30
|
+
diffY = scrollAction.y - window.scrollY;
|
31
|
+
if (diffY < 0) {
|
32
|
+
siteNav.removeClass('up');
|
33
|
+
siteNav.toggleClass('down', SHOW);
|
34
|
+
}
|
35
|
+
else if (diffY > 0) {
|
36
|
+
siteNav.removeClass('down');
|
37
|
+
siteNav.toggleClass('up', SHOW);
|
38
|
+
}
|
39
|
+
else { }
|
40
|
+
scrollAction.y = window.scrollY;
|
41
|
+
const scrollPercent = Math.round(Math.min(100 * window.scrollY / contentVisibilityHeight, 100)) + '%';
|
42
|
+
if (backToTop.child('span').innerText !== scrollPercent) {
|
43
|
+
backToTop.child('span').innerText = scrollPercent;
|
44
|
+
}
|
45
|
+
if ($dom('#sidebar').hasClass('affix') || $dom('#sidebar').hasClass('on')) {
|
46
|
+
$dom('.percent').changeOrGetWidth(scrollPercent);
|
47
|
+
}
|
48
|
+
};
|
49
|
+
const clickMenu = () => {
|
50
|
+
const menuElement = $dom('#clickMenu');
|
51
|
+
window.oncontextmenu = function (event) {
|
52
|
+
if (event.ctrlKey) {
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
event.preventDefault();
|
56
|
+
let x = event.offsetX;
|
57
|
+
let y = event.offsetY;
|
58
|
+
const winWidth = window.innerWidth;
|
59
|
+
const winHeight = window.innerHeight;
|
60
|
+
const menuWidth = menuElement.offsetWidth;
|
61
|
+
const menuHeight = menuElement.offsetHeight;
|
62
|
+
x = winWidth - menuWidth >= x ? x : winWidth - menuWidth;
|
63
|
+
y = winHeight - menuHeight >= y ? y : winHeight - menuHeight;
|
64
|
+
menuElement.style.top = y + 'px';
|
65
|
+
menuElement.style.left = x + 'px';
|
66
|
+
menuElement.classList.add('active');
|
67
|
+
$dom.each('.clickSubmenu', (submenu) => {
|
68
|
+
if (x > (winWidth - menuWidth - submenu.offsetWidth)) {
|
69
|
+
submenu.style.left = '-200px';
|
70
|
+
}
|
71
|
+
else {
|
72
|
+
submenu.style.left = '';
|
73
|
+
submenu.style.right = '-200px';
|
74
|
+
}
|
75
|
+
});
|
76
|
+
};
|
77
|
+
window.addEventListener('click', () => {
|
78
|
+
menuElement.classList.remove('active');
|
79
|
+
});
|
80
|
+
};
|
81
|
+
const visibilityListener = () => {
|
82
|
+
const iconNode = $dom('[rel="icon"]');
|
83
|
+
document.addEventListener('visibilitychange', () => {
|
84
|
+
switch (document.visibilityState) {
|
85
|
+
case 'hidden':
|
86
|
+
iconNode.attr('href', statics + CONFIG.favicon.hidden);
|
87
|
+
document.title = LOCAL.favicon.hide;
|
88
|
+
if (CONFIG.loader.switch) {
|
89
|
+
Loader.show();
|
90
|
+
}
|
91
|
+
clearTimeout(titleTime);
|
92
|
+
break;
|
93
|
+
case 'visible':
|
94
|
+
iconNode.attr('href', statics + CONFIG.favicon.normal);
|
95
|
+
document.title = LOCAL.favicon.show;
|
96
|
+
if (CONFIG.loader.switch) {
|
97
|
+
Loader.hide(1000);
|
98
|
+
}
|
99
|
+
titleTime = setTimeout(() => {
|
100
|
+
document.title = originTitle;
|
101
|
+
}, 2000);
|
102
|
+
break;
|
103
|
+
}
|
104
|
+
});
|
105
|
+
};
|
@@ -0,0 +1,48 @@
|
|
1
|
+
const changeTheme = (type) => {
|
2
|
+
const btn = $dom('.theme .ic');
|
3
|
+
if (type === 'dark') {
|
4
|
+
HTML.attr('data-theme', type);
|
5
|
+
btn.removeClass('i-sun');
|
6
|
+
btn.addClass('i-moon');
|
7
|
+
}
|
8
|
+
else {
|
9
|
+
HTML.attr('data-theme', null);
|
10
|
+
btn.removeClass('i-moon');
|
11
|
+
btn.addClass('i-sun');
|
12
|
+
}
|
13
|
+
};
|
14
|
+
const autoDarkmode = () => {
|
15
|
+
if (CONFIG.auto_dark.enable) {
|
16
|
+
if (new Date().getHours() >= CONFIG.auto_dark.start || new Date().getHours() <= CONFIG.auto_dark.end) {
|
17
|
+
changeTheme('dark');
|
18
|
+
}
|
19
|
+
else {
|
20
|
+
changeTheme();
|
21
|
+
}
|
22
|
+
}
|
23
|
+
};
|
24
|
+
const changeMetaTheme = (color) => {
|
25
|
+
if (HTML.attr('data-theme') === 'dark') {
|
26
|
+
color = '#222';
|
27
|
+
}
|
28
|
+
$dom('meta[name="theme-color"]').attr('content', color);
|
29
|
+
};
|
30
|
+
const themeColorListener = () => {
|
31
|
+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (mediaQueryList) => {
|
32
|
+
if (mediaQueryList.matches) {
|
33
|
+
changeTheme('dark');
|
34
|
+
}
|
35
|
+
else {
|
36
|
+
changeTheme();
|
37
|
+
}
|
38
|
+
});
|
39
|
+
const t = $storage.get('theme');
|
40
|
+
if (t) {
|
41
|
+
changeTheme(t);
|
42
|
+
}
|
43
|
+
else {
|
44
|
+
if (CONFIG.darkmode) {
|
45
|
+
changeTheme('dark');
|
46
|
+
}
|
47
|
+
}
|
48
|
+
};
|
@@ -0,0 +1,60 @@
|
|
1
|
+
const lazyload = lozad('img, [data-background-image]', {
|
2
|
+
loaded(el) {
|
3
|
+
el.addClass('lozaded');
|
4
|
+
}
|
5
|
+
});
|
6
|
+
const Loader = {
|
7
|
+
timer: undefined,
|
8
|
+
lock: false,
|
9
|
+
show() {
|
10
|
+
clearTimeout(this.timer);
|
11
|
+
document.body.removeClass('loaded');
|
12
|
+
loadCat.attr('style', 'display:block');
|
13
|
+
Loader.lock = false;
|
14
|
+
},
|
15
|
+
hide(sec) {
|
16
|
+
if (!CONFIG.loader.start) {
|
17
|
+
sec = -1;
|
18
|
+
}
|
19
|
+
this.timer = setTimeout(this.vanish, sec || 3000);
|
20
|
+
},
|
21
|
+
vanish() {
|
22
|
+
if (Loader.lock) {
|
23
|
+
return;
|
24
|
+
}
|
25
|
+
if (CONFIG.loader.start) {
|
26
|
+
transition(loadCat, 0);
|
27
|
+
}
|
28
|
+
document.body.addClass('loaded');
|
29
|
+
Loader.lock = true;
|
30
|
+
}
|
31
|
+
};
|
32
|
+
const isOutime = () => {
|
33
|
+
let updateTime;
|
34
|
+
if (CONFIG.outime.enable && LOCAL.outime) {
|
35
|
+
const times = document.getElementsByTagName('time');
|
36
|
+
if (times.length === 0) {
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
const posts = document.getElementsByClassName('body md');
|
40
|
+
if (posts.length === 0) {
|
41
|
+
return;
|
42
|
+
}
|
43
|
+
const now = Date.now();
|
44
|
+
const pubTime = new Date(times[0].dateTime);
|
45
|
+
if (times.length === 1) {
|
46
|
+
updateTime = pubTime;
|
47
|
+
}
|
48
|
+
else {
|
49
|
+
updateTime = new Date(times[1].dateTime);
|
50
|
+
}
|
51
|
+
const interval = parseInt(String(now - updateTime));
|
52
|
+
const days = parseInt(String(CONFIG.outime.days)) || 30;
|
53
|
+
if (interval > (days * 86400000)) {
|
54
|
+
const publish = parseInt(String((now - pubTime) / 86400000));
|
55
|
+
const updated = parseInt(String(interval / 86400000));
|
56
|
+
const template = LOCAL.template.replace('{{publish}}', String(publish)).replace('{{updated}}', String(updated));
|
57
|
+
posts[0].insertAdjacentHTML('afterbegin', template);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
};
|