+17
-14
post_component.js
+17
-14
post_component.js
···
171
171
}
172
172
173
173
if (this.post.originalFediURL) {
174
-
wrapper.appendChild(this.buildFediSourceLink());
174
+
let link = this.buildFediSourceLink(this.post.originalFediURL);
175
+
if (link) {
176
+
wrapper.appendChild(link);
177
+
}
175
178
}
176
179
177
180
if (this.post.likeCount !== undefined && this.post.repostCount !== undefined) {
···
316
319
highlightSearchResults(terms) {
317
320
let regexp = new RegExp(`\\b(${terms.join('|')})\\b`, 'gi');
318
321
319
-
let body = this._rootElement.querySelector(':scope > .content > .body, :scope > .content > details .body');
322
+
let root = this.rootElement;
323
+
let body = $(root.querySelector(':scope > .content > .body, :scope > .content > details .body'));
320
324
let walker = document.createTreeWalker(body, NodeFilter.SHOW_TEXT);
321
325
let textNodes = [];
322
326
···
325
329
}
326
330
327
331
for (let node of textNodes) {
332
+
if (!node.textContent) { continue; }
333
+
328
334
let markedText = document.createDocumentFragment();
329
335
let currentPosition = 0;
330
336
···
348
354
markedText.appendChild(document.createTextNode(remainingText));
349
355
}
350
356
351
-
node.parentNode.replaceChild(markedText, node);
357
+
$(node.parentNode).replaceChild(markedText, node);
352
358
}
353
359
}
354
360
···
486
492
this.loadHiddenSubtree(this.post, this.rootElement);
487
493
}
488
494
489
-
/** @returns {HTMLElement | undefined} */
495
+
/** @param {string} url, @returns {HTMLElement | undefined} */
490
496
491
-
buildFediSourceLink() {
492
-
let url = this.post.originalFediURL;
493
-
let hostname;
497
+
buildFediSourceLink(url) {
498
+
try {
499
+
let hostname = new URL(url).hostname;
500
+
let a = $tag('a.fedi-link', { href: url, target: '_blank' });
494
501
495
-
try {
496
-
hostname = new URL(url).hostname;
502
+
let box = $tag('div', { html: `<i class="fa-solid fa-arrow-up-right-from-square fa-sm"></i> View on ${hostname}` });
503
+
a.append(box);
504
+
return a;
497
505
} catch (error) {
498
506
console.log("Invalid Fedi URL:" + error);
499
507
return undefined;
500
508
}
501
-
502
-
let a = $tag('a.fedi-link', { href: url, target: '_blank' });
503
-
let box = $tag('div', { html: `<i class="fa-solid fa-arrow-up-right-from-square fa-sm"></i> View on ${hostname}` });
504
-
a.append(box);
505
-
return a;
506
509
}
507
510
508
511
/** @param {HTMLLinkElement} authorLink */
+10
-7
private_search_page.js
+10
-7
private_search_page.js
···
16
16
this.searchForm = $(this.pageElement.querySelector('.search-form'), HTMLFormElement);
17
17
this.results = $(this.pageElement.querySelector('.results'));
18
18
19
+
this.timelineSearch = $(this.pageElement.querySelector('.timeline-search'));
20
+
this.searchCollections = $(this.pageElement.querySelector('.search-collections'));
21
+
19
22
this.timelinePosts = [];
20
23
21
24
this.setupEvents();
···
25
28
this.lycanMode = params.get('lycan');
26
29
27
30
if (this.lycanMode == 'local') {
28
-
this.lycan = new BlueskyAPI('http://localhost:3000', false);
31
+
this.localLycan = new BlueskyAPI('http://localhost:3000', false);
29
32
}
30
33
}
31
34
···
71
74
this.pageElement.style.display = 'block';
72
75
73
76
if (this.mode == 'likes') {
74
-
this.pageElement.querySelector('.timeline-search').style.display = 'none';
75
-
this.pageElement.querySelector('.search-collections').style.display = 'block';
77
+
this.timelineSearch.style.display = 'none';
78
+
this.searchCollections.style.display = 'block';
76
79
this.searchLine.style.display = 'block';
77
80
} else {
78
-
this.pageElement.querySelector('.timeline-search').style.display = 'block';
79
-
this.pageElement.querySelector('.search-collections').style.display = 'none';
81
+
this.timelineSearch.style.display = 'block';
82
+
this.searchCollections.style.display = 'none';
80
83
}
81
84
}
82
85
···
170
173
171
174
let response;
172
175
173
-
if (this.lycanMode == 'local') {
176
+
if (this.localLycan) {
174
177
let params = { collection, query, user: window.accountAPI.user.did };
175
178
if (cursor) params.cursor = cursor;
176
179
177
-
response = await this.lycan.getRequest('blue.feeds.lycan.searchPosts', params);
180
+
response = await this.localLycan.getRequest('blue.feeds.lycan.searchPosts', params);
178
181
} else {
179
182
let params = { collection, query };
180
183
if (cursor) params.cursor = cursor;
+2
types.d.ts
+2
types.d.ts
+7
-2
utils.js
+7
-2
utils.js
···
17
17
}
18
18
}
19
19
20
-
window.Paginator = {
21
-
/** @param {Function} callback */
20
+
/**
21
+
* @typedef {object} PaginatorType
22
+
* @property {(callback: (boolean) => void) => void} loadInPages
23
+
* @property {(() => void)=} scrollHandler
24
+
* @property {ResizeObserver=} resizeObserver
25
+
*/
22
26
27
+
window.Paginator = {
23
28
loadInPages(callback) {
24
29
if (this.scrollHandler) {
25
30
document.removeEventListener('scroll', this.scrollHandler);