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