diff options
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/js/display/display-generator.js | 7 | ||||
| -rw-r--r-- | ext/js/language/dictionary-data-util.js | 3 | ||||
| -rw-r--r-- | ext/js/language/japanese-util.js | 2 | ||||
| -rw-r--r-- | ext/js/language/translator.js | 6 | ||||
| -rw-r--r-- | ext/js/media/audio-downloader.js | 2 | 
5 files changed, 9 insertions, 11 deletions
| diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index 93e84bdd..d8ae566e 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -70,8 +70,7 @@ class DisplayGenerator {          const uniqueExpressions = new Set();          const uniqueReadings = new Set(); -        for (let {expression, reading} of expressions) { -            if (reading.length === 0) { reading = expression; } +        for (const {expression, reading} of expressions) {              uniqueExpressions.add(expression);              uniqueReadings.add(reading);          } @@ -244,7 +243,7 @@ class DisplayGenerator {          const expressionContainer = node.querySelector('.expression-text');          const tagContainer = node.querySelector('.expression-tag-list'); -        node.dataset.readingIsSame = `${!reading || reading === expression}`; +        node.dataset.readingIsSame = `${reading === expression}`;          node.dataset.frequency = termFrequency;          const pitchAccentCategories = this._getPitchAccentCategories(pitches); @@ -252,7 +251,7 @@ class DisplayGenerator {              node.dataset.pitchAccentCategories = pitchAccentCategories;          } -        this._setTextContent(node.querySelector('.expression-reading'), reading.length > 0 ? reading : expression); +        this._setTextContent(node.querySelector('.expression-reading'), reading);          this._appendFurigana(expressionContainer, furiganaSegments, this._appendKanjiLinks.bind(this));          this._appendMultiple(tagContainer, this._createTag.bind(this), termTags); diff --git a/ext/js/language/dictionary-data-util.js b/ext/js/language/dictionary-data-util.js index 70a51e89..b3a354a7 100644 --- a/ext/js/language/dictionary-data-util.js +++ b/ext/js/language/dictionary-data-util.js @@ -96,8 +96,7 @@ class DictionaryDataUtil {          const allExpressions = new Set();          const allReadings = new Set(); -        for (let {expression, reading, pitches: expressionPitches} of definition.expressions) { -            if (reading.length === 0) { reading = expression; } +        for (const {expression, reading, pitches: expressionPitches} of definition.expressions) {              allExpressions.add(expression);              allReadings.add(reading); diff --git a/ext/js/language/japanese-util.js b/ext/js/language/japanese-util.js index 861d66e8..b363ed5c 100644 --- a/ext/js/language/japanese-util.js +++ b/ext/js/language/japanese-util.js @@ -430,7 +430,7 @@ const JapaneseUtil = (() => {          // Furigana distribution          distributeFurigana(expression, reading) { -            if (!reading || reading === expression) { +            if (reading === expression) {                  // Same                  return [this._createFuriganaSegment(expression, '')];              } diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 28cc1f3c..0533f70b 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -648,8 +648,7 @@ class Translator {          for (const {expressions, frequencies: frequencies1, pitches: pitches1} of allDefinitions) {              for (let i = 0, ii = expressions.length; i < ii; ++i) { -                let {expression, reading, frequencies: frequencies2, pitches: pitches2} = expressions[i]; -                if (reading.length === 0) { reading = expression; } +                const {expression, reading, frequencies: frequencies2, pitches: pitches2} = expressions[i];                  let readingMap = expressionMap.get(expression);                  if (typeof readingMap === 'undefined') {                      readingMap = new Map(); @@ -1079,7 +1078,8 @@ class Translator {      }      async _createTermDefinitionFromDatabaseDefinition(databaseDefinition, source, rawSource, sourceTerm, reasons, isPrimary, enabledDictionaryMap) { -        const {expression, reading, definitionTags, termTags, glossary, score, dictionary, id, sequence} = databaseDefinition; +        const {expression, reading: rawReading, definitionTags, termTags, glossary, score, dictionary, id, sequence} = databaseDefinition; +        const reading = (rawReading.length > 0 ? rawReading : expression);          const dictionaryOrder = this._getDictionaryOrder(dictionary, enabledDictionaryMap);          const termTagsExpanded = await this._expandTags(termTags, dictionary);          const definitionTagsExpanded = await this._expandTags(definitionTags, dictionary); diff --git a/ext/js/media/audio-downloader.js b/ext/js/media/audio-downloader.js index bb8d40a8..68e03d39 100644 --- a/ext/js/media/audio-downloader.js +++ b/ext/js/media/audio-downloader.js @@ -131,7 +131,7 @@ class AudioDownloader {                  if (htmlReadings.length === 0) { continue; }                  const htmlReading = dom.getTextContent(htmlReadings[0]); -                if (htmlReading && (!reading || reading === htmlReading)) { +                if (htmlReading && (reading === expression || reading === htmlReading)) {                      url = this._normalizeUrl(url, response.url);                      return [{type: 'url', url}];                  } |