hexo-theme-shokax 0.2.9 → 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 +9 -16
- package/layout/_mixin/comment.pug +2 -1
- package/layout/_mixin/widgets.pug +2 -1
- package/layout/_partials/layout.pug +8 -8
- package/layout/post.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/{components.js → components/sidebar.js} +26 -27
- package/source/js/_app/fireworks.js +28 -42
- 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/{vue.js → library/vue.js} +6 -6
- 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 +87 -91
- package/source/js/_app/global.js +0 -314
- package/source/js/_app/library.js +0 -312
- package/source/js/_app/page.js +0 -674
package/source/js/_app/page.js
DELETED
@@ -1,674 +0,0 @@
|
|
1
|
-
const cardActive = function () {
|
2
|
-
if (!$dom('.index.wrap')) {
|
3
|
-
return;
|
4
|
-
}
|
5
|
-
const io = new IntersectionObserver(function (entries) {
|
6
|
-
entries.forEach(function (article) {
|
7
|
-
if (article.target.hasClass('show')) {
|
8
|
-
io.unobserve(article.target);
|
9
|
-
}
|
10
|
-
else {
|
11
|
-
if (article.isIntersecting || article.intersectionRatio > 0) {
|
12
|
-
article.target.addClass('show');
|
13
|
-
io.unobserve(article.target);
|
14
|
-
}
|
15
|
-
}
|
16
|
-
});
|
17
|
-
}, {
|
18
|
-
root: null,
|
19
|
-
threshold: [0.3]
|
20
|
-
});
|
21
|
-
$dom.each('.index.wrap article.item, .index.wrap section.item', function (article) {
|
22
|
-
io.observe(article);
|
23
|
-
});
|
24
|
-
$dom('.index.wrap .item:first-child').addClass('show');
|
25
|
-
$dom.each('.cards .item', function (element, index) {
|
26
|
-
['mouseenter', 'touchstart'].forEach(function (item) {
|
27
|
-
element.addEventListener(item, function (event) {
|
28
|
-
if ($dom('.cards .item.active')) {
|
29
|
-
$dom('.cards .item.active').removeClass('active');
|
30
|
-
}
|
31
|
-
element.addClass('active');
|
32
|
-
}, { passive: true });
|
33
|
-
});
|
34
|
-
['mouseleave'].forEach(function (item) {
|
35
|
-
element.addEventListener(item, function (event) {
|
36
|
-
element.removeClass('active');
|
37
|
-
}, { passive: true });
|
38
|
-
});
|
39
|
-
});
|
40
|
-
};
|
41
|
-
const registerExtURL = function () {
|
42
|
-
$dom.each('span.exturl', function (element) {
|
43
|
-
const link = document.createElement('a');
|
44
|
-
link.href = decodeURIComponent(window.atob(element.dataset.url).split('').map(function (c) {
|
45
|
-
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
46
|
-
}).join(''));
|
47
|
-
link.rel = 'noopener external nofollow noreferrer';
|
48
|
-
link.target = '_blank';
|
49
|
-
link.className = element.className;
|
50
|
-
link.title = element.title || element.innerText;
|
51
|
-
link.innerHTML = element.innerHTML;
|
52
|
-
if (element.dataset.backgroundImage) {
|
53
|
-
link.dataset.backgroundImage = element.dataset.backgroundImage;
|
54
|
-
}
|
55
|
-
element.parentNode.replaceChild(link, element);
|
56
|
-
});
|
57
|
-
};
|
58
|
-
const postFancybox = function (p) {
|
59
|
-
if ($dom(p + ' .md img')) {
|
60
|
-
vendorCss('fancybox');
|
61
|
-
vendorJs('fancybox', function () {
|
62
|
-
const q = jQuery.noConflict();
|
63
|
-
$dom.each(p + ' p.gallery', function (element) {
|
64
|
-
const box = document.createElement('div');
|
65
|
-
box.className = 'gallery';
|
66
|
-
box.attr('data-height', String(element.attr('data-height') || 220));
|
67
|
-
box.innerHTML = element.innerHTML.replace(/<br>/g, '');
|
68
|
-
element.parentNode.insertBefore(box, element);
|
69
|
-
element.remove();
|
70
|
-
});
|
71
|
-
$dom.each(p + ' .md img:not(.emoji):not(.vemoji)', function (element) {
|
72
|
-
const $image = q(element);
|
73
|
-
const imageLink = $image.attr('data-src') || $image.attr('src');
|
74
|
-
const $imageWrapLink = $image.wrap('<a class="fancybox" href="' + imageLink + '" itemscope itemtype="https://schema.org/ImageObject" itemprop="url"></a>').parent('a');
|
75
|
-
let info;
|
76
|
-
let captionClass = 'image-info';
|
77
|
-
if (!$image.is('a img')) {
|
78
|
-
$image.data('safe-src', imageLink);
|
79
|
-
if (!$image.is('.gallery img')) {
|
80
|
-
$imageWrapLink.attr('data-fancybox', 'default').attr('rel', 'default');
|
81
|
-
}
|
82
|
-
else {
|
83
|
-
captionClass = 'jg-caption';
|
84
|
-
}
|
85
|
-
}
|
86
|
-
if ((info = element.attr('title'))) {
|
87
|
-
$imageWrapLink.attr('data-caption', info);
|
88
|
-
const para = document.createElement('span');
|
89
|
-
const txt = document.createTextNode(info);
|
90
|
-
para.appendChild(txt);
|
91
|
-
para.addClass(captionClass);
|
92
|
-
element.insertAfter(para);
|
93
|
-
}
|
94
|
-
});
|
95
|
-
$dom.each(p + ' div.gallery', function (el, i) {
|
96
|
-
q(el).justifiedGallery({
|
97
|
-
rowHeight: q(el).data('height') || 120,
|
98
|
-
rel: 'gallery-' + i
|
99
|
-
}).on('jg.complete', function () {
|
100
|
-
q(this).find('a').each((k, ele) => {
|
101
|
-
ele.attr('data-fancybox', 'gallery-' + i);
|
102
|
-
});
|
103
|
-
});
|
104
|
-
});
|
105
|
-
q.fancybox.defaults.hash = false;
|
106
|
-
q(p + ' .fancybox').fancybox({
|
107
|
-
loop: true,
|
108
|
-
helpers: {
|
109
|
-
overlay: {
|
110
|
-
locked: false
|
111
|
-
}
|
112
|
-
}
|
113
|
-
});
|
114
|
-
}, window.jQuery);
|
115
|
-
}
|
116
|
-
};
|
117
|
-
const postBeauty = function () {
|
118
|
-
loadComments();
|
119
|
-
if (!$dom('.md')) {
|
120
|
-
return;
|
121
|
-
}
|
122
|
-
postFancybox('.post.block');
|
123
|
-
$dom('.post.block').oncopy = async function (event) {
|
124
|
-
showtip(LOCAL.copyright);
|
125
|
-
if (LOCAL.nocopy) {
|
126
|
-
event.preventDefault();
|
127
|
-
return;
|
128
|
-
}
|
129
|
-
const copyright = await $dom.asyncify('#copyright');
|
130
|
-
if (window.getSelection().toString().length > 30 && copyright) {
|
131
|
-
event.preventDefault();
|
132
|
-
const author = '# ' + copyright.child('.author').innerText;
|
133
|
-
const link = '# ' + copyright.child('.link').innerText;
|
134
|
-
const license = '# ' + copyright.child('.license').innerText;
|
135
|
-
const htmlData = author + '<br>' + link + '<br>' + license + '<br><br>' + window.getSelection().toString().replace(/\r\n/g, '<br>');
|
136
|
-
const textData = author + '\n' + link + '\n' + license + '\n\n' + window.getSelection().toString().replace(/\r\n/g, '\n');
|
137
|
-
if (event.clipboardData) {
|
138
|
-
event.clipboardData.setData('text/html', htmlData);
|
139
|
-
event.clipboardData.setData('text/plain', textData);
|
140
|
-
}
|
141
|
-
else {
|
142
|
-
if (window.clipboardData) {
|
143
|
-
return window.clipboardData.setData('text', textData);
|
144
|
-
}
|
145
|
-
}
|
146
|
-
}
|
147
|
-
};
|
148
|
-
$dom.each('li ruby', function (element) {
|
149
|
-
let parent = element.parentNode;
|
150
|
-
if (element.parentNode.tagName !== 'LI') {
|
151
|
-
parent = element.parentNode.parentNode;
|
152
|
-
}
|
153
|
-
parent.addClass('ruby');
|
154
|
-
});
|
155
|
-
$dom.each('ol[start]', function (element) {
|
156
|
-
element.style.counterReset = 'counter ' + parseInt(element.attr('start') - 1);
|
157
|
-
});
|
158
|
-
$dom.each('.md table', function (element) {
|
159
|
-
element.wrapObject({
|
160
|
-
className: 'table-container'
|
161
|
-
});
|
162
|
-
});
|
163
|
-
$dom.each('.highlight > .table-container', function (element) {
|
164
|
-
element.className = 'code-container';
|
165
|
-
});
|
166
|
-
$dom.each('figure.highlight', function (element) {
|
167
|
-
const code_container = element.child('.code-container');
|
168
|
-
const caption = element.child('figcaption');
|
169
|
-
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>');
|
170
|
-
const copyBtn = element.child('.copy-btn');
|
171
|
-
if (LOCAL.nocopy) {
|
172
|
-
copyBtn.remove();
|
173
|
-
}
|
174
|
-
else {
|
175
|
-
copyBtn.addEventListener('click', function (event) {
|
176
|
-
const target = event.currentTarget;
|
177
|
-
let comma = '';
|
178
|
-
let code = '';
|
179
|
-
code_container.find('pre').forEach(function (line) {
|
180
|
-
code += comma + line.innerText;
|
181
|
-
comma = '\n';
|
182
|
-
});
|
183
|
-
clipBoard(code, function (result) {
|
184
|
-
target.child('.ic').className = result ? 'ic i-check' : 'ic i-times';
|
185
|
-
target.blur();
|
186
|
-
showtip(LOCAL.copyright);
|
187
|
-
});
|
188
|
-
}, { passive: true });
|
189
|
-
copyBtn.addEventListener('mouseleave', function (event) {
|
190
|
-
setTimeout(function () {
|
191
|
-
event.target.child('.ic').className = 'ic i-clipboard';
|
192
|
-
}, 1000);
|
193
|
-
});
|
194
|
-
}
|
195
|
-
const breakBtn = element.child('.breakline-btn');
|
196
|
-
breakBtn.addEventListener('click', function (event) {
|
197
|
-
const target = event.currentTarget;
|
198
|
-
if (element.hasClass('breakline')) {
|
199
|
-
element.removeClass('breakline');
|
200
|
-
target.child('.ic').className = 'ic i-align-left';
|
201
|
-
}
|
202
|
-
else {
|
203
|
-
element.addClass('breakline');
|
204
|
-
target.child('.ic').className = 'ic i-align-justify';
|
205
|
-
}
|
206
|
-
});
|
207
|
-
const fullscreenBtn = element.child('.fullscreen-btn');
|
208
|
-
const removeFullscreen = function () {
|
209
|
-
element.removeClass('fullscreen');
|
210
|
-
element.scrollTop = 0;
|
211
|
-
BODY.removeClass('fullscreen');
|
212
|
-
fullscreenBtn.child('.ic').className = 'ic i-expand';
|
213
|
-
};
|
214
|
-
const fullscreenHandle = function (event) {
|
215
|
-
const target = event.currentTarget;
|
216
|
-
if (element.hasClass('fullscreen')) {
|
217
|
-
removeFullscreen();
|
218
|
-
if (code_container && code_container.find('tr').length > 15) {
|
219
|
-
const showBtn = code_container.child('.show-btn');
|
220
|
-
code_container.style.maxHeight = '300px';
|
221
|
-
showBtn.removeClass('open');
|
222
|
-
}
|
223
|
-
pageScroll(element);
|
224
|
-
}
|
225
|
-
else {
|
226
|
-
element.addClass('fullscreen');
|
227
|
-
BODY.addClass('fullscreen');
|
228
|
-
fullscreenBtn.child('.ic').className = 'ic i-compress';
|
229
|
-
if (code_container && code_container.find('tr').length > 15) {
|
230
|
-
const showBtn = code_container.child('.show-btn');
|
231
|
-
code_container.style.maxHeight = '';
|
232
|
-
showBtn.addClass('open');
|
233
|
-
}
|
234
|
-
}
|
235
|
-
};
|
236
|
-
fullscreenBtn.addEventListener('click', fullscreenHandle);
|
237
|
-
caption && caption.addEventListener('click', fullscreenHandle);
|
238
|
-
if (code_container && code_container.find('tr').length > 15) {
|
239
|
-
code_container.style.maxHeight = '300px';
|
240
|
-
code_container.insertAdjacentHTML('beforeend', '<div class="show-btn"><i class="ic i-angle-down"></i></div>');
|
241
|
-
const showBtn = code_container.child('.show-btn');
|
242
|
-
const hideCode = function () {
|
243
|
-
code_container.style.maxHeight = '300px';
|
244
|
-
showBtn.removeClass('open');
|
245
|
-
};
|
246
|
-
const showCode = function () {
|
247
|
-
code_container.style.maxHeight = '';
|
248
|
-
showBtn.addClass('open');
|
249
|
-
};
|
250
|
-
showBtn.addEventListener('click', function (event) {
|
251
|
-
if (showBtn.hasClass('open')) {
|
252
|
-
removeFullscreen();
|
253
|
-
hideCode();
|
254
|
-
pageScroll(code_container);
|
255
|
-
}
|
256
|
-
else {
|
257
|
-
showCode();
|
258
|
-
}
|
259
|
-
});
|
260
|
-
}
|
261
|
-
});
|
262
|
-
$dom.asyncifyEach('pre.mermaid > svg', function (element) {
|
263
|
-
const temp = element;
|
264
|
-
temp.style.maxWidth = '';
|
265
|
-
});
|
266
|
-
$dom.each('.reward button', function (element) {
|
267
|
-
element.addEventListener('click', function (event) {
|
268
|
-
event.preventDefault();
|
269
|
-
const qr = $dom('#qr');
|
270
|
-
if (qr.display() === 'inline-flex') {
|
271
|
-
transition(qr, 0);
|
272
|
-
}
|
273
|
-
else {
|
274
|
-
transition(qr, 1, function () {
|
275
|
-
qr.display('inline-flex');
|
276
|
-
});
|
277
|
-
}
|
278
|
-
});
|
279
|
-
});
|
280
|
-
$dom.asyncifyEach('.quiz > ul.options li', function (element) {
|
281
|
-
element.addEventListener('click', function (event) {
|
282
|
-
if (element.hasClass('correct')) {
|
283
|
-
element.toggleClass('right');
|
284
|
-
element.parentNode.parentNode.addClass('show');
|
285
|
-
}
|
286
|
-
else {
|
287
|
-
element.toggleClass('wrong');
|
288
|
-
}
|
289
|
-
});
|
290
|
-
});
|
291
|
-
$dom.asyncifyEach('.quiz > p', function (element) {
|
292
|
-
element.addEventListener('click', function (event) {
|
293
|
-
element.parentNode.toggleClass('show');
|
294
|
-
});
|
295
|
-
});
|
296
|
-
$dom.asyncifyEach('.quiz > p:first-child', function (element) {
|
297
|
-
const quiz = element.parentNode;
|
298
|
-
let type = 'choice';
|
299
|
-
if (quiz.hasClass('true') || quiz.hasClass('false')) {
|
300
|
-
type = 'true_false';
|
301
|
-
}
|
302
|
-
if (quiz.hasClass('multi')) {
|
303
|
-
type = 'multiple';
|
304
|
-
}
|
305
|
-
if (quiz.hasClass('fill')) {
|
306
|
-
type = 'gap_fill';
|
307
|
-
}
|
308
|
-
if (quiz.hasClass('essay')) {
|
309
|
-
type = 'essay';
|
310
|
-
}
|
311
|
-
element.attr('data-type', LOCAL.quiz[type]);
|
312
|
-
});
|
313
|
-
$dom.asyncifyEach('.quiz .mistake', function (element) {
|
314
|
-
element.attr('data-type', LOCAL.quiz.mistake);
|
315
|
-
});
|
316
|
-
$dom.each('div.tags a', function (element) {
|
317
|
-
element.className = ['primary', 'success', 'info', 'warning', 'danger'][Math.floor(Math.random() * 5)];
|
318
|
-
});
|
319
|
-
$dom.asyncifyEach('.md div.player', function (element) {
|
320
|
-
mediaPlayer(element, {
|
321
|
-
type: element.attr('data-type'),
|
322
|
-
mode: 'order',
|
323
|
-
btns: []
|
324
|
-
}).player.load(JSON.parse(element.attr('data-src'))).fetch();
|
325
|
-
});
|
326
|
-
const angleDown = document.querySelectorAll('.show-btn .i-angle-down');
|
327
|
-
if (angleDown.length) {
|
328
|
-
const io = new IntersectionObserver((entries) => {
|
329
|
-
entries.forEach(entry => {
|
330
|
-
if (entry.isIntersecting) {
|
331
|
-
angleDown.forEach(i => {
|
332
|
-
i.classList.remove('stop-animation');
|
333
|
-
});
|
334
|
-
}
|
335
|
-
else {
|
336
|
-
angleDown.forEach(i => {
|
337
|
-
i.classList.add('stop-animation');
|
338
|
-
});
|
339
|
-
}
|
340
|
-
});
|
341
|
-
}, {
|
342
|
-
root: null,
|
343
|
-
threshold: 0.5
|
344
|
-
});
|
345
|
-
angleDown.forEach(i => {
|
346
|
-
io.observe(i);
|
347
|
-
});
|
348
|
-
}
|
349
|
-
};
|
350
|
-
const tabFormat = function () {
|
351
|
-
let first_tab;
|
352
|
-
$dom.each('div.tab', function (element, index) {
|
353
|
-
if (element.attr('data-ready')) {
|
354
|
-
return;
|
355
|
-
}
|
356
|
-
const id = element.attr('data-id');
|
357
|
-
const title = element.attr('data-title');
|
358
|
-
let box = $dom('#' + id);
|
359
|
-
if (!box) {
|
360
|
-
box = document.createElement('div');
|
361
|
-
box.className = 'tabs';
|
362
|
-
box.id = id;
|
363
|
-
box.innerHTML = '<div class="show-btn"></div>';
|
364
|
-
const showBtn = box.child('.show-btn');
|
365
|
-
showBtn.addEventListener('click', function (event) {
|
366
|
-
pageScroll(box);
|
367
|
-
});
|
368
|
-
element.parentNode.insertBefore(box, element);
|
369
|
-
first_tab = true;
|
370
|
-
}
|
371
|
-
else {
|
372
|
-
first_tab = false;
|
373
|
-
}
|
374
|
-
let ul = box.child('.nav ul');
|
375
|
-
if (!ul) {
|
376
|
-
ul = box.createChild('div', {
|
377
|
-
className: 'nav',
|
378
|
-
innerHTML: '<ul></ul>'
|
379
|
-
}).child('ul');
|
380
|
-
}
|
381
|
-
const li = ul.createChild('li', {
|
382
|
-
innerHTML: title
|
383
|
-
});
|
384
|
-
if (first_tab) {
|
385
|
-
li.addClass('active');
|
386
|
-
element.addClass('active');
|
387
|
-
}
|
388
|
-
li.addEventListener('click', function (event) {
|
389
|
-
const target = event.currentTarget;
|
390
|
-
box.find('.active').forEach(function (el) {
|
391
|
-
el.removeClass('active');
|
392
|
-
});
|
393
|
-
element.addClass('active');
|
394
|
-
target.addClass('active');
|
395
|
-
});
|
396
|
-
box.appendChild(element);
|
397
|
-
element.attr('data-ready', String(true));
|
398
|
-
});
|
399
|
-
};
|
400
|
-
const loadComments = function () {
|
401
|
-
const element = $dom('#comments');
|
402
|
-
if (!element) {
|
403
|
-
goToComment.display('none');
|
404
|
-
return;
|
405
|
-
}
|
406
|
-
else {
|
407
|
-
goToComment.display('');
|
408
|
-
}
|
409
|
-
const io = new IntersectionObserver(function (entries, observer) {
|
410
|
-
const entry = entries[0];
|
411
|
-
vendorCss('valine');
|
412
|
-
if (entry.isIntersecting || entry.intersectionRatio > 0) {
|
413
|
-
transition($dom('#comments'), 'bounceUpIn');
|
414
|
-
observer.disconnect();
|
415
|
-
}
|
416
|
-
});
|
417
|
-
io.observe(element);
|
418
|
-
};
|
419
|
-
const algoliaSearch = function (pjax) {
|
420
|
-
if (CONFIG.search === null) {
|
421
|
-
return;
|
422
|
-
}
|
423
|
-
if (!siteSearch) {
|
424
|
-
siteSearch = BODY.createChild('div', {
|
425
|
-
id: 'search',
|
426
|
-
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>'
|
427
|
-
});
|
428
|
-
}
|
429
|
-
const search = instantsearch({
|
430
|
-
indexName: CONFIG.search.indexName,
|
431
|
-
searchClient: algoliasearch(CONFIG.search.appID, CONFIG.search.apiKey),
|
432
|
-
searchFunction: function (helper) {
|
433
|
-
const searchInput = $dom('.search-input');
|
434
|
-
if (searchInput.value) {
|
435
|
-
helper.search();
|
436
|
-
}
|
437
|
-
}
|
438
|
-
});
|
439
|
-
search.on('render', function () {
|
440
|
-
pjax.refresh($dom('#search-hits'));
|
441
|
-
});
|
442
|
-
search.addWidgets([
|
443
|
-
instantsearch.widgets.configure({
|
444
|
-
hitsPerPage: CONFIG.search.hits.per_page || 10
|
445
|
-
}),
|
446
|
-
instantsearch.widgets.searchBox({
|
447
|
-
container: '.search-input-container',
|
448
|
-
placeholder: LOCAL.search.placeholder,
|
449
|
-
showReset: false,
|
450
|
-
showSubmit: false,
|
451
|
-
showLoadingIndicator: false,
|
452
|
-
cssClasses: {
|
453
|
-
input: 'search-input'
|
454
|
-
}
|
455
|
-
}),
|
456
|
-
instantsearch.widgets.stats({
|
457
|
-
container: '#search-stats',
|
458
|
-
templates: {
|
459
|
-
text: function (data) {
|
460
|
-
const stats = LOCAL.search.stats
|
461
|
-
.replace(/\$\{hits}/, data.nbHits)
|
462
|
-
.replace(/\$\{time}/, data.processingTimeMS);
|
463
|
-
return stats + '<span class="algolia-powered"></span><hr>';
|
464
|
-
}
|
465
|
-
}
|
466
|
-
}),
|
467
|
-
instantsearch.widgets.hits({
|
468
|
-
container: '#search-hits',
|
469
|
-
templates: {
|
470
|
-
item: function (data) {
|
471
|
-
const cats = data.categories ? '<span>' + data.categories.join('<i class="ic i-angle-right"></i>') + '</span>' : '';
|
472
|
-
return '<a href="' + CONFIG.root + data.path + '">' + cats + data._highlightResult.title.value + '</a>';
|
473
|
-
},
|
474
|
-
empty: function (data) {
|
475
|
-
return '<div id="hits-empty">' +
|
476
|
-
LOCAL.search.empty.replace(/\$\{query}/, data.query) +
|
477
|
-
'</div>';
|
478
|
-
}
|
479
|
-
},
|
480
|
-
cssClasses: {
|
481
|
-
item: 'item'
|
482
|
-
}
|
483
|
-
}),
|
484
|
-
instantsearch.widgets.pagination({
|
485
|
-
container: '#search-pagination',
|
486
|
-
scrollTo: false,
|
487
|
-
showFirst: false,
|
488
|
-
showLast: false,
|
489
|
-
templates: {
|
490
|
-
first: '<i class="ic i-angle-double-left"></i>',
|
491
|
-
last: '<i class="ic i-angle-double-right"></i>',
|
492
|
-
previous: '<i class="ic i-angle-left"></i>',
|
493
|
-
next: '<i class="ic i-angle-right"></i>'
|
494
|
-
},
|
495
|
-
cssClasses: {
|
496
|
-
root: 'pagination',
|
497
|
-
item: 'pagination-item',
|
498
|
-
link: 'page-number',
|
499
|
-
selectedItem: 'current',
|
500
|
-
disabledItem: 'disabled-item'
|
501
|
-
}
|
502
|
-
})
|
503
|
-
]);
|
504
|
-
search.start();
|
505
|
-
$dom.each('.search', function (element) {
|
506
|
-
element.addEventListener('click', function () {
|
507
|
-
document.body.style.overflow = 'hidden';
|
508
|
-
transition(siteSearch, 'shrinkIn', function () {
|
509
|
-
$dom('.search-input').focus();
|
510
|
-
});
|
511
|
-
});
|
512
|
-
});
|
513
|
-
const onPopupClose = function () {
|
514
|
-
document.body.style.overflow = '';
|
515
|
-
transition(siteSearch, 0);
|
516
|
-
};
|
517
|
-
siteSearch.addEventListener('click', function (event) {
|
518
|
-
if (event.target === siteSearch) {
|
519
|
-
onPopupClose();
|
520
|
-
}
|
521
|
-
});
|
522
|
-
$dom('.close-btn').addEventListener('click', onPopupClose);
|
523
|
-
window.addEventListener('pjax:success', onPopupClose);
|
524
|
-
window.addEventListener('keyup', function (event) {
|
525
|
-
if (event.key === 'Escape') {
|
526
|
-
onPopupClose();
|
527
|
-
}
|
528
|
-
});
|
529
|
-
};
|
530
|
-
const domInit = function () {
|
531
|
-
$dom.each('.overview .menu > .item', function (el) {
|
532
|
-
siteNav.child('.menu').appendChild(el.cloneNode(true));
|
533
|
-
});
|
534
|
-
loadCat.addEventListener('click', Loader.vanish);
|
535
|
-
menuToggle.addEventListener('click', sideBarToggleHandle);
|
536
|
-
$dom('.dimmer').addEventListener('click', sideBarToggleHandle);
|
537
|
-
quickBtn.child('.down').addEventListener('click', goToBottomHandle);
|
538
|
-
quickBtn.child('.up').addEventListener('click', backToTopHandle);
|
539
|
-
if (!toolBtn) {
|
540
|
-
toolBtn = siteHeader.createChild('div', {
|
541
|
-
id: 'tool',
|
542
|
-
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>'
|
543
|
-
});
|
544
|
-
}
|
545
|
-
toolPlayer = toolBtn.child('.player');
|
546
|
-
backToTop = toolBtn.child('.back-to-top');
|
547
|
-
goToComment = toolBtn.child('.chat');
|
548
|
-
showContents = toolBtn.child('.contents');
|
549
|
-
backToTop.addEventListener('click', backToTopHandle);
|
550
|
-
goToComment.addEventListener('click', goToCommentHandle);
|
551
|
-
showContents.addEventListener('click', sideBarToggleHandle);
|
552
|
-
if (typeof mediaPlayer !== 'undefined') {
|
553
|
-
mediaPlayer(toolPlayer);
|
554
|
-
$dom('main').addEventListener('click', function () {
|
555
|
-
toolPlayer.player.mini();
|
556
|
-
});
|
557
|
-
}
|
558
|
-
const createIntersectionObserver = function () {
|
559
|
-
new IntersectionObserver(([entry]) => {
|
560
|
-
if (entry.isIntersecting) {
|
561
|
-
document.querySelectorAll('.parallax>use').forEach(i => {
|
562
|
-
i.classList.remove('stop-animation');
|
563
|
-
});
|
564
|
-
document.querySelectorAll('#imgs .item').forEach(i => {
|
565
|
-
i.classList.remove('stop-animation');
|
566
|
-
});
|
567
|
-
}
|
568
|
-
else {
|
569
|
-
document.querySelectorAll('.parallax>use').forEach(i => {
|
570
|
-
i.classList.add('stop-animation');
|
571
|
-
});
|
572
|
-
document.querySelectorAll('#imgs .item').forEach(i => {
|
573
|
-
i.classList.add('stop-animation');
|
574
|
-
});
|
575
|
-
}
|
576
|
-
}, {
|
577
|
-
root: null,
|
578
|
-
threshold: 0.2
|
579
|
-
}).observe(document.getElementById('waves'));
|
580
|
-
new IntersectionObserver(([entry]) => {
|
581
|
-
if (entry.isIntersecting) {
|
582
|
-
document.querySelectorAll('.with-love>i').forEach(i => {
|
583
|
-
i.classList.remove('stop-animation');
|
584
|
-
});
|
585
|
-
}
|
586
|
-
else {
|
587
|
-
document.querySelectorAll('.with-love>i').forEach(i => {
|
588
|
-
i.classList.add('stop-animation');
|
589
|
-
});
|
590
|
-
}
|
591
|
-
}, {
|
592
|
-
root: null,
|
593
|
-
threshold: 0.2
|
594
|
-
}).observe(document.querySelector('.with-love'));
|
595
|
-
};
|
596
|
-
createIntersectionObserver();
|
597
|
-
};
|
598
|
-
const pjaxReload = function () {
|
599
|
-
pagePosition();
|
600
|
-
if (sideBar.hasClass('on')) {
|
601
|
-
transition(sideBar, 0, function () {
|
602
|
-
sideBar.removeClass('on');
|
603
|
-
menuToggle.removeClass('close');
|
604
|
-
});
|
605
|
-
}
|
606
|
-
const mainNode = $dom('#main');
|
607
|
-
mainNode.innerHTML = '';
|
608
|
-
mainNode.appendChild(loadCat.lastChild.cloneNode(true));
|
609
|
-
pageScroll(0);
|
610
|
-
};
|
611
|
-
const siteRefresh = function (reload) {
|
612
|
-
LOCAL_HASH = 0;
|
613
|
-
LOCAL_URL = window.location.href;
|
614
|
-
vendorCss('katex');
|
615
|
-
vendorJs('copy_tex');
|
616
|
-
vendorCss('mermaid');
|
617
|
-
vendorJs('chart');
|
618
|
-
if (reload !== 1) {
|
619
|
-
$dom.each('script[data-pjax]', pjaxScript);
|
620
|
-
}
|
621
|
-
originTitle = document.title;
|
622
|
-
resizeHandle();
|
623
|
-
menuActive();
|
624
|
-
sideBarTab();
|
625
|
-
sidebarTOC();
|
626
|
-
registerExtURL();
|
627
|
-
postBeauty();
|
628
|
-
tabFormat();
|
629
|
-
if (typeof mediaPlayer !== 'undefined') {
|
630
|
-
toolPlayer.player.load(LOCAL.audio || CONFIG.audio || {});
|
631
|
-
}
|
632
|
-
Loader.hide();
|
633
|
-
setTimeout(function () {
|
634
|
-
positionInit();
|
635
|
-
}, 500);
|
636
|
-
cardActive();
|
637
|
-
lazyload.observe();
|
638
|
-
isOutime();
|
639
|
-
};
|
640
|
-
const siteInit = function () {
|
641
|
-
domInit();
|
642
|
-
pjax = new Pjax({
|
643
|
-
selectors: [
|
644
|
-
'head title',
|
645
|
-
'.languages',
|
646
|
-
'.twikoo',
|
647
|
-
'.pjax',
|
648
|
-
'.leancloud-recent-comment',
|
649
|
-
'script[data-config]'
|
650
|
-
],
|
651
|
-
cacheBust: false
|
652
|
-
});
|
653
|
-
CONFIG.quicklink.ignores = LOCAL.ignores;
|
654
|
-
quicklink.listen(CONFIG.quicklink);
|
655
|
-
autoDarkmode();
|
656
|
-
if (!CONFIG.disableVL) {
|
657
|
-
visibilityListener();
|
658
|
-
}
|
659
|
-
themeColorListener();
|
660
|
-
algoliaSearch(pjax);
|
661
|
-
window.addEventListener('scroll', scrollHandle);
|
662
|
-
window.addEventListener('resize', resizeHandle);
|
663
|
-
window.addEventListener('pjax:send', pjaxReload);
|
664
|
-
window.addEventListener('pjax:success', siteRefresh);
|
665
|
-
window.addEventListener('beforeunload', function () {
|
666
|
-
pagePosition();
|
667
|
-
});
|
668
|
-
siteRefresh(1);
|
669
|
-
};
|
670
|
-
window.addEventListener('DOMContentLoaded', siteInit, {
|
671
|
-
passive: true
|
672
|
-
});
|
673
|
-
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;');
|
674
|
-
console.log('%c by kaitaku ' + '%c https://www.kaitaku.xyz', 'color: white; background: #00bfff; padding: 5px 3px;', 'padding: 4px;border:1px solid #00bfff');
|