2019-12-25 02:45:57 +00:00
|
|
|
/*
|
2021-01-01 19:50:41 +00:00
|
|
|
* Copyright (C) 2019-2021 Yomichan Authors
|
2019-12-25 02:45:57 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-02-26 01:21:05 +00:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2019-12-25 02:45:57 +00:00
|
|
|
*/
|
|
|
|
|
2020-03-11 02:30:36 +00:00
|
|
|
/* global
|
2020-07-31 00:45:52 +00:00
|
|
|
* DictionaryDataUtil
|
2020-10-08 00:47:44 +00:00
|
|
|
* HtmlTemplateCollection
|
2020-03-11 02:30:36 +00:00
|
|
|
*/
|
2019-12-25 02:45:57 +00:00
|
|
|
|
|
|
|
class DisplayGenerator {
|
2021-01-20 01:48:10 +00:00
|
|
|
constructor({japaneseUtil, mediaLoader, hotkeyHelpController=null}) {
|
2020-11-29 18:09:02 +00:00
|
|
|
this._japaneseUtil = japaneseUtil;
|
2020-04-11 18:23:49 +00:00
|
|
|
this._mediaLoader = mediaLoader;
|
2021-01-18 20:23:49 +00:00
|
|
|
this._hotkeyHelpController = hotkeyHelpController;
|
2020-10-08 00:47:44 +00:00
|
|
|
this._templates = null;
|
2020-03-01 19:20:11 +00:00
|
|
|
this._termPitchAccentStaticTemplateIsSetup = false;
|
2019-12-27 23:58:11 +00:00
|
|
|
}
|
|
|
|
|
2020-02-12 23:43:01 +00:00
|
|
|
async prepare() {
|
2021-02-14 20:53:35 +00:00
|
|
|
const html = await yomichan.api.getDisplayTemplatesHtml();
|
2020-10-08 00:47:44 +00:00
|
|
|
this._templates = new HtmlTemplateCollection(html);
|
2021-01-18 20:23:49 +00:00
|
|
|
this.updateHotkeys();
|
|
|
|
}
|
|
|
|
|
|
|
|
updateHotkeys() {
|
|
|
|
const hotkeyHelpController = this._hotkeyHelpController;
|
2021-01-20 01:48:10 +00:00
|
|
|
if (hotkeyHelpController === null) { return; }
|
2021-01-18 20:23:49 +00:00
|
|
|
for (const template of this._templates.getAllTemplates()) {
|
|
|
|
hotkeyHelpController.setupNode(template.content);
|
|
|
|
}
|
2019-12-25 02:45:57 +00:00
|
|
|
}
|
|
|
|
|
2020-11-04 03:30:20 +00:00
|
|
|
preparePitchAccents() {
|
|
|
|
if (this._termPitchAccentStaticTemplateIsSetup) { return; }
|
|
|
|
this._termPitchAccentStaticTemplateIsSetup = true;
|
|
|
|
const t = this._templates.instantiate('term-pitch-accent-static');
|
|
|
|
document.head.appendChild(t);
|
|
|
|
}
|
|
|
|
|
2019-12-25 02:45:57 +00:00
|
|
|
createTermEntry(details) {
|
2020-10-08 00:47:44 +00:00
|
|
|
const node = this._templates.instantiate('term-entry');
|
2019-12-25 02:45:57 +00:00
|
|
|
|
|
|
|
const expressionsContainer = node.querySelector('.term-expression-list');
|
2020-01-19 01:04:45 +00:00
|
|
|
const reasonsContainer = node.querySelector('.term-reasons');
|
2020-03-01 19:15:28 +00:00
|
|
|
const pitchesContainer = node.querySelector('.term-pitch-accent-group-list');
|
2021-01-09 15:41:17 +00:00
|
|
|
const frequencyGroupListContainer = node.querySelector('.frequency-group-list');
|
2019-12-25 02:45:57 +00:00
|
|
|
const definitionsContainer = node.querySelector('.term-definition-list');
|
2021-01-09 21:02:03 +00:00
|
|
|
const termTagsContainer = node.querySelector('.term-tags');
|
2020-03-01 19:15:28 +00:00
|
|
|
|
2020-11-14 18:42:50 +00:00
|
|
|
const {expressions, type, reasons, frequencies} = details;
|
2020-11-14 00:48:22 +00:00
|
|
|
const definitions = (type === 'term' ? [details] : details.definitions);
|
|
|
|
const merged = (type === 'termMerged' || type === 'termMergedByGlossary');
|
2020-07-31 00:45:52 +00:00
|
|
|
const pitches = DictionaryDataUtil.getPitchAccentInfos(details);
|
|
|
|
const pitchCount = pitches.reduce((i, v) => i + v.pitches.length, 0);
|
2021-01-09 15:41:17 +00:00
|
|
|
const groupedFrequencies = DictionaryDataUtil.groupTermFrequencies(frequencies);
|
2021-01-09 21:02:03 +00:00
|
|
|
const termTags = DictionaryDataUtil.groupTermTags(details);
|
2019-12-25 02:45:57 +00:00
|
|
|
|
2020-11-24 16:56:40 +00:00
|
|
|
const uniqueExpressions = new Set();
|
|
|
|
const uniqueReadings = new Set();
|
2021-02-17 02:19:52 +00:00
|
|
|
for (let {expression, reading} of expressions) {
|
|
|
|
if (reading.length === 0) { reading = expression; }
|
2020-11-24 16:56:40 +00:00
|
|
|
uniqueExpressions.add(expression);
|
|
|
|
uniqueReadings.add(reading);
|
|
|
|
}
|
|
|
|
|
2020-11-14 00:48:22 +00:00
|
|
|
node.dataset.format = type;
|
|
|
|
node.dataset.expressionMulti = `${merged}`;
|
|
|
|
node.dataset.expressionCount = `${expressions.length}`;
|
|
|
|
node.dataset.definitionCount = `${definitions.length}`;
|
2020-03-01 19:15:28 +00:00
|
|
|
node.dataset.pitchAccentDictionaryCount = `${pitches.length}`;
|
|
|
|
node.dataset.pitchAccentCount = `${pitchCount}`;
|
2020-11-24 16:56:40 +00:00
|
|
|
node.dataset.uniqueExpressionCount = `${uniqueExpressions.size}`;
|
|
|
|
node.dataset.uniqueReadingCount = `${uniqueReadings.size}`;
|
2021-01-09 15:41:17 +00:00
|
|
|
node.dataset.frequencyCount = `${frequencies.length}`;
|
|
|
|
node.dataset.groupedFrequencyCount = `${groupedFrequencies.length}`;
|
2019-12-25 02:45:57 +00:00
|
|
|
|
2020-11-14 18:42:50 +00:00
|
|
|
this._appendMultiple(expressionsContainer, this._createTermExpression.bind(this), expressions);
|
2020-11-14 00:48:22 +00:00
|
|
|
this._appendMultiple(reasonsContainer, this._createTermReason.bind(this), reasons);
|
2021-01-09 15:41:17 +00:00
|
|
|
this._appendMultiple(frequencyGroupListContainer, this._createFrequencyGroup.bind(this), groupedFrequencies, false);
|
2020-04-10 02:02:17 +00:00
|
|
|
this._appendMultiple(pitchesContainer, this._createPitches.bind(this), pitches);
|
2021-01-09 21:02:03 +00:00
|
|
|
this._appendMultiple(termTagsContainer, this._createTermTag.bind(this), termTags, expressions.length);
|
2019-12-25 02:45:57 +00:00
|
|
|
|
2021-02-17 02:19:52 +00:00
|
|
|
for (const expression of uniqueExpressions) {
|
|
|
|
termTagsContainer.appendChild(this._createSearchTag(expression));
|
|
|
|
}
|
|
|
|
for (const reading of uniqueReadings) {
|
|
|
|
if (uniqueExpressions.has(reading)) { continue; }
|
|
|
|
termTagsContainer.appendChild(this._createSearchTag(reading));
|
|
|
|
}
|
|
|
|
|
2021-01-29 02:33:30 +00:00
|
|
|
// Add definitions
|
|
|
|
const dictionaryTag = this._createDictionaryTag(null);
|
|
|
|
for (let i = 0, ii = definitions.length; i < ii; ++i) {
|
|
|
|
const definition = definitions[i];
|
|
|
|
const {dictionary} = definition;
|
|
|
|
|
|
|
|
if (dictionaryTag.dictionary === dictionary) {
|
|
|
|
dictionaryTag.redundant = true;
|
|
|
|
} else {
|
|
|
|
dictionaryTag.redundant = false;
|
|
|
|
dictionaryTag.dictionary = dictionary;
|
|
|
|
dictionaryTag.name = dictionary;
|
|
|
|
}
|
|
|
|
|
|
|
|
const node2 = this._createTermDefinitionItem(definition, dictionaryTag);
|
|
|
|
node2.dataset.index = `${i}`;
|
|
|
|
definitionsContainer.appendChild(node2);
|
|
|
|
}
|
|
|
|
definitionsContainer.dataset.count = `${definitions.length}`;
|
|
|
|
|
2019-12-25 02:45:57 +00:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2020-04-10 02:03:16 +00:00
|
|
|
createKanjiEntry(details) {
|
2020-10-08 00:47:44 +00:00
|
|
|
const node = this._templates.instantiate('kanji-entry');
|
2020-04-10 02:03:16 +00:00
|
|
|
|
|
|
|
const glyphContainer = node.querySelector('.kanji-glyph');
|
2021-01-09 15:41:17 +00:00
|
|
|
const frequencyGroupListContainer = node.querySelector('.frequency-group-list');
|
2020-04-10 02:03:16 +00:00
|
|
|
const tagContainer = node.querySelector('.tags');
|
|
|
|
const glossaryContainer = node.querySelector('.kanji-glossary-list');
|
|
|
|
const chineseReadingsContainer = node.querySelector('.kanji-readings-chinese');
|
|
|
|
const japaneseReadingsContainer = node.querySelector('.kanji-readings-japanese');
|
|
|
|
const statisticsContainer = node.querySelector('.kanji-statistics');
|
|
|
|
const classificationsContainer = node.querySelector('.kanji-classifications');
|
|
|
|
const codepointsContainer = node.querySelector('.kanji-codepoints');
|
|
|
|
const dictionaryIndicesContainer = node.querySelector('.kanji-dictionary-indices');
|
|
|
|
|
2021-02-08 22:52:35 +00:00
|
|
|
this._setTextContent(glyphContainer, details.character, 'ja');
|
2021-01-09 15:41:17 +00:00
|
|
|
const groupedFrequencies = DictionaryDataUtil.groupKanjiFrequencies(details.frequencies);
|
2020-01-29 00:06:50 +00:00
|
|
|
|
2021-01-29 02:33:30 +00:00
|
|
|
const dictionaryTag = this._createDictionaryTag(details.dictionary);
|
|
|
|
|
2021-01-09 15:41:17 +00:00
|
|
|
this._appendMultiple(frequencyGroupListContainer, this._createFrequencyGroup.bind(this), groupedFrequencies, true);
|
2021-01-29 02:33:30 +00:00
|
|
|
this._appendMultiple(tagContainer, this._createTag.bind(this), [...details.tags, dictionaryTag]);
|
2020-04-10 02:03:16 +00:00
|
|
|
this._appendMultiple(glossaryContainer, this._createKanjiGlossaryItem.bind(this), details.glossary);
|
|
|
|
this._appendMultiple(chineseReadingsContainer, this._createKanjiReading.bind(this), details.onyomi);
|
|
|
|
this._appendMultiple(japaneseReadingsContainer, this._createKanjiReading.bind(this), details.kunyomi);
|
|
|
|
|
2020-11-14 18:42:50 +00:00
|
|
|
statisticsContainer.appendChild(this._createKanjiInfoTable(details.stats.misc));
|
|
|
|
classificationsContainer.appendChild(this._createKanjiInfoTable(details.stats.class));
|
|
|
|
codepointsContainer.appendChild(this._createKanjiInfoTable(details.stats.code));
|
|
|
|
dictionaryIndicesContainer.appendChild(this._createKanjiInfoTable(details.stats.index));
|
2019-12-25 02:45:57 +00:00
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2020-12-18 14:43:54 +00:00
|
|
|
createEmptyFooterNotification() {
|
|
|
|
return this._templates.instantiate('footer-notification');
|
|
|
|
}
|
|
|
|
|
2021-01-09 21:02:03 +00:00
|
|
|
createTagFooterNotificationDetails(tagNode) {
|
|
|
|
const node = this._templates.instantiateFragment('footer-notification-tag-details');
|
|
|
|
|
|
|
|
const details = tagNode.dataset.details;
|
2021-02-08 22:52:35 +00:00
|
|
|
this._setTextContent(node.querySelector('.tag-details'), details);
|
2021-01-09 21:02:03 +00:00
|
|
|
|
|
|
|
let disambiguation = null;
|
|
|
|
try {
|
|
|
|
let a = tagNode.dataset.disambiguation;
|
|
|
|
if (typeof a !== 'undefined') {
|
|
|
|
a = JSON.parse(a);
|
|
|
|
if (Array.isArray(a)) { disambiguation = a; }
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
// NOP
|
|
|
|
}
|
|
|
|
|
|
|
|
if (disambiguation !== null) {
|
|
|
|
const disambiguationContainer = node.querySelector('.tag-details-disambiguation-list');
|
|
|
|
const copyAttributes = ['totalExpressionCount', 'matchedExpressionCount', 'unmatchedExpressionCount'];
|
|
|
|
for (const attribute of copyAttributes) {
|
|
|
|
const value = tagNode.dataset[attribute];
|
|
|
|
if (typeof value === 'undefined') { continue; }
|
|
|
|
disambiguationContainer.dataset[attribute] = value;
|
|
|
|
}
|
|
|
|
for (const {expression, reading} of disambiguation) {
|
|
|
|
const segments = this._japaneseUtil.distributeFurigana(expression, reading);
|
|
|
|
const disambiguationItem = document.createElement('span');
|
|
|
|
disambiguationItem.className = 'tag-details-disambiguation';
|
2021-02-08 22:52:35 +00:00
|
|
|
disambiguationItem.lang = 'ja';
|
2021-01-09 21:02:03 +00:00
|
|
|
this._appendFurigana(disambiguationItem, segments, (container, text) => {
|
|
|
|
container.appendChild(document.createTextNode(text));
|
|
|
|
});
|
|
|
|
disambiguationContainer.appendChild(disambiguationItem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2021-01-30 17:33:29 +00:00
|
|
|
createAnkiNoteErrorsNotificationContent(errors) {
|
|
|
|
const content = this._templates.instantiate('footer-notification-anki-errors-content');
|
|
|
|
|
|
|
|
const header = content.querySelector('.anki-note-error-header');
|
2021-02-08 22:52:35 +00:00
|
|
|
this._setTextContent(header, (errors.length === 1 ? 'An error occurred:' : `${errors.length} errors occurred:`), 'en');
|
2021-01-30 17:33:29 +00:00
|
|
|
|
|
|
|
const list = content.querySelector('.anki-note-error-list');
|
|
|
|
for (const error of errors) {
|
|
|
|
const div = document.createElement('li');
|
|
|
|
div.className = 'anki-note-error-message';
|
2021-02-08 22:52:35 +00:00
|
|
|
this._setTextContent(div, isObject(error) && typeof error.message === 'string' ? error.message : `${error}`);
|
2021-01-30 17:33:29 +00:00
|
|
|
list.appendChild(div);
|
|
|
|
}
|
|
|
|
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
|
2020-12-30 04:38:44 +00:00
|
|
|
createProfileListItem() {
|
|
|
|
return this._templates.instantiate('profile-list-item');
|
|
|
|
}
|
|
|
|
|
2021-02-15 19:31:16 +00:00
|
|
|
instantiateTemplate(name) {
|
|
|
|
return this._templates.instantiate(name);
|
2021-01-24 02:13:01 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 02:03:16 +00:00
|
|
|
// Private
|
|
|
|
|
2020-11-14 18:42:50 +00:00
|
|
|
_createTermExpression(details) {
|
2021-01-09 15:41:17 +00:00
|
|
|
const {termFrequency, furiganaSegments, expression, reading, termTags} = details;
|
2020-11-14 18:42:50 +00:00
|
|
|
|
|
|
|
const searchQueries = [];
|
|
|
|
if (expression) { searchQueries.push(expression); }
|
|
|
|
if (reading) { searchQueries.push(reading); }
|
|
|
|
|
2020-10-08 00:47:44 +00:00
|
|
|
const node = this._templates.instantiate('term-expression');
|
2019-12-25 02:45:57 +00:00
|
|
|
|
|
|
|
const expressionContainer = node.querySelector('.term-expression-text');
|
|
|
|
const tagContainer = node.querySelector('.tags');
|
|
|
|
|
2020-11-14 18:42:50 +00:00
|
|
|
node.dataset.readingIsSame = `${!reading || reading === expression}`;
|
|
|
|
node.dataset.frequency = termFrequency;
|
2019-12-25 02:45:57 +00:00
|
|
|
|
2021-02-27 19:04:52 +00:00
|
|
|
this._setTextContent(node.querySelector('.term-expression-reading'), reading.length > 0 ? reading : expression);
|
2021-02-08 22:52:35 +00:00
|
|
|
|
2020-11-14 18:42:50 +00:00
|
|
|
this._appendFurigana(expressionContainer, furiganaSegments, this._appendKanjiLinks.bind(this));
|
2020-04-10 02:02:17 +00:00
|
|
|
this._appendMultiple(tagContainer, this._createTag.bind(this), termTags);
|
|
|
|
this._appendMultiple(tagContainer, this._createSearchTag.bind(this), searchQueries);
|
2019-12-25 02:45:57 +00:00
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2020-04-10 02:02:17 +00:00
|
|
|
_createTermReason(reason) {
|
2020-10-08 00:47:44 +00:00
|
|
|
const fragment = this._templates.instantiateFragment('term-reason');
|
2020-01-30 01:47:24 +00:00
|
|
|
const node = fragment.querySelector('.term-reason');
|
2021-02-08 22:52:35 +00:00
|
|
|
this._setTextContent(node, reason);
|
2019-12-25 02:45:57 +00:00
|
|
|
node.dataset.reason = reason;
|
2020-01-30 01:47:24 +00:00
|
|
|
return fragment;
|
2019-12-25 02:45:57 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 02:33:30 +00:00
|
|
|
_createTermDefinitionItem(details, dictionaryTag) {
|
2020-10-08 00:47:44 +00:00
|
|
|
const node = this._templates.instantiate('term-definition-item');
|
2019-12-25 02:45:57 +00:00
|
|
|
|
|
|
|
const tagListContainer = node.querySelector('.term-definition-tag-list');
|
2020-04-10 02:19:58 +00:00
|
|
|
const onlyListContainer = node.querySelector('.term-definition-disambiguation-list');
|
2019-12-25 02:45:57 +00:00
|
|
|
const glossaryContainer = node.querySelector('.term-glossary-list');
|
|
|
|
|
2021-01-29 02:33:30 +00:00
|
|
|
const {dictionary, definitionTags} = details;
|
2020-04-11 18:23:49 +00:00
|
|
|
node.dataset.dictionary = dictionary;
|
2019-12-25 02:45:57 +00:00
|
|
|
|
2021-01-29 02:33:30 +00:00
|
|
|
this._appendMultiple(tagListContainer, this._createTag.bind(this), [...definitionTags, dictionaryTag]);
|
2020-04-10 02:19:58 +00:00
|
|
|
this._appendMultiple(onlyListContainer, this._createTermDisambiguation.bind(this), details.only);
|
2020-04-11 18:23:49 +00:00
|
|
|
this._appendMultiple(glossaryContainer, this._createTermGlossaryItem.bind(this), details.glossary, dictionary);
|
2019-12-25 02:45:57 +00:00
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2020-04-11 18:23:49 +00:00
|
|
|
_createTermGlossaryItem(glossary, dictionary) {
|
|
|
|
if (typeof glossary === 'string') {
|
|
|
|
return this._createTermGlossaryItemText(glossary);
|
|
|
|
} else if (typeof glossary === 'object' && glossary !== null) {
|
|
|
|
switch (glossary.type) {
|
|
|
|
case 'image':
|
|
|
|
return this._createTermGlossaryItemImage(glossary, dictionary);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
_createTermGlossaryItemText(glossary) {
|
2020-10-08 00:47:44 +00:00
|
|
|
const node = this._templates.instantiate('term-glossary-item');
|
2019-12-25 02:45:57 +00:00
|
|
|
const container = node.querySelector('.term-glossary');
|
2021-02-08 22:52:35 +00:00
|
|
|
this._setTextContent(container, glossary);
|
2019-12-25 02:45:57 +00:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2020-04-11 18:23:49 +00:00
|
|
|
_createTermGlossaryItemImage(data, dictionary) {
|
|
|
|
const {path, width, height, preferredWidth, preferredHeight, title, description, pixelated} = data;
|
|
|
|
|
|
|
|
const usedWidth = (
|
|
|
|
typeof preferredWidth === 'number' ?
|
|
|
|
preferredWidth :
|
|
|
|
width
|
|
|
|
);
|
|
|
|
const aspectRatio = (
|
|
|
|
typeof preferredWidth === 'number' &&
|
|
|
|
typeof preferredHeight === 'number' ?
|
|
|
|
preferredWidth / preferredHeight :
|
|
|
|
width / height
|
|
|
|
);
|
|
|
|
|
2020-10-08 00:47:44 +00:00
|
|
|
const node = this._templates.instantiate('term-glossary-item-image');
|
2020-04-11 18:23:49 +00:00
|
|
|
node.dataset.path = path;
|
|
|
|
node.dataset.dictionary = dictionary;
|
|
|
|
node.dataset.imageLoadState = 'not-loaded';
|
|
|
|
|
|
|
|
const imageContainer = node.querySelector('.term-glossary-image-container');
|
|
|
|
imageContainer.style.width = `${usedWidth}em`;
|
|
|
|
if (typeof title === 'string') {
|
|
|
|
imageContainer.title = title;
|
|
|
|
}
|
|
|
|
|
|
|
|
const aspectRatioSizer = node.querySelector('.term-glossary-image-aspect-ratio-sizer');
|
|
|
|
aspectRatioSizer.style.paddingTop = `${aspectRatio * 100.0}%`;
|
|
|
|
|
|
|
|
const image = node.querySelector('img.term-glossary-image');
|
|
|
|
const imageLink = node.querySelector('.term-glossary-image-link');
|
|
|
|
image.dataset.pixelated = `${pixelated === true}`;
|
|
|
|
|
|
|
|
if (this._mediaLoader !== null) {
|
|
|
|
this._mediaLoader.loadMedia(
|
|
|
|
path,
|
|
|
|
dictionary,
|
|
|
|
(url) => this._setImageData(node, image, imageLink, url, false),
|
|
|
|
() => this._setImageData(node, image, imageLink, null, true)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof description === 'string') {
|
|
|
|
const container = node.querySelector('.term-glossary-image-description');
|
2021-02-08 22:52:35 +00:00
|
|
|
this._setTextContent(container, description);
|
2020-04-11 18:23:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
_setImageData(container, image, imageLink, url, unloaded) {
|
|
|
|
if (url !== null) {
|
|
|
|
image.src = url;
|
|
|
|
imageLink.href = url;
|
|
|
|
container.dataset.imageLoadState = 'loaded';
|
|
|
|
} else {
|
|
|
|
image.removeAttribute('src');
|
|
|
|
imageLink.removeAttribute('href');
|
|
|
|
container.dataset.imageLoadState = unloaded ? 'unloaded' : 'load-error';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-10 02:19:58 +00:00
|
|
|
_createTermDisambiguation(disambiguation) {
|
2020-10-08 00:47:44 +00:00
|
|
|
const node = this._templates.instantiate('term-definition-disambiguation');
|
2020-04-10 02:19:58 +00:00
|
|
|
node.dataset.term = disambiguation;
|
2021-02-08 22:52:35 +00:00
|
|
|
this._setTextContent(node, disambiguation, 'ja');
|
2019-12-25 02:45:57 +00:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2020-04-10 02:02:17 +00:00
|
|
|
_createKanjiLink(character) {
|
2019-12-25 02:45:57 +00:00
|
|
|
const node = document.createElement('a');
|
|
|
|
node.className = 'kanji-link';
|
2021-02-08 22:52:35 +00:00
|
|
|
this._setTextContent(node, character, 'ja');
|
2019-12-25 02:45:57 +00:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2020-04-10 02:02:17 +00:00
|
|
|
_createKanjiGlossaryItem(glossary) {
|
2020-10-08 00:47:44 +00:00
|
|
|
const node = this._templates.instantiate('kanji-glossary-item');
|
2019-12-25 02:45:57 +00:00
|
|
|
const container = node.querySelector('.kanji-glossary');
|
2021-02-08 22:52:35 +00:00
|
|
|
this._setTextContent(container, glossary);
|
2019-12-25 02:45:57 +00:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2020-04-10 02:02:17 +00:00
|
|
|
_createKanjiReading(reading) {
|
2020-10-08 00:47:44 +00:00
|
|
|
const node = this._templates.instantiate('kanji-reading');
|
2021-02-08 22:52:35 +00:00
|
|
|
this._setTextContent(node, reading, 'ja');
|
2019-12-25 02:45:57 +00:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2020-04-10 02:02:17 +00:00
|
|
|
_createKanjiInfoTable(details) {
|
2020-10-08 00:47:44 +00:00
|
|
|
const node = this._templates.instantiate('kanji-info-table');
|
2019-12-25 02:45:57 +00:00
|
|
|
const container = node.querySelector('.kanji-info-table-body');
|
|
|
|
|
2020-11-14 18:42:50 +00:00
|
|
|
const count = this._appendMultiple(container, this._createKanjiInfoTableItem.bind(this), details);
|
|
|
|
if (count === 0) {
|
|
|
|
const n = this._createKanjiInfoTableItemEmpty();
|
|
|
|
container.appendChild(n);
|
2019-12-25 02:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2020-04-10 02:02:17 +00:00
|
|
|
_createKanjiInfoTableItem(details) {
|
2020-10-08 00:47:44 +00:00
|
|
|
const node = this._templates.instantiate('kanji-info-table-item');
|
2019-12-25 02:45:57 +00:00
|
|
|
const nameNode = node.querySelector('.kanji-info-table-item-header');
|
|
|
|
const valueNode = node.querySelector('.kanji-info-table-item-value');
|
2021-02-08 22:52:35 +00:00
|
|
|
this._setTextContent(nameNode, details.notes || details.name);
|
|
|
|
this._setTextContent(valueNode, details.value);
|
2019-12-25 02:45:57 +00:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2020-04-10 02:02:17 +00:00
|
|
|
_createKanjiInfoTableItemEmpty() {
|
2020-10-08 00:47:44 +00:00
|
|
|
return this._templates.instantiate('kanji-info-table-empty');
|
2019-12-25 02:45:57 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 02:02:17 +00:00
|
|
|
_createTag(details) {
|
2021-02-21 18:57:28 +00:00
|
|
|
const {notes, name, category, redundant} = details;
|
2020-10-08 00:47:44 +00:00
|
|
|
const node = this._templates.instantiate('tag');
|
2019-12-25 02:45:57 +00:00
|
|
|
|
2021-02-21 18:57:28 +00:00
|
|
|
const inner = node.querySelector('.tag-label-content');
|
2020-01-30 00:52:24 +00:00
|
|
|
|
2021-02-21 18:57:28 +00:00
|
|
|
node.title = notes;
|
|
|
|
this._setTextContent(inner, name);
|
|
|
|
node.dataset.details = notes || name;
|
|
|
|
node.dataset.category = category;
|
|
|
|
if (redundant) { node.dataset.redundant = 'true'; }
|
2019-12-25 02:45:57 +00:00
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2021-01-09 21:02:03 +00:00
|
|
|
_createTermTag(details, totalExpressionCount) {
|
|
|
|
const {tag, expressions} = details;
|
|
|
|
const node = this._createTag(tag);
|
|
|
|
node.dataset.disambiguation = `${JSON.stringify(expressions)}`;
|
|
|
|
node.dataset.totalExpressionCount = `${totalExpressionCount}`;
|
|
|
|
node.dataset.matchedExpressionCount = `${expressions.length}`;
|
|
|
|
node.dataset.unmatchedExpressionCount = `${Math.max(0, totalExpressionCount - expressions.length)}`;
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2020-11-14 18:42:50 +00:00
|
|
|
_createSearchTag(text) {
|
2020-11-25 00:06:29 +00:00
|
|
|
return this._createTag({
|
|
|
|
notes: '',
|
|
|
|
name: text,
|
|
|
|
category: 'search',
|
|
|
|
redundant: false
|
|
|
|
});
|
2020-01-26 19:00:19 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 02:02:17 +00:00
|
|
|
_createPitches(details) {
|
2020-11-04 03:30:20 +00:00
|
|
|
this.preparePitchAccents();
|
2020-03-01 19:15:28 +00:00
|
|
|
|
2020-07-31 00:45:52 +00:00
|
|
|
const {dictionary, pitches} = details;
|
2020-03-01 19:15:28 +00:00
|
|
|
|
2020-10-08 00:47:44 +00:00
|
|
|
const node = this._templates.instantiate('term-pitch-accent-group');
|
2020-03-01 19:15:28 +00:00
|
|
|
node.dataset.dictionary = dictionary;
|
|
|
|
node.dataset.pitchesMulti = 'true';
|
2020-07-31 00:45:52 +00:00
|
|
|
node.dataset.pitchesCount = `${pitches.length}`;
|
2020-03-01 19:15:28 +00:00
|
|
|
|
2020-04-10 02:02:17 +00:00
|
|
|
const tag = this._createTag({notes: '', name: dictionary, category: 'pitch-accent-dictionary'});
|
2020-03-01 19:15:28 +00:00
|
|
|
node.querySelector('.term-pitch-accent-group-tag-list').appendChild(tag);
|
|
|
|
|
2020-11-27 20:22:06 +00:00
|
|
|
let hasTags = false;
|
|
|
|
for (const {tags} of pitches) {
|
|
|
|
if (tags.length > 0) {
|
|
|
|
hasTags = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-01 19:15:28 +00:00
|
|
|
const n = node.querySelector('.term-pitch-accent-list');
|
2020-11-27 20:22:06 +00:00
|
|
|
n.dataset.hasTags = `${hasTags}`;
|
2020-07-31 00:45:52 +00:00
|
|
|
this._appendMultiple(n, this._createPitch.bind(this), pitches);
|
2020-03-01 19:15:28 +00:00
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2020-04-10 02:02:17 +00:00
|
|
|
_createPitch(details) {
|
2020-11-29 18:09:02 +00:00
|
|
|
const jp = this._japaneseUtil;
|
2020-03-29 15:27:13 +00:00
|
|
|
const {reading, position, tags, exclusiveExpressions, exclusiveReadings} = details;
|
2020-03-28 14:47:02 +00:00
|
|
|
const morae = jp.getKanaMorae(reading);
|
2020-03-01 19:15:28 +00:00
|
|
|
|
2020-10-08 00:47:44 +00:00
|
|
|
const node = this._templates.instantiate('term-pitch-accent');
|
2020-03-01 19:15:28 +00:00
|
|
|
|
|
|
|
node.dataset.pitchAccentPosition = `${position}`;
|
|
|
|
node.dataset.tagCount = `${tags.length}`;
|
|
|
|
|
|
|
|
let n = node.querySelector('.term-pitch-accent-position');
|
2021-02-08 22:52:35 +00:00
|
|
|
this._setTextContent(n, `${position}`, '');
|
2020-03-01 19:15:28 +00:00
|
|
|
|
|
|
|
n = node.querySelector('.term-pitch-accent-tag-list');
|
2020-04-10 02:02:17 +00:00
|
|
|
this._appendMultiple(n, this._createTag.bind(this), tags);
|
2020-03-01 19:15:28 +00:00
|
|
|
|
2020-03-29 15:19:43 +00:00
|
|
|
n = node.querySelector('.term-pitch-accent-disambiguation-list');
|
2020-04-10 02:02:17 +00:00
|
|
|
this._createPitchAccentDisambiguations(n, exclusiveExpressions, exclusiveReadings);
|
2020-03-01 19:15:28 +00:00
|
|
|
|
|
|
|
n = node.querySelector('.term-pitch-accent-characters');
|
|
|
|
for (let i = 0, ii = morae.length; i < ii; ++i) {
|
|
|
|
const mora = morae[i];
|
2020-03-28 14:47:02 +00:00
|
|
|
const highPitch = jp.isMoraPitchHigh(i, position);
|
|
|
|
const highPitchNext = jp.isMoraPitchHigh(i + 1, position);
|
2020-03-01 19:15:28 +00:00
|
|
|
|
2020-10-08 00:47:44 +00:00
|
|
|
const n1 = this._templates.instantiate('term-pitch-accent-character');
|
2020-03-01 19:15:28 +00:00
|
|
|
const n2 = n1.querySelector('.term-pitch-accent-character-inner');
|
|
|
|
|
|
|
|
n1.dataset.position = `${i}`;
|
|
|
|
n1.dataset.pitch = highPitch ? 'high' : 'low';
|
|
|
|
n1.dataset.pitchNext = highPitchNext ? 'high' : 'low';
|
2021-02-08 22:52:35 +00:00
|
|
|
this._setTextContent(n2, mora, 'ja');
|
2020-03-01 19:15:28 +00:00
|
|
|
|
|
|
|
n.appendChild(n1);
|
|
|
|
}
|
|
|
|
|
2020-03-01 19:20:11 +00:00
|
|
|
if (morae.length > 0) {
|
2020-04-10 02:02:17 +00:00
|
|
|
this._populatePitchGraph(node.querySelector('.term-pitch-accent-graph'), position, morae);
|
2020-03-01 19:20:11 +00:00
|
|
|
}
|
|
|
|
|
2020-03-01 19:15:28 +00:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2020-04-10 02:02:17 +00:00
|
|
|
_createPitchAccentDisambiguations(container, exclusiveExpressions, exclusiveReadings) {
|
2020-03-29 15:27:13 +00:00
|
|
|
const templateName = 'term-pitch-accent-disambiguation';
|
|
|
|
for (const exclusiveExpression of exclusiveExpressions) {
|
2020-10-08 00:47:44 +00:00
|
|
|
const node = this._templates.instantiate(templateName);
|
2020-03-29 15:27:13 +00:00
|
|
|
node.dataset.type = 'expression';
|
2021-02-08 22:52:35 +00:00
|
|
|
this._setTextContent(node, exclusiveExpression, 'ja');
|
2020-03-29 15:27:13 +00:00
|
|
|
container.appendChild(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const exclusiveReading of exclusiveReadings) {
|
2020-10-08 00:47:44 +00:00
|
|
|
const node = this._templates.instantiate(templateName);
|
2020-03-29 15:27:13 +00:00
|
|
|
node.dataset.type = 'reading';
|
2021-02-08 22:52:35 +00:00
|
|
|
this._setTextContent(node, exclusiveReading, 'ja');
|
2020-03-29 15:27:13 +00:00
|
|
|
container.appendChild(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
container.dataset.count = `${exclusiveExpressions.length + exclusiveReadings.length}`;
|
|
|
|
container.dataset.expressionCount = `${exclusiveExpressions.length}`;
|
|
|
|
container.dataset.readingCount = `${exclusiveReadings.length}`;
|
2020-03-01 19:15:28 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 02:02:17 +00:00
|
|
|
_populatePitchGraph(svg, position, morae) {
|
2020-11-29 18:09:02 +00:00
|
|
|
const jp = this._japaneseUtil;
|
2020-03-01 19:20:11 +00:00
|
|
|
const svgns = svg.getAttribute('xmlns');
|
|
|
|
const ii = morae.length;
|
|
|
|
svg.setAttribute('viewBox', `0 0 ${50 * (ii + 1)} 100`);
|
|
|
|
|
|
|
|
const pathPoints = [];
|
|
|
|
for (let i = 0; i < ii; ++i) {
|
2020-03-28 14:47:02 +00:00
|
|
|
const highPitch = jp.isMoraPitchHigh(i, position);
|
|
|
|
const highPitchNext = jp.isMoraPitchHigh(i + 1, position);
|
2020-03-01 19:20:11 +00:00
|
|
|
const graphic = (highPitch && !highPitchNext ? '#term-pitch-accent-graph-dot-downstep' : '#term-pitch-accent-graph-dot');
|
|
|
|
const x = `${i * 50 + 25}`;
|
|
|
|
const y = highPitch ? '25' : '75';
|
|
|
|
const use = document.createElementNS(svgns, 'use');
|
|
|
|
use.setAttribute('href', graphic);
|
|
|
|
use.setAttribute('x', x);
|
|
|
|
use.setAttribute('y', y);
|
|
|
|
svg.appendChild(use);
|
|
|
|
pathPoints.push(`${x} ${y}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
let path = svg.querySelector('.term-pitch-accent-graph-line');
|
|
|
|
path.setAttribute('d', `M${pathPoints.join(' L')}`);
|
|
|
|
|
|
|
|
pathPoints.splice(0, ii - 1);
|
|
|
|
{
|
2020-03-28 14:47:02 +00:00
|
|
|
const highPitch = jp.isMoraPitchHigh(ii, position);
|
2020-03-01 19:20:11 +00:00
|
|
|
const x = `${ii * 50 + 25}`;
|
|
|
|
const y = highPitch ? '25' : '75';
|
|
|
|
const use = document.createElementNS(svgns, 'use');
|
|
|
|
use.setAttribute('href', '#term-pitch-accent-graph-triangle');
|
|
|
|
use.setAttribute('x', x);
|
|
|
|
use.setAttribute('y', y);
|
|
|
|
svg.appendChild(use);
|
|
|
|
pathPoints.push(`${x} ${y}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
path = svg.querySelector('.term-pitch-accent-graph-line-tail');
|
|
|
|
path.setAttribute('d', `M${pathPoints.join(' L')}`);
|
|
|
|
}
|
|
|
|
|
2021-01-09 15:41:17 +00:00
|
|
|
_createFrequencyGroup(details, kanji) {
|
|
|
|
const {dictionary, frequencyData} = details;
|
2021-02-25 22:48:39 +00:00
|
|
|
|
2021-01-09 15:41:17 +00:00
|
|
|
const node = this._templates.instantiate('frequency-group-item');
|
2021-02-25 22:48:39 +00:00
|
|
|
const body = node.querySelector('.tag-body-content');
|
2021-01-09 15:41:17 +00:00
|
|
|
|
2021-02-25 22:48:39 +00:00
|
|
|
this._setTextContent(node.querySelector('.tag-label-content'), dictionary);
|
|
|
|
node.dataset.details = dictionary;
|
2021-01-09 15:41:17 +00:00
|
|
|
|
2021-02-25 22:48:39 +00:00
|
|
|
for (let i = 0, ii = frequencyData.length; i < ii; ++i) {
|
|
|
|
const item = frequencyData[i];
|
|
|
|
const itemNode = (kanji ? this._createKanjiFrequency(item, dictionary) : this._createTermFrequency(item, dictionary));
|
|
|
|
itemNode.dataset.index = `${i}`;
|
|
|
|
body.appendChild(itemNode);
|
|
|
|
}
|
2021-01-09 15:41:17 +00:00
|
|
|
|
2021-02-25 22:48:39 +00:00
|
|
|
body.dataset.count = `${frequencyData.length}`;
|
2021-01-09 15:41:17 +00:00
|
|
|
node.dataset.count = `${frequencyData.length}`;
|
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
_createTermFrequency(details, dictionary) {
|
|
|
|
const {expression, reading, frequencies} = details;
|
|
|
|
const node = this._templates.instantiate('term-frequency-item');
|
2019-12-25 02:45:57 +00:00
|
|
|
|
2021-02-25 22:48:39 +00:00
|
|
|
this._setTextContent(node.querySelector('.tag-label-content'), dictionary);
|
|
|
|
|
2021-01-09 15:41:17 +00:00
|
|
|
const frequency = frequencies.join(', ');
|
|
|
|
|
2021-02-08 22:52:35 +00:00
|
|
|
this._setTextContent(node.querySelector('.frequency-disambiguation-expression'), expression, 'ja');
|
|
|
|
this._setTextContent(node.querySelector('.frequency-disambiguation-reading'), (reading !== null ? reading : ''), 'ja');
|
|
|
|
this._setTextContent(node.querySelector('.frequency-value'), frequency, 'ja');
|
2019-12-25 02:45:57 +00:00
|
|
|
|
2020-11-24 16:56:40 +00:00
|
|
|
node.dataset.expression = expression;
|
|
|
|
node.dataset.reading = reading;
|
2021-01-09 15:41:17 +00:00
|
|
|
node.dataset.hasReading = `${reading !== null}`;
|
2020-11-24 16:56:40 +00:00
|
|
|
node.dataset.readingIsSame = `${reading === expression}`;
|
|
|
|
node.dataset.dictionary = dictionary;
|
2021-01-09 15:41:17 +00:00
|
|
|
node.dataset.frequency = `${frequency}`;
|
2019-12-25 02:45:57 +00:00
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2021-01-09 15:41:17 +00:00
|
|
|
_createKanjiFrequency(details, dictionary) {
|
|
|
|
const {character, frequencies} = details;
|
|
|
|
const node = this._templates.instantiate('kanji-frequency-item');
|
|
|
|
|
|
|
|
const frequency = frequencies.join(', ');
|
2020-12-05 22:45:45 +00:00
|
|
|
|
2021-02-25 22:48:39 +00:00
|
|
|
this._setTextContent(node.querySelector('.tag-label-content'), dictionary);
|
2021-02-08 22:52:35 +00:00
|
|
|
this._setTextContent(node.querySelector('.frequency-value'), frequency, 'ja');
|
2020-12-05 22:45:45 +00:00
|
|
|
|
|
|
|
node.dataset.character = character;
|
|
|
|
node.dataset.dictionary = dictionary;
|
2021-01-09 15:41:17 +00:00
|
|
|
node.dataset.frequency = `${frequency}`;
|
2020-12-05 22:45:45 +00:00
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2019-12-25 02:45:57 +00:00
|
|
|
_appendKanjiLinks(container, text) {
|
2021-02-08 22:52:35 +00:00
|
|
|
container.lang = 'ja';
|
2020-11-29 18:09:02 +00:00
|
|
|
const jp = this._japaneseUtil;
|
2019-12-25 02:45:57 +00:00
|
|
|
let part = '';
|
|
|
|
for (const c of text) {
|
2020-03-21 17:22:14 +00:00
|
|
|
if (jp.isCodePointKanji(c.codePointAt(0))) {
|
2019-12-25 02:45:57 +00:00
|
|
|
if (part.length > 0) {
|
|
|
|
container.appendChild(document.createTextNode(part));
|
|
|
|
part = '';
|
|
|
|
}
|
|
|
|
|
2020-04-10 02:02:17 +00:00
|
|
|
const link = this._createKanjiLink(c);
|
2019-12-25 02:45:57 +00:00
|
|
|
container.appendChild(link);
|
|
|
|
} else {
|
|
|
|
part += c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (part.length > 0) {
|
|
|
|
container.appendChild(document.createTextNode(part));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 18:42:50 +00:00
|
|
|
_appendMultiple(container, createItem, detailsArray, ...args) {
|
2020-01-25 05:14:27 +00:00
|
|
|
let count = 0;
|
2020-11-22 02:17:39 +00:00
|
|
|
const {ELEMENT_NODE} = Node;
|
2020-11-14 18:42:50 +00:00
|
|
|
if (Array.isArray(detailsArray)) {
|
|
|
|
for (const details of detailsArray) {
|
2020-04-10 02:35:26 +00:00
|
|
|
const item = createItem(details, ...args);
|
2020-04-10 02:16:55 +00:00
|
|
|
if (item === null) { continue; }
|
|
|
|
container.appendChild(item);
|
2020-11-22 02:17:39 +00:00
|
|
|
if (item.nodeType === ELEMENT_NODE) {
|
|
|
|
item.dataset.index = `${count}`;
|
|
|
|
}
|
2020-04-10 02:16:55 +00:00
|
|
|
++count;
|
|
|
|
}
|
2019-12-25 02:45:57 +00:00
|
|
|
}
|
|
|
|
|
2020-01-25 05:14:27 +00:00
|
|
|
container.dataset.count = `${count}`;
|
|
|
|
|
|
|
|
return count;
|
2019-12-25 02:45:57 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 01:59:02 +00:00
|
|
|
_appendFurigana(container, segments, addText) {
|
2019-12-25 02:45:57 +00:00
|
|
|
for (const {text, furigana} of segments) {
|
|
|
|
if (furigana) {
|
|
|
|
const ruby = document.createElement('ruby');
|
|
|
|
const rt = document.createElement('rt');
|
|
|
|
addText(ruby, text);
|
|
|
|
ruby.appendChild(rt);
|
|
|
|
rt.appendChild(document.createTextNode(furigana));
|
|
|
|
container.appendChild(ruby);
|
|
|
|
} else {
|
|
|
|
addText(container, text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-29 02:33:30 +00:00
|
|
|
_createDictionaryTag(dictionary) {
|
|
|
|
return {
|
|
|
|
name: dictionary,
|
|
|
|
category: 'dictionary',
|
|
|
|
notes: '',
|
|
|
|
order: 100,
|
|
|
|
score: 0,
|
|
|
|
dictionary,
|
|
|
|
redundant: false
|
|
|
|
};
|
|
|
|
}
|
2021-02-08 22:52:35 +00:00
|
|
|
|
|
|
|
_setTextContent(node, value, language) {
|
|
|
|
node.textContent = value;
|
|
|
|
if (typeof language === 'string') {
|
|
|
|
node.lang = language;
|
|
|
|
} else if (this._japaneseUtil.isStringPartiallyJapanese(value)) {
|
|
|
|
node.lang = 'ja';
|
|
|
|
}
|
|
|
|
}
|
2019-12-25 02:45:57 +00:00
|
|
|
}
|