diff options
author | siikamiika <siikamiika@users.noreply.github.com> | 2020-01-26 21:00:19 +0200 |
---|---|---|
committer | siikamiika <siikamiika@users.noreply.github.com> | 2020-02-02 13:57:30 +0200 |
commit | b8326138a3254e82dd42e1517f371287bdfc6705 (patch) | |
tree | 5655e89b2ff9548e462ddbf9043e658470b08c91 /ext/mixed/js/display-generator.js | |
parent | 24690ceb7c0fc2af9ebd33971dece22eb2bd1d03 (diff) |
add scannable tags for expression and reading
Diffstat (limited to 'ext/mixed/js/display-generator.js')
-rw-r--r-- | ext/mixed/js/display-generator.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/mixed/js/display-generator.js b/ext/mixed/js/display-generator.js index b2dc373b..c90e693a 100644 --- a/ext/mixed/js/display-generator.js +++ b/ext/mixed/js/display-generator.js @@ -111,7 +111,11 @@ class DisplayGenerator { // Fallback termTags = details.termTags; } + const searchQueries = [details.expression, details.reading] + .filter((x) => !!x) + .map((x) => ({query: x})); DisplayGenerator._appendMultiple(tagContainer, this.createTag.bind(this), termTags); + DisplayGenerator._appendMultiple(tagContainer, this.createSearchTag.bind(this), searchQueries); DisplayGenerator._appendMultiple(frequencyContainer, this.createFrequencyTag.bind(this), details.frequencies); return node; @@ -270,6 +274,16 @@ class DisplayGenerator { return node; } + createSearchTag(details) { + const node = DisplayGenerator._instantiateTemplate(this._tagSearchTemplate); + + node.textContent = details.query; + + node.dataset.query = details.query; + + return node; + } + createFrequencyTag(details) { const node = DisplayGenerator._instantiateTemplate(this._tagFrequencyTemplate); @@ -311,6 +325,7 @@ class DisplayGenerator { this._kanjiReadingTemplate = doc.querySelector('#kanji-reading-template'); this._tagTemplate = doc.querySelector('#tag-template'); + this._tagSearchTemplate = doc.querySelector('#tag-search-template'); this._tagFrequencyTemplate = doc.querySelector('#tag-frequency-template'); } |