hexo-theme-stellar 1.34.0 → 1.36.0

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.
Files changed (64) hide show
  1. package/_config.yml +25 -19
  2. package/layout/_partial/comments/artalk/layout.ejs +2 -2
  3. package/layout/_partial/comments/artalk/script.ejs +3 -9
  4. package/layout/_partial/comments/beaudar/script.ejs +2 -8
  5. package/layout/_partial/comments/giscus/script.ejs +2 -8
  6. package/layout/_partial/comments/twikoo/layout.ejs +2 -2
  7. package/layout/_partial/comments/twikoo/script.ejs +3 -9
  8. package/layout/_partial/comments/utterances/script.ejs +2 -8
  9. package/layout/_partial/comments/waline/layout.ejs +1 -1
  10. package/layout/_partial/comments/waline/script.ejs +1 -7
  11. package/layout/_partial/head.ejs +0 -3
  12. package/layout/_partial/scripts/defines.ejs +118 -1
  13. package/layout/_partial/scripts/lazyload.ejs +7 -6
  14. package/layout/_partial/scripts/services.ejs +11 -13
  15. package/layout/_partial/scripts/utils.ejs +358 -66
  16. package/layout/_partial/widgets/tagtree.ejs +1 -1
  17. package/layout/_partial/widgets/toc.ejs +1 -4
  18. package/layout/_partial/widgets/tree.ejs +1 -1
  19. package/layout/_plugins/fancybox.ejs +23 -8
  20. package/layout/_plugins/scrollreveal.ejs +77 -13
  21. package/layout/layout.ejs +0 -1
  22. package/package.json +4 -2
  23. package/scripts/events/index.js +2 -1
  24. package/scripts/events/lib/doc_tree.js +7 -4
  25. package/scripts/events/lib/merge_posts.js +3 -1
  26. package/scripts/events/lib/notebooks.js +5 -3
  27. package/scripts/events/lib/path_normalize.js +22 -0
  28. package/scripts/filters/lib/img_lazyload.js +9 -9
  29. package/scripts/generators/search.js +3 -1
  30. package/scripts/helpers/json_ld.js +3 -2
  31. package/scripts/helpers/pretty_url.js +9 -10
  32. package/scripts/lib/path_utils.js +24 -0
  33. package/scripts/tags/lib/emoji.js +17 -2
  34. package/scripts/tags/lib/image.js +13 -18
  35. package/source/css/_common/html.styl +0 -2
  36. package/source/css/_components/widgets/toc.styl +2 -2
  37. package/source/css/_plugins/index.styl +0 -3
  38. package/source/css/_plugins/lazyload.styl +40 -26
  39. package/source/css/_plugins/scrollreveal.styl +5 -1
  40. package/source/js/main.js +157 -73
  41. package/source/js/search/algolia-search.js +62 -62
  42. package/source/js/search/local-search.js +37 -36
  43. package/source/js/services/artalk_latest_comment.js +5 -7
  44. package/source/js/services/contributors.js +4 -6
  45. package/source/js/services/fcircle.js +4 -6
  46. package/source/js/services/friends.js +4 -6
  47. package/source/js/services/friends_and_posts.js +4 -6
  48. package/source/js/services/ghinfo.js +6 -8
  49. package/source/js/services/giscus_latest_comment.js +4 -6
  50. package/source/js/services/mdrender.js +2 -2
  51. package/source/js/services/memos.js +3 -4
  52. package/source/js/services/rss.js +10 -12
  53. package/source/js/services/siteinfo.js +24 -26
  54. package/source/js/services/sites.js +4 -6
  55. package/source/js/services/timeline.js +4 -6
  56. package/source/js/services/twikoo_latest_comment.js +5 -7
  57. package/source/js/services/waline_latest_comment.js +4 -6
  58. package/source/js/services/weibo.js +4 -6
  59. package/CLAUDE.md +0 -217
  60. package/docs/audits/2026-08-08-stellar-analysis.md +0 -267
  61. package/docs/release-process.md +0 -59
  62. package/layout/_plugins/pjax.ejs +0 -8
  63. package/source/css/_plugins/pjax.styl +0 -61
  64. package/source/js/plugins/pjax.js +0 -646
package/source/js/main.js CHANGED
@@ -53,11 +53,14 @@ const util = {
53
53
  },
54
54
 
55
55
  scrollTop: () => {
56
- window.scrollTo({ top: 0, behavior: "smooth" });
56
+ smoothScrollTo(0);
57
57
  },
58
58
 
59
59
  scrollComment: () => {
60
- document.getElementById('comments').scrollIntoView({ behavior: "smooth" });
60
+ const el = document.getElementById('comments');
61
+ if (el) {
62
+ smoothScrollTo(el.getBoundingClientRect().top + window.scrollY - 32);
63
+ }
61
64
  },
62
65
 
63
66
  viewportLazyload: (target, func, enabled = true) => {
@@ -94,73 +97,168 @@ const hud = {
94
97
 
95
98
  const l_body = document.querySelector('.l_body');
96
99
 
100
+ // 通用平滑滚动(自定义动画,TOC / 回到顶部 / 参与讨论共用)
101
+ let scrollAnim = null;
102
+ function cancelSmoothScroll() {
103
+ if (scrollAnim !== null) {
104
+ cancelAnimationFrame(scrollAnim);
105
+ scrollAnim = null;
106
+ }
107
+ }
108
+ function smoothScrollTo(targetY) {
109
+ cancelSmoothScroll();
110
+ targetY = Math.max(0, targetY);
111
+ const startY = window.scrollY;
112
+ const diff = targetY - startY;
113
+ if (Math.abs(diff) < 2) {
114
+ return;
115
+ }
116
+ // 短距离 300ms,长距离最多 600ms
117
+ const duration = Math.min(600, Math.max(300, Math.abs(diff) * 0.15));
118
+ const startTime = performance.now();
119
+ function step(now) {
120
+ const t = Math.min(1, (now - startTime) / duration);
121
+ const eased = 1 - Math.pow(1 - t, 3); // easeOutCubic
122
+ // 显式指定 instant,避免全局 scroll-behavior: smooth 与自定义动画叠加导致滚动变慢
123
+ window.scrollTo({ top: startY + diff * eased, behavior: 'instant' });
124
+ if (t < 1) {
125
+ scrollAnim = requestAnimationFrame(step);
126
+ } else {
127
+ scrollAnim = null;
128
+ }
129
+ }
130
+ scrollAnim = requestAnimationFrame(step);
131
+ }
132
+ window.addEventListener('wheel', cancelSmoothScroll, { passive: true });
133
+ window.addEventListener('touchstart', cancelSmoothScroll, { passive: true });
134
+
97
135
 
98
136
  const init = {
99
137
  toc: () => {
100
- utils.jq(() => {
101
- const scrollOffset = 32;
102
- var segs = [];
103
- $("article.md-text :header").each(function (idx, node) {
104
- segs.push(node);
105
- });
106
- function activeTOC() {
107
- var scrollTop = $(this).scrollTop();
108
- var topSeg = null;
109
- for (var idx in segs) {
110
- var seg = $(segs[idx]);
111
- if (seg.offset().top > scrollTop + scrollOffset) {
112
- continue;
113
- }
114
- if (!topSeg) {
115
- topSeg = seg;
116
- } else if (seg.offset().top >= topSeg.offset().top) {
117
- topSeg = seg;
118
- }
138
+ const scrollOffset = 32;
139
+ // 滚动位置取整后标题顶可能落在偏移线下方 1~2px,加容差避免高亮回跳到上一条
140
+ const scrollTolerance = 4;
141
+ var segs = utils.qsa("article.md-text h1, article.md-text h2, article.md-text h3, article.md-text h4, article.md-text h5, article.md-text h6");
142
+ function activeTOC() {
143
+ var scrollTop = window.scrollY;
144
+ var topSeg = null;
145
+ for (var i = 0; i < segs.length; i++) {
146
+ var segTop = segs[i].getBoundingClientRect().top + window.scrollY;
147
+ if (segTop > scrollTop + scrollOffset + scrollTolerance) {
148
+ continue;
119
149
  }
120
- if (topSeg) {
121
- $("#data-toc a.toc-link").removeClass("active");
122
- var link = "#" + topSeg.attr("id");
123
- if (link != '#undefined') {
124
- const highlightItem = $('#data-toc a.toc-link[href="' + encodeURI(link) + '"]');
125
- if (highlightItem.length > 0) {
126
- highlightItem.addClass("active");
127
- }
128
- } else {
129
- $('#data-toc a.toc-link:first').addClass("active");
130
- }
150
+ if (!topSeg || segTop >= topSeg.getBoundingClientRect().top + window.scrollY) {
151
+ topSeg = segs[i];
131
152
  }
132
153
  }
133
- function scrollTOC() {
134
- const e0 = document.querySelector('#data-toc .toc');
135
- const e1 = document.querySelector('#data-toc .toc a.toc-link.active');
136
- if (e0 == null || e1 == null) {
137
- return;
138
- }
139
- const offsetBottom = e1.getBoundingClientRect().bottom - e0.getBoundingClientRect().bottom + 100;
140
- const offsetTop = e1.getBoundingClientRect().top - e0.getBoundingClientRect().top - 64;
141
- if (offsetTop < 0) {
142
- e0.scrollBy({ top: offsetTop, behavior: "smooth" });
143
- } else if (offsetBottom > 0) {
144
- e0.scrollBy({ top: offsetBottom, behavior: "smooth" });
154
+ if (topSeg) {
155
+ utils.dom("#data-toc a.toc-link").removeClass("active");
156
+ var id = topSeg.getAttribute("id");
157
+ var link = id ? "#" + id : "#undefined";
158
+ if (link != '#undefined') {
159
+ const highlightItem = utils.dom('#data-toc a.toc-link[href="' + encodeURI(link) + '"]');
160
+ if (highlightItem.length > 0) {
161
+ highlightItem.addClass("active");
162
+ }
163
+ } else {
164
+ const first = utils.qs('#data-toc a.toc-link');
165
+ if (first) first.classList.add("active");
145
166
  }
146
167
  }
168
+ }
169
+ function scrollTOC() {
170
+ const e0 = document.querySelector('#data-toc .toc');
171
+ const e1 = document.querySelector('#data-toc .toc a.toc-link.active');
172
+ if (e0 == null || e1 == null) {
173
+ return;
174
+ }
175
+ const offsetBottom = e1.getBoundingClientRect().bottom - e0.getBoundingClientRect().bottom + 100;
176
+ const offsetTop = e1.getBoundingClientRect().top - e0.getBoundingClientRect().top - 64;
177
+ if (offsetTop < 0) {
178
+ e0.scrollBy({ top: offsetTop, behavior: "smooth" });
179
+ } else if (offsetBottom > 0) {
180
+ e0.scrollBy({ top: offsetBottom, behavior: "smooth" });
181
+ }
182
+ }
147
183
 
148
- var timeout = null;
149
- window.addEventListener('scroll', function () {
150
- activeTOC();
151
- if (timeout !== null) clearTimeout(timeout);
152
- timeout = setTimeout(function () {
153
- scrollTOC();
154
- }.bind(this), 50);
155
- });
156
- })
184
+ var timeout = null;
185
+ window.addEventListener('scroll', function () {
186
+ activeTOC();
187
+ if (timeout !== null) clearTimeout(timeout);
188
+ timeout = setTimeout(function () {
189
+ scrollTOC();
190
+ }, 50);
191
+ });
157
192
  },
158
193
  sidebar: () => {
159
- utils.jq(() => {
160
- $("#data-toc a.toc-link").click(function (e) {
161
- sidebar.dismiss();
162
- });
163
- })
194
+ utils.dom("#data-toc a.toc-link").click(function (e) {
195
+ const href = this.getAttribute("href");
196
+ const id = href && href.indexOf("#") === 0 ? decodeURIComponent(href.slice(1)) : null;
197
+ const target = id && document.getElementById(id);
198
+ if (target) {
199
+ e.preventDefault();
200
+ const offset = 32; // 与 activeTOC 的 scrollOffset 保持一致
201
+ const targetY = target.getBoundingClientRect().top + window.scrollY - offset;
202
+ smoothScrollTo(targetY);
203
+ if (window.history && window.history.pushState) {
204
+ window.history.pushState(null, "", href);
205
+ }
206
+ }
207
+ sidebar.dismiss();
208
+ });
209
+ },
210
+ leftbarScroll: () => {
211
+ const container = document.querySelector('.l_left .widgets');
212
+ if (container == null) {
213
+ return;
214
+ }
215
+ const PREFIX = 'Stellar.leftbarScroll.';
216
+ const encode = (s) => encodeURIComponent(String(s || ''));
217
+ function scope() {
218
+ const wikiEl = document.querySelector('.doc-tree[data-wiki]');
219
+ if (wikiEl != null) {
220
+ return 'wiki:' + encode(wikiEl.getAttribute('data-wiki'));
221
+ }
222
+ const notebookEl = document.querySelector('widget[data-notebook]');
223
+ if (notebookEl != null) {
224
+ return 'notebook:' + encode(notebookEl.getAttribute('data-notebook'));
225
+ }
226
+ const body = document.querySelector('.l_body');
227
+ return 'layout:' + encode((body && body.getAttribute('layout')) || 'default');
228
+ }
229
+ window.addEventListener('pagehide', function () {
230
+ try {
231
+ const s = scope();
232
+ sessionStorage.setItem(PREFIX + s, String(container.scrollTop));
233
+ sessionStorage.setItem(PREFIX + 'last', s);
234
+ } catch (e) {}
235
+ });
236
+ try {
237
+ const s = scope();
238
+ // 仅当上一页与当前页属于同一分区时才恢复,离开分区后再回来不跳回旧位置
239
+ if (sessionStorage.getItem(PREFIX + 'last') !== s) {
240
+ return;
241
+ }
242
+ const value = sessionStorage.getItem(PREFIX + s);
243
+ if (value == null) {
244
+ return;
245
+ }
246
+ container.scrollTop = parseInt(value, 10) || 0;
247
+ const link = container.querySelector('a.link.active');
248
+ if (link == null) {
249
+ return;
250
+ }
251
+ const padding = 16;
252
+ const containerRect = container.getBoundingClientRect();
253
+ const linkRect = link.getBoundingClientRect();
254
+ const top = linkRect.top - containerRect.top;
255
+ const bottom = linkRect.bottom - containerRect.top;
256
+ if (top < 0) {
257
+ container.scrollTop += top - padding;
258
+ } else if (bottom > container.clientHeight) {
259
+ container.scrollTop += bottom - container.clientHeight + padding;
260
+ }
261
+ } catch (e) {}
164
262
  },
165
263
  relativeDate: (selector) => {
166
264
  selector.forEach(item => {
@@ -293,29 +391,15 @@ window.stellar = window.stellar || {};
293
391
 
294
392
  /**
295
393
  * Initialize page components
296
- * Called on initial load and after PJAX navigation
297
394
  */
298
395
  stellar.initPage = function () {
299
396
  init.toc();
300
397
  init.sidebar();
398
+ init.leftbarScroll();
301
399
  init.relativeDate(document.querySelectorAll('#post-meta time'));
302
400
  init.registerTabsTag();
303
-
304
- // Reinitialize comments after PJAX navigation
305
- if (stellar.initComments) {
306
- for (const commentSystem in stellar.initComments) {
307
- if (typeof stellar.initComments[commentSystem] === 'function') {
308
- stellar.initComments[commentSystem]();
309
- }
310
- }
311
- }
312
401
  };
313
402
 
314
403
  // Initial page load
315
404
  stellar.initPage();
316
405
  init.canonicalCheck();
317
-
318
- // Listen for PJAX navigation complete
319
- document.addEventListener('pjax:complete', function () {
320
- stellar.initPage();
321
- });
@@ -1,77 +1,77 @@
1
1
  utils.js(window.searchConfig.js).then(() => {
2
- utils.jq(() => {
3
- var $inputArea = $("input#search-input");
4
- if ($inputArea.length === 0) {
5
- return;
6
- }
2
+ var inputArea = document.querySelector("input#search-input");
3
+ if (!inputArea) {
4
+ return;
5
+ }
7
6
 
8
- var $resultArea = $("#search-result");
9
- var $searchWrapper = $("#search-wrapper");
10
- var client = algoliasearch(window.searchConfig.appId, window.searchConfig.apiKey);
11
- var index = client.initIndex(window.searchConfig.indexName);
7
+ var resultArea = document.querySelector("#search-result");
8
+ var searchWrapper = document.querySelector("#search-wrapper");
9
+ var client = algoliasearch(window.searchConfig.appId, window.searchConfig.apiKey);
10
+ var index = client.initIndex(window.searchConfig.indexName);
12
11
 
13
- function filterResults(hits, filterPath) {
14
- if (!filterPath || filterPath === '/') return hits;
15
- var regex = new RegExp(filterPath);
16
- return hits.filter(hit => regex.test(hit.url));
17
- }
12
+ function filterResults(hits, filterPath) {
13
+ if (!filterPath || filterPath === '/') return hits;
14
+ var regex = new RegExp(filterPath);
15
+ return hits.filter(hit => regex.test(hit.url));
16
+ }
18
17
 
19
- function displayResults(hits) {
20
- var $resultList = $("<ul>").addClass("search-result-list");
21
- if (hits.length === 0) {
22
- $searchWrapper.addClass('noresult');
23
- } else {
24
- $searchWrapper.removeClass('noresult');
25
- hits.forEach(function(hit) {
26
- var contentSnippet = hit._snippetResult.content.value;
27
- var title = hit.hierarchy.lvl1 || 'Untitled';
28
- var $item = $("<li>").html(`<a href="${hit.url}"><span class='search-result-title'>${title}</span><p class="search-result-content">${contentSnippet}</p></a>`);
29
- $resultList.append($item);
30
- });
31
- }
32
- $resultArea.html($resultList);
18
+ function displayResults(hits) {
19
+ var resultList = document.createElement("ul");
20
+ resultList.classList.add("search-result-list");
21
+ if (hits.length === 0) {
22
+ searchWrapper.classList.add('noresult');
23
+ } else {
24
+ searchWrapper.classList.remove('noresult');
25
+ hits.forEach(function(hit) {
26
+ var contentSnippet = hit._snippetResult.content.value;
27
+ var title = hit.hierarchy.lvl1 || 'Untitled';
28
+ var item = document.createElement("li");
29
+ item.innerHTML = `<a href="${hit.url}"><span class='search-result-title'>${title}</span><p class="search-result-content">${contentSnippet}</p></a>`;
30
+ resultList.appendChild(item);
31
+ });
33
32
  }
33
+ resultArea.replaceChildren(resultList);
34
+ }
34
35
 
35
- $inputArea.on("input", function() {
36
- var query = $(this).val().trim();
37
- var filterPath = $inputArea.data('filter');
36
+ inputArea.addEventListener("input", function() {
37
+ var query = inputArea.value.trim();
38
+ var filterPath = inputArea.getAttribute('data-filter');
38
39
 
39
- if (query.length <= 0) {
40
- $searchWrapper.attr('searching', 'false');
41
- $resultArea.empty();
42
- return;
43
- }
40
+ if (query.length <= 0) {
41
+ searchWrapper.setAttribute('searching', 'false');
42
+ resultArea.replaceChildren();
43
+ return;
44
+ }
44
45
 
45
- $searchWrapper.attr('searching', 'true');
46
+ searchWrapper.setAttribute('searching', 'true');
46
47
 
47
- index.search(query, {
48
- hitsPerPage: window.searchConfig.hitsPerPage,
49
- attributesToHighlight: ['content'],
50
- attributesToSnippet: ['content:30'],
51
- highlightPreTag: '<span class="search-keyword">',
52
- highlightPostTag: '</span>',
53
- restrictSearchableAttributes: ['content']
54
- }).then(function(responses) {
55
- displayResults(filterResults(responses.hits, filterPath));
56
- });
48
+ index.search(query, {
49
+ hitsPerPage: window.searchConfig.hitsPerPage,
50
+ attributesToHighlight: ['content'],
51
+ attributesToSnippet: ['content:30'],
52
+ highlightPreTag: '<span class="search-keyword">',
53
+ highlightPostTag: '</span>',
54
+ restrictSearchableAttributes: ['content']
55
+ }).then(function(responses) {
56
+ displayResults(filterResults(responses.hits, filterPath));
57
57
  });
58
+ });
58
59
 
59
- $inputArea.on("keydown", function(e) {
60
- if (e.which == 13) {
61
- e.preventDefault();
62
- }
63
- });
60
+ inputArea.addEventListener("keydown", function(e) {
61
+ if (e.key == 'Enter') {
62
+ e.preventDefault();
63
+ }
64
+ });
64
65
 
65
- var observer = new MutationObserver(function(mutationsList) {
66
- if (mutationsList.length === 1) {
67
- if (mutationsList[0].addedNodes.length) {
68
- $searchWrapper.removeClass('noresult');
69
- } else if (mutationsList[0].removedNodes.length) {
70
- $searchWrapper.addClass('noresult');
71
- }
66
+ var observer = new MutationObserver(function(mutationsList) {
67
+ if (mutationsList.length === 1) {
68
+ if (mutationsList[0].addedNodes.length) {
69
+ searchWrapper.classList.remove('noresult');
70
+ } else if (mutationsList[0].removedNodes.length) {
71
+ searchWrapper.classList.add('noresult');
72
72
  }
73
- });
74
-
75
- observer.observe($resultArea[0], { childList: true });
73
+ }
76
74
  });
75
+
76
+ observer.observe(resultArea, { childList: true });
77
77
  });
@@ -130,58 +130,59 @@ var searchFunc = function(path, filter, wrapperId, searchId, contentId) {
130
130
  }
131
131
  };
132
132
 
133
- utils.jq(() => {
134
- (function preloadSearchData() {
135
- var path = ctx.search.path;
136
- if (path.startsWith('/')) {
137
- path = path.substring(1);
138
- }
139
- path = ctx.root + path;
133
+ (function preloadSearchData() {
134
+ var path = ctx.search.path;
135
+ if (path.startsWith('/')) {
136
+ path = path.substring(1);
137
+ }
138
+ path = ctx.root + path;
140
139
 
141
- try {
142
- var cached = localStorage.getItem(searchCacheKey);
143
- if (cached) {
144
- searchCache = JSON.parse(cached);
145
- }
146
- } catch (e) {
147
- console.warn('搜索缓存解析失败', e);
140
+ try {
141
+ var cached = localStorage.getItem(searchCacheKey);
142
+ if (cached) {
143
+ searchCache = JSON.parse(cached);
148
144
  }
145
+ } catch (e) {
146
+ console.warn('搜索缓存解析失败', e);
147
+ }
149
148
 
150
- fetch(path)
151
- .then(res => res.json())
152
- .then(json => {
153
- searchCache = json;
154
- try {
155
- localStorage.setItem(searchCacheKey, JSON.stringify(json));
156
- } catch (e) {
157
- console.warn('搜索缓存写入失败', e);
158
- }
159
- });
160
- })();
149
+ fetch(path)
150
+ .then(res => res.json())
151
+ .then(json => {
152
+ searchCache = json;
153
+ try {
154
+ localStorage.setItem(searchCacheKey, JSON.stringify(json));
155
+ } catch (e) {
156
+ console.warn('搜索缓存写入失败', e);
157
+ }
158
+ });
159
+ })();
161
160
 
162
- var $inputArea = $("input#search-input");
163
- if ($inputArea.length == 0) return;
164
- var $resultArea = document.querySelector("div#search-result");
161
+ (function () {
162
+ var inputArea = document.querySelector("input#search-input");
163
+ if (!inputArea) return;
164
+ var resultArea = document.querySelector("div#search-result");
165
165
 
166
- $inputArea.focus(function() {
166
+ inputArea.addEventListener("focus", function() {
167
167
  var path = ctx.search.path;
168
168
  if (path.startsWith('/')) {
169
169
  path = path.substring(1);
170
170
  }
171
171
  path = ctx.root + path;
172
- const filter = $inputArea.attr('data-filter') || '';
172
+ const filter = inputArea.getAttribute('data-filter') || '';
173
173
  searchFunc(path, filter, 'search-wrapper', 'search-input', 'search-result');
174
174
  });
175
175
 
176
- $inputArea.keydown(function(e) {
177
- if (e.which == 13) {
176
+ inputArea.addEventListener("keydown", function(e) {
177
+ if (e.key == 'Enter') {
178
178
  e.preventDefault();
179
179
  }
180
180
  });
181
181
 
182
182
  const observer = new MutationObserver(function(mutationsList) {
183
- const hasResults = $resultArea.querySelector(".search-result-list li");
184
- $('.search-wrapper').toggleClass('noresult', !hasResults);
183
+ const hasResults = resultArea.querySelector(".search-result-list li");
184
+ const wrapper = document.querySelector('.search-wrapper');
185
+ if (wrapper) wrapper.classList.toggle('noresult', !hasResults);
185
186
  });
186
- observer.observe($resultArea, { childList: true, subtree: true });
187
- });
187
+ observer.observe(resultArea, { childList: true, subtree: true });
188
+ })();
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- const els = document.getElementsByClassName('ds-artalk');
1
+ (function () {
2
+ const els = document.getElementsByClassName('ds-artalk');
4
3
  for (var i = 0; i < els.length; i++) {
5
4
  const el = els[i];
6
5
  const limit = parseInt(el.getAttribute('limit')) || 10;
@@ -25,10 +24,9 @@ utils.jq(() => {
25
24
  cell += item.content_marked;
26
25
  cell += '</a>';
27
26
  cell += '</div>';
28
- $(el).append(cell);
27
+ utils.dom(el).append(cell);
29
28
  });
30
29
  });
31
30
  }
32
- });
33
- });
34
-
31
+ })();
32
+
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- function parseGithubFileContributors(data) {
1
+ (function () {
2
+ function parseGithubFileContributors(data) {
4
3
  // 去重贡献者(按 login)
5
4
  const contributorsMap = new Map();
6
5
 
@@ -47,10 +46,9 @@ utils.jq(() => {
47
46
  cell += `</div>`;
48
47
  cell += `</a>`;
49
48
  cell += `</div>`;
50
- $(el).find('.grid-box').append(cell);
49
+ utils.dom(el).find('.grid-box').append(cell);
51
50
  }
52
51
  window.wrapLazyloadImages(el);
53
52
  });
54
53
  }
55
- });
56
- });
54
+ })();
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- const els = document.getElementsByClassName('ds-fcircle');
1
+ (function () {
2
+ const els = document.getElementsByClassName('ds-fcircle');
4
3
  for (var i = 0; i < els.length; i++) {
5
4
  const el = els[i];
6
5
  const api = el.dataset.api;
@@ -29,9 +28,8 @@ utils.jq(() => {
29
28
  cell += item.title;
30
29
  cell += '</a>';
31
30
  cell += '</div>';
32
- $(el).append(cell);
31
+ utils.dom(el).append(cell);
33
32
  });
34
33
  });
35
34
  }
36
- });
37
- });
35
+ })();
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- const els = document.getElementsByClassName('ds-friends');
1
+ (function () {
2
+ const els = document.getElementsByClassName('ds-friends');
4
3
  for (var i = 0; i < els.length; i++) {
5
4
  const el = els[i];
6
5
  const api = el.dataset.api;
@@ -24,10 +23,9 @@ utils.jq(() => {
24
23
  }
25
24
  cell += `</a>`;
26
25
  cell += `</div>`;
27
- $(el).find('.grid-box').append(cell);
26
+ utils.dom(el).find('.grid-box').append(cell);
28
27
  }
29
28
  window.wrapLazyloadImages(el);
30
29
  });
31
30
  }
32
- });
33
- });
31
+ })();
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- const els = document.getElementsByClassName('ds-friends_and_posts');
1
+ (function () {
2
+ const els = document.getElementsByClassName('ds-friends_and_posts');
4
3
  for (var i = 0; i < els.length; i++) {
5
4
  const el = els[i];
6
5
  const api = el.dataset.api;
@@ -50,10 +49,9 @@ utils.jq(() => {
50
49
  cell += `</div>`;
51
50
  cell += `</div>`;
52
51
  cell += `</div>`;
53
- $(el).find('.grid-box').append(cell);
52
+ utils.dom(el).find('.grid-box').append(cell);
54
53
  }
55
54
  window.wrapLazyloadImages(el);
56
55
  });
57
56
  }
58
- });
59
- });
57
+ })();
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- const els = document.getElementsByClassName('ds-ghinfo');
1
+ (function () {
2
+ const els = document.getElementsByClassName('ds-ghinfo');
4
3
  for (var i = 0; i < els.length; i++) {
5
4
  const el = els[i];
6
5
  const api = el.dataset.api;
@@ -12,9 +11,9 @@ utils.jq(() => {
12
11
  const data = await resp.json();
13
12
  function fill(data) {
14
13
  for (let key of Object.keys(data)) {
15
- $(el).find("[type=text]#" + key).text(data[key]);
16
- $(el).find("[type=link]#" + key).attr("href", data[key]);
17
- $(el).find("[type=img]#" + key).attr("src", data[key]);
14
+ utils.dom(el).find("[type=text]#" + key).text(data[key]);
15
+ utils.dom(el).find("[type=link]#" + key).attr("href", data[key]);
16
+ utils.dom(el).find("[type=img]#" + key).attr("src", data[key]);
18
17
  }
19
18
  }
20
19
  const idx = el.getAttribute('index');
@@ -30,5 +29,4 @@ utils.jq(() => {
30
29
  }
31
30
  });
32
31
  }
33
- });
34
- });
32
+ })();