hexo-theme-shokax 0.0.1-alpha1

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