Skip to content

Commit

Permalink
remove extract reading implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
khaitruong922 committed Oct 18, 2024
1 parent 051a2f0 commit 521cb1e
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions ext/js/display/structured-content-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,10 @@ export class StructuredContentGenerator {
_createLinkElement(content, dictionary, language) {
let {href} = content;
const internal = href.startsWith('?');
if (internal) {
href = `${location.protocol}//${location.host}/search.html${href.length > 1 ? href : ''}`;
}

const node = /** @type {HTMLAnchorElement} */ (this._createElement('a', 'gloss-link'));
node.dataset.external = `${!internal}`;

Expand All @@ -456,30 +460,6 @@ export class StructuredContentGenerator {
node.appendChild(icon);
}

if (internal) {
let query = '';
if (href.length > 1) {
let hasFurigana = false;
let reading = '';
for (const childNode of text.childNodes) {
if (childNode instanceof HTMLElement) {
const furigana = childNode.querySelector('.gloss-sc-rt')?.textContent;
if (furigana && furigana.length > 0) {
reading += furigana;
hasFurigana = true;
}
} else {
reading += childNode.textContent ?? '';
}
}
query = href;
if (reading.length > 0 && hasFurigana) {
query += `&primary_reading=${reading}`;
}
}
href = `${location.protocol}//${location.host}/search.html${query}`;
}

this._contentManager.prepareLink(node, href, internal);
return node;
}
Expand Down

0 comments on commit 521cb1e

Please sign in to comment.