hexo-theme-shokax 0.2.10 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +68 -81
- package/README.md +8 -6
- package/UsageRestrictions.md +21 -0
- package/_config.yml +5 -12
- package/layout/_mixin/widgets.pug +2 -1
- package/package.json +8 -4
- package/scripts/generaters/script.js +33 -7
- 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/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
@@ -0,0 +1,232 @@
|
|
1
|
+
const postBeauty = () => {
|
2
|
+
loadComments();
|
3
|
+
if (!$dom('.md')) {
|
4
|
+
return;
|
5
|
+
}
|
6
|
+
postFancybox('.post.block');
|
7
|
+
$dom('.post.block').oncopy = async (event) => {
|
8
|
+
showtip(LOCAL.copyright);
|
9
|
+
if (LOCAL.nocopy) {
|
10
|
+
event.preventDefault();
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
const copyright = await $dom.asyncify('#copyright');
|
14
|
+
if (window.getSelection().toString().length > 30 && copyright) {
|
15
|
+
event.preventDefault();
|
16
|
+
const author = '# ' + copyright.child('.author').innerText;
|
17
|
+
const link = '# ' + copyright.child('.link').innerText;
|
18
|
+
const license = '# ' + copyright.child('.license').innerText;
|
19
|
+
const htmlData = author + '<br>' + link + '<br>' + license + '<br><br>' + window.getSelection().toString().replace(/\r\n/g, '<br>');
|
20
|
+
const textData = author + '\n' + link + '\n' + license + '\n\n' + window.getSelection().toString().replace(/\r\n/g, '\n');
|
21
|
+
if (event.clipboardData) {
|
22
|
+
event.clipboardData.setData('text/html', htmlData);
|
23
|
+
event.clipboardData.setData('text/plain', textData);
|
24
|
+
}
|
25
|
+
else {
|
26
|
+
if (window.clipboardData) {
|
27
|
+
return window.clipboardData.setData('text', textData);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
};
|
32
|
+
$dom.each('li ruby', (element) => {
|
33
|
+
let parent = element.parentNode;
|
34
|
+
if (element.parentNode.tagName !== 'LI') {
|
35
|
+
parent = element.parentNode.parentNode;
|
36
|
+
}
|
37
|
+
parent.addClass('ruby');
|
38
|
+
});
|
39
|
+
$dom.each('ol[start]', (element) => {
|
40
|
+
element.style.counterReset = 'counter ' + parseInt(element.attr('start') - 1);
|
41
|
+
});
|
42
|
+
$dom.each('.md table', (element) => {
|
43
|
+
element.wrapObject({
|
44
|
+
className: 'table-container'
|
45
|
+
});
|
46
|
+
});
|
47
|
+
$dom.each('.highlight > .table-container', (element) => {
|
48
|
+
element.className = 'code-container';
|
49
|
+
});
|
50
|
+
$dom.each('figure.highlight', (element) => {
|
51
|
+
const code_container = element.child('.code-container');
|
52
|
+
const caption = element.child('figcaption');
|
53
|
+
element.insertAdjacentHTML('beforeend', '<div class="operation"><span class="breakline-btn"><i class="ic i-align-left"></i></span><span class="copy-btn"><i class="ic i-clipboard"></i></span><span class="fullscreen-btn"><i class="ic i-expand"></i></span></div>');
|
54
|
+
const copyBtn = element.child('.copy-btn');
|
55
|
+
if (LOCAL.nocopy) {
|
56
|
+
copyBtn.remove();
|
57
|
+
}
|
58
|
+
else {
|
59
|
+
copyBtn.addEventListener('click', (event) => {
|
60
|
+
const target = event.currentTarget;
|
61
|
+
let comma = '';
|
62
|
+
let code = '';
|
63
|
+
code_container.find('pre').forEach((line) => {
|
64
|
+
code += comma + line.innerText;
|
65
|
+
comma = '\n';
|
66
|
+
});
|
67
|
+
clipBoard(code, (result) => {
|
68
|
+
target.child('.ic').className = result ? 'ic i-check' : 'ic i-times';
|
69
|
+
target.blur();
|
70
|
+
showtip(LOCAL.copyright);
|
71
|
+
});
|
72
|
+
}, { passive: true });
|
73
|
+
copyBtn.addEventListener('mouseleave', (event) => {
|
74
|
+
setTimeout(() => {
|
75
|
+
event.target.child('.ic').className = 'ic i-clipboard';
|
76
|
+
}, 1000);
|
77
|
+
});
|
78
|
+
}
|
79
|
+
const breakBtn = element.child('.breakline-btn');
|
80
|
+
breakBtn.addEventListener('click', (event) => {
|
81
|
+
const target = event.currentTarget;
|
82
|
+
if (element.hasClass('breakline')) {
|
83
|
+
element.removeClass('breakline');
|
84
|
+
target.child('.ic').className = 'ic i-align-left';
|
85
|
+
}
|
86
|
+
else {
|
87
|
+
element.addClass('breakline');
|
88
|
+
target.child('.ic').className = 'ic i-align-justify';
|
89
|
+
}
|
90
|
+
});
|
91
|
+
const fullscreenBtn = element.child('.fullscreen-btn');
|
92
|
+
const removeFullscreen = () => {
|
93
|
+
element.removeClass('fullscreen');
|
94
|
+
element.scrollTop = 0;
|
95
|
+
BODY.removeClass('fullscreen');
|
96
|
+
fullscreenBtn.child('.ic').className = 'ic i-expand';
|
97
|
+
};
|
98
|
+
const fullscreenHandle = () => {
|
99
|
+
if (element.hasClass('fullscreen')) {
|
100
|
+
removeFullscreen();
|
101
|
+
if (code_container && code_container.find('tr').length > 15) {
|
102
|
+
const showBtn = code_container.child('.show-btn');
|
103
|
+
code_container.style.maxHeight = '300px';
|
104
|
+
showBtn.removeClass('open');
|
105
|
+
}
|
106
|
+
pageScroll(element);
|
107
|
+
}
|
108
|
+
else {
|
109
|
+
element.addClass('fullscreen');
|
110
|
+
BODY.addClass('fullscreen');
|
111
|
+
fullscreenBtn.child('.ic').className = 'ic i-compress';
|
112
|
+
if (code_container && code_container.find('tr').length > 15) {
|
113
|
+
const showBtn = code_container.child('.show-btn');
|
114
|
+
code_container.style.maxHeight = '';
|
115
|
+
showBtn.addClass('open');
|
116
|
+
}
|
117
|
+
}
|
118
|
+
};
|
119
|
+
fullscreenBtn.addEventListener('click', fullscreenHandle);
|
120
|
+
caption && caption.addEventListener('click', fullscreenHandle);
|
121
|
+
if (code_container && code_container.find('tr').length > 15) {
|
122
|
+
code_container.style.maxHeight = '300px';
|
123
|
+
code_container.insertAdjacentHTML('beforeend', '<div class="show-btn"><i class="ic i-angle-down"></i></div>');
|
124
|
+
const showBtn = code_container.child('.show-btn');
|
125
|
+
const hideCode = () => {
|
126
|
+
code_container.style.maxHeight = '300px';
|
127
|
+
showBtn.removeClass('open');
|
128
|
+
};
|
129
|
+
const showCode = () => {
|
130
|
+
code_container.style.maxHeight = '';
|
131
|
+
showBtn.addClass('open');
|
132
|
+
};
|
133
|
+
showBtn.addEventListener('click', () => {
|
134
|
+
if (showBtn.hasClass('open')) {
|
135
|
+
removeFullscreen();
|
136
|
+
hideCode();
|
137
|
+
pageScroll(code_container);
|
138
|
+
}
|
139
|
+
else {
|
140
|
+
showCode();
|
141
|
+
}
|
142
|
+
});
|
143
|
+
}
|
144
|
+
});
|
145
|
+
$dom.asyncifyEach('pre.mermaid > svg', (element) => {
|
146
|
+
const temp = element;
|
147
|
+
temp.style.maxWidth = '';
|
148
|
+
});
|
149
|
+
$dom.each('.reward button', (element) => {
|
150
|
+
element.addEventListener('click', (event) => {
|
151
|
+
event.preventDefault();
|
152
|
+
const qr = $dom('#qr');
|
153
|
+
if (qr.display() === 'inline-flex') {
|
154
|
+
transition(qr, 0);
|
155
|
+
}
|
156
|
+
else {
|
157
|
+
transition(qr, 1, () => {
|
158
|
+
qr.display('inline-flex');
|
159
|
+
});
|
160
|
+
}
|
161
|
+
});
|
162
|
+
});
|
163
|
+
$dom.asyncifyEach('.quiz > ul.options li', (element) => {
|
164
|
+
element.addEventListener('click', () => {
|
165
|
+
if (element.hasClass('correct')) {
|
166
|
+
element.toggleClass('right');
|
167
|
+
element.parentNode.parentNode.addClass('show');
|
168
|
+
}
|
169
|
+
else {
|
170
|
+
element.toggleClass('wrong');
|
171
|
+
}
|
172
|
+
});
|
173
|
+
});
|
174
|
+
$dom.asyncifyEach('.quiz > p', (element) => {
|
175
|
+
element.addEventListener('click', () => {
|
176
|
+
element.parentNode.toggleClass('show');
|
177
|
+
});
|
178
|
+
});
|
179
|
+
$dom.asyncifyEach('.quiz > p:first-child', (element) => {
|
180
|
+
const quiz = element.parentNode;
|
181
|
+
let type = 'choice';
|
182
|
+
if (quiz.hasClass('true') || quiz.hasClass('false')) {
|
183
|
+
type = 'true_false';
|
184
|
+
}
|
185
|
+
if (quiz.hasClass('multi')) {
|
186
|
+
type = 'multiple';
|
187
|
+
}
|
188
|
+
if (quiz.hasClass('fill')) {
|
189
|
+
type = 'gap_fill';
|
190
|
+
}
|
191
|
+
if (quiz.hasClass('essay')) {
|
192
|
+
type = 'essay';
|
193
|
+
}
|
194
|
+
element.attr('data-type', LOCAL.quiz[type]);
|
195
|
+
});
|
196
|
+
$dom.asyncifyEach('.quiz .mistake', (element) => {
|
197
|
+
element.attr('data-type', LOCAL.quiz.mistake);
|
198
|
+
});
|
199
|
+
$dom.each('div.tags a', (element) => {
|
200
|
+
element.className = ['primary', 'success', 'info', 'warning', 'danger'][Math.floor(Math.random() * 5)];
|
201
|
+
});
|
202
|
+
$dom.asyncifyEach('.md div.player', (element) => {
|
203
|
+
mediaPlayer(element, {
|
204
|
+
type: element.attr('data-type'),
|
205
|
+
mode: 'order',
|
206
|
+
btns: []
|
207
|
+
}).player.load(JSON.parse(element.attr('data-src'))).fetch();
|
208
|
+
});
|
209
|
+
const angleDown = document.querySelectorAll('.show-btn .i-angle-down');
|
210
|
+
if (angleDown.length) {
|
211
|
+
const io = new IntersectionObserver((entries) => {
|
212
|
+
entries.forEach(entry => {
|
213
|
+
if (entry.isIntersecting) {
|
214
|
+
angleDown.forEach(i => {
|
215
|
+
i.classList.remove('stop-animation');
|
216
|
+
});
|
217
|
+
}
|
218
|
+
else {
|
219
|
+
angleDown.forEach(i => {
|
220
|
+
i.classList.add('stop-animation');
|
221
|
+
});
|
222
|
+
}
|
223
|
+
});
|
224
|
+
}, {
|
225
|
+
root: null,
|
226
|
+
threshold: 0.5
|
227
|
+
});
|
228
|
+
angleDown.forEach(i => {
|
229
|
+
io.observe(i);
|
230
|
+
});
|
231
|
+
}
|
232
|
+
};
|
@@ -0,0 +1,111 @@
|
|
1
|
+
const algoliaSearch = (pjax) => {
|
2
|
+
if (CONFIG.search === null) {
|
3
|
+
return;
|
4
|
+
}
|
5
|
+
if (!siteSearch) {
|
6
|
+
siteSearch = BODY.createChild('div', {
|
7
|
+
id: 'search',
|
8
|
+
innerHTML: '<div class="inner"><div class="header"><span class="icon"><i class="ic i-search"></i></span><div class="search-input-container"></div><span class="close-btn"><i class="ic i-times-circle"></i></span></div><div class="results"><div class="inner"><div id="search-stats"></div><div id="search-hits"></div><div id="search-pagination"></div></div></div></div>'
|
9
|
+
});
|
10
|
+
}
|
11
|
+
const search = instantsearch({
|
12
|
+
indexName: CONFIG.search.indexName,
|
13
|
+
searchClient: algoliasearch(CONFIG.search.appID, CONFIG.search.apiKey),
|
14
|
+
searchFunction(helper) {
|
15
|
+
const searchInput = $dom('.search-input');
|
16
|
+
if (searchInput.value) {
|
17
|
+
helper.search();
|
18
|
+
}
|
19
|
+
}
|
20
|
+
});
|
21
|
+
search.on('render', () => {
|
22
|
+
pjax.refresh($dom('#search-hits'));
|
23
|
+
});
|
24
|
+
search.addWidgets([
|
25
|
+
instantsearch.widgets.configure({
|
26
|
+
hitsPerPage: CONFIG.search.hits.per_page || 10
|
27
|
+
}),
|
28
|
+
instantsearch.widgets.searchBox({
|
29
|
+
container: '.search-input-container',
|
30
|
+
placeholder: LOCAL.search.placeholder,
|
31
|
+
showReset: false,
|
32
|
+
showSubmit: false,
|
33
|
+
showLoadingIndicator: false,
|
34
|
+
cssClasses: {
|
35
|
+
input: 'search-input'
|
36
|
+
}
|
37
|
+
}),
|
38
|
+
instantsearch.widgets.stats({
|
39
|
+
container: '#search-stats',
|
40
|
+
templates: {
|
41
|
+
text(data) {
|
42
|
+
const stats = LOCAL.search.stats
|
43
|
+
.replace(/\$\{hits}/, data.nbHits)
|
44
|
+
.replace(/\$\{time}/, data.processingTimeMS);
|
45
|
+
return stats + '<span class="algolia-powered"></span><hr>';
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}),
|
49
|
+
instantsearch.widgets.hits({
|
50
|
+
container: '#search-hits',
|
51
|
+
templates: {
|
52
|
+
item(data) {
|
53
|
+
const cats = data.categories ? '<span>' + data.categories.join('<i class="ic i-angle-right"></i>') + '</span>' : '';
|
54
|
+
return '<a href="' + CONFIG.root + data.path + '">' + cats + data._highlightResult.title.value + '</a>';
|
55
|
+
},
|
56
|
+
empty(data) {
|
57
|
+
return '<div id="hits-empty">' +
|
58
|
+
LOCAL.search.empty.replace(/\$\{query}/, data.query) +
|
59
|
+
'</div>';
|
60
|
+
}
|
61
|
+
},
|
62
|
+
cssClasses: {
|
63
|
+
item: 'item'
|
64
|
+
}
|
65
|
+
}),
|
66
|
+
instantsearch.widgets.pagination({
|
67
|
+
container: '#search-pagination',
|
68
|
+
scrollTo: false,
|
69
|
+
showFirst: false,
|
70
|
+
showLast: false,
|
71
|
+
templates: {
|
72
|
+
first: '<i class="ic i-angle-double-left"></i>',
|
73
|
+
last: '<i class="ic i-angle-double-right"></i>',
|
74
|
+
previous: '<i class="ic i-angle-left"></i>',
|
75
|
+
next: '<i class="ic i-angle-right"></i>'
|
76
|
+
},
|
77
|
+
cssClasses: {
|
78
|
+
root: 'pagination',
|
79
|
+
item: 'pagination-item',
|
80
|
+
link: 'page-number',
|
81
|
+
selectedItem: 'current',
|
82
|
+
disabledItem: 'disabled-item'
|
83
|
+
}
|
84
|
+
})
|
85
|
+
]);
|
86
|
+
search.start();
|
87
|
+
$dom.each('.search', (element) => {
|
88
|
+
element.addEventListener('click', () => {
|
89
|
+
document.body.style.overflow = 'hidden';
|
90
|
+
transition(siteSearch, 'shrinkIn', () => {
|
91
|
+
$dom('.search-input').focus();
|
92
|
+
});
|
93
|
+
});
|
94
|
+
});
|
95
|
+
const onPopupClose = () => {
|
96
|
+
document.body.style.overflow = '';
|
97
|
+
transition(siteSearch, 0);
|
98
|
+
};
|
99
|
+
siteSearch.addEventListener('click', (event) => {
|
100
|
+
if (event.target === siteSearch) {
|
101
|
+
onPopupClose();
|
102
|
+
}
|
103
|
+
});
|
104
|
+
$dom('.close-btn').addEventListener('click', onPopupClose);
|
105
|
+
window.addEventListener('pjax:success', onPopupClose);
|
106
|
+
window.addEventListener('keyup', (event) => {
|
107
|
+
if (event.key === 'Escape') {
|
108
|
+
onPopupClose();
|
109
|
+
}
|
110
|
+
});
|
111
|
+
};
|
@@ -0,0 +1,50 @@
|
|
1
|
+
const tabFormat = () => {
|
2
|
+
let first_tab;
|
3
|
+
$dom.each('div.tab', (element) => {
|
4
|
+
if (element.attr('data-ready')) {
|
5
|
+
return;
|
6
|
+
}
|
7
|
+
const id = element.attr('data-id');
|
8
|
+
const title = element.attr('data-title');
|
9
|
+
let box = $dom('#' + id);
|
10
|
+
if (!box) {
|
11
|
+
box = document.createElement('div');
|
12
|
+
box.className = 'tabs';
|
13
|
+
box.id = id;
|
14
|
+
box.innerHTML = '<div class="show-btn"></div>';
|
15
|
+
const showBtn = box.child('.show-btn');
|
16
|
+
showBtn.addEventListener('click', () => {
|
17
|
+
pageScroll(box);
|
18
|
+
});
|
19
|
+
element.parentNode.insertBefore(box, element);
|
20
|
+
first_tab = true;
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
first_tab = false;
|
24
|
+
}
|
25
|
+
let ul = box.child('.nav ul');
|
26
|
+
if (!ul) {
|
27
|
+
ul = box.createChild('div', {
|
28
|
+
className: 'nav',
|
29
|
+
innerHTML: '<ul></ul>'
|
30
|
+
}).child('ul');
|
31
|
+
}
|
32
|
+
const li = ul.createChild('li', {
|
33
|
+
innerHTML: title
|
34
|
+
});
|
35
|
+
if (first_tab) {
|
36
|
+
li.addClass('active');
|
37
|
+
element.addClass('active');
|
38
|
+
}
|
39
|
+
li.addEventListener('click', (event) => {
|
40
|
+
const target = event.currentTarget;
|
41
|
+
box.find('.active').forEach((el) => {
|
42
|
+
el.removeClass('active');
|
43
|
+
});
|
44
|
+
element.addClass('active');
|
45
|
+
target.addClass('active');
|
46
|
+
});
|
47
|
+
box.appendChild(element);
|
48
|
+
element.attr('data-ready', String(true));
|
49
|
+
});
|
50
|
+
};
|
@@ -0,0 +1,68 @@
|
|
1
|
+
const domInit = () => {
|
2
|
+
$dom.each('.overview .menu > .item', (el) => {
|
3
|
+
siteNav.child('.menu').appendChild(el.cloneNode(true));
|
4
|
+
});
|
5
|
+
loadCat.addEventListener('click', Loader.vanish);
|
6
|
+
menuToggle.addEventListener('click', sideBarToggleHandle);
|
7
|
+
$dom('.dimmer').addEventListener('click', sideBarToggleHandle);
|
8
|
+
quickBtn.child('.down').addEventListener('click', goToBottomHandle);
|
9
|
+
quickBtn.child('.up').addEventListener('click', backToTopHandle);
|
10
|
+
if (!toolBtn) {
|
11
|
+
toolBtn = siteHeader.createChild('div', {
|
12
|
+
id: 'tool',
|
13
|
+
innerHTML: '<div class="item player"></div><div class="item contents"><i class="ic i-list-ol"></i></div><div class="item chat"><i class="ic i-comments"></i></div><div class="item back-to-top"><i class="ic i-arrow-up"></i><span>0%</span></div>'
|
14
|
+
});
|
15
|
+
}
|
16
|
+
toolPlayer = toolBtn.child('.player');
|
17
|
+
backToTop = toolBtn.child('.back-to-top');
|
18
|
+
goToComment = toolBtn.child('.chat');
|
19
|
+
showContents = toolBtn.child('.contents');
|
20
|
+
backToTop.addEventListener('click', backToTopHandle);
|
21
|
+
goToComment.addEventListener('click', goToCommentHandle);
|
22
|
+
showContents.addEventListener('click', sideBarToggleHandle);
|
23
|
+
if (typeof mediaPlayer !== 'undefined') {
|
24
|
+
mediaPlayer(toolPlayer);
|
25
|
+
$dom('main').addEventListener('click', () => {
|
26
|
+
toolPlayer.player.mini();
|
27
|
+
});
|
28
|
+
}
|
29
|
+
const createIntersectionObserver = () => {
|
30
|
+
new IntersectionObserver(([entry]) => {
|
31
|
+
if (entry.isIntersecting) {
|
32
|
+
document.querySelectorAll('.parallax>use').forEach(i => {
|
33
|
+
i.classList.remove('stop-animation');
|
34
|
+
});
|
35
|
+
document.querySelectorAll('#imgs .item').forEach(i => {
|
36
|
+
i.classList.remove('stop-animation');
|
37
|
+
});
|
38
|
+
}
|
39
|
+
else {
|
40
|
+
document.querySelectorAll('.parallax>use').forEach(i => {
|
41
|
+
i.classList.add('stop-animation');
|
42
|
+
});
|
43
|
+
document.querySelectorAll('#imgs .item').forEach(i => {
|
44
|
+
i.classList.add('stop-animation');
|
45
|
+
});
|
46
|
+
}
|
47
|
+
}, {
|
48
|
+
root: null,
|
49
|
+
threshold: 0.2
|
50
|
+
}).observe(document.getElementById('waves'));
|
51
|
+
new IntersectionObserver(([entry]) => {
|
52
|
+
if (entry.isIntersecting) {
|
53
|
+
document.querySelectorAll('.with-love>i').forEach(i => {
|
54
|
+
i.classList.remove('stop-animation');
|
55
|
+
});
|
56
|
+
}
|
57
|
+
else {
|
58
|
+
document.querySelectorAll('.with-love>i').forEach(i => {
|
59
|
+
i.classList.add('stop-animation');
|
60
|
+
});
|
61
|
+
}
|
62
|
+
}, {
|
63
|
+
root: null,
|
64
|
+
threshold: 0.2
|
65
|
+
}).observe(document.querySelector('.with-love'));
|
66
|
+
};
|
67
|
+
createIntersectionObserver();
|
68
|
+
};
|
@@ -0,0 +1,42 @@
|
|
1
|
+
const pjaxReload = () => {
|
2
|
+
pagePosition();
|
3
|
+
if (sideBar.hasClass('on')) {
|
4
|
+
transition(sideBar, 0, () => {
|
5
|
+
sideBar.removeClass('on');
|
6
|
+
menuToggle.removeClass('close');
|
7
|
+
});
|
8
|
+
}
|
9
|
+
const mainNode = $dom('#main');
|
10
|
+
mainNode.innerHTML = '';
|
11
|
+
mainNode.appendChild(loadCat.lastChild.cloneNode(true));
|
12
|
+
pageScroll(0);
|
13
|
+
};
|
14
|
+
const siteRefresh = (reload) => {
|
15
|
+
LOCAL_HASH = 0;
|
16
|
+
LOCAL_URL = window.location.href;
|
17
|
+
vendorCss('katex');
|
18
|
+
vendorJs('copy_tex');
|
19
|
+
vendorCss('mermaid');
|
20
|
+
vendorJs('chart');
|
21
|
+
if (reload !== 1) {
|
22
|
+
$dom.each('script[data-pjax]', pjaxScript);
|
23
|
+
}
|
24
|
+
originTitle = document.title;
|
25
|
+
resizeHandle();
|
26
|
+
menuActive();
|
27
|
+
sideBarTab();
|
28
|
+
sidebarTOC();
|
29
|
+
registerExtURL();
|
30
|
+
postBeauty();
|
31
|
+
tabFormat();
|
32
|
+
if (typeof mediaPlayer !== 'undefined') {
|
33
|
+
toolPlayer.player.load(LOCAL.audio || CONFIG.audio || {});
|
34
|
+
}
|
35
|
+
Loader.hide();
|
36
|
+
setTimeout(() => {
|
37
|
+
positionInit();
|
38
|
+
}, 500);
|
39
|
+
cardActive();
|
40
|
+
lazyload.observe();
|
41
|
+
isOutime();
|
42
|
+
};
|
@@ -0,0 +1,34 @@
|
|
1
|
+
const siteInit = () => {
|
2
|
+
domInit();
|
3
|
+
pjax = new Pjax({
|
4
|
+
selectors: [
|
5
|
+
'head title',
|
6
|
+
'.languages',
|
7
|
+
'.twikoo',
|
8
|
+
'.pjax',
|
9
|
+
'.leancloud-recent-comment',
|
10
|
+
'script[data-config]'
|
11
|
+
],
|
12
|
+
cacheBust: false
|
13
|
+
});
|
14
|
+
CONFIG.quicklink.ignores = LOCAL.ignores;
|
15
|
+
quicklink.listen(CONFIG.quicklink);
|
16
|
+
autoDarkmode();
|
17
|
+
if (!CONFIG.disableVL) {
|
18
|
+
visibilityListener();
|
19
|
+
}
|
20
|
+
themeColorListener();
|
21
|
+
algoliaSearch(pjax);
|
22
|
+
window.addEventListener('scroll', scrollHandle);
|
23
|
+
window.addEventListener('resize', resizeHandle);
|
24
|
+
window.addEventListener('pjax:send', pjaxReload);
|
25
|
+
window.addEventListener('pjax:success', siteRefresh);
|
26
|
+
window.addEventListener('beforeunload', () => {
|
27
|
+
pagePosition();
|
28
|
+
});
|
29
|
+
siteRefresh(1);
|
30
|
+
};
|
31
|
+
window.addEventListener('DOMContentLoaded', siteInit, {
|
32
|
+
passive: true
|
33
|
+
});
|
34
|
+
console.log('%c Theme.ShokaX v' + CONFIG.version + ' %c https://github.com/theme-shoka-x/hexo-theme-shokaX ', 'color: white; background: #e9546b; padding:5px 0;', 'padding:4px;border:1px solid #e9546b;');
|
package/source/js/_app/player.js
CHANGED
@@ -662,7 +662,7 @@ const mediaPlayer = (t, config) => {
|
|
662
662
|
const lrcText = lyric[i]
|
663
663
|
.replace(/.*\[(\d{2}):(\d{2})(\.(\d{2,3}))?]/g, '')
|
664
664
|
.replace(/<(\d{2}):(\d{2})(\.(\d{2,3}))?>/g, '')
|
665
|
-
.trim;
|
665
|
+
.trim();
|
666
666
|
if (lrcTimes) {
|
667
667
|
const timeLen = lrcTimes.length;
|
668
668
|
for (let j = 0; j < timeLen; j++) {
|