summaryrefslogtreecommitdiff
path: root/ext/mixed/js/display-generator.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-11-29 13:09:02 -0500
committerGitHub <noreply@github.com>2020-11-29 13:09:02 -0500
commit34451ebf7122a2a5d140696215411abfb0dfe188 (patch)
treee9eddb52f133269853059372045dea510e8d02dc /ext/mixed/js/display-generator.js
parenta8cd03cbecf4015483ce3479e589e65ce7eece45 (diff)
JapaneseUtil normalization (#1076)
* Use JapaneseUtil as a class which is manually instantiated * Use alias function for toKana
Diffstat (limited to 'ext/mixed/js/display-generator.js')
-rw-r--r--ext/mixed/js/display-generator.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/mixed/js/display-generator.js b/ext/mixed/js/display-generator.js
index 63140330..82f6199b 100644
--- a/ext/mixed/js/display-generator.js
+++ b/ext/mixed/js/display-generator.js
@@ -19,11 +19,11 @@
* DictionaryDataUtil
* HtmlTemplateCollection
* api
- * jp
*/
class DisplayGenerator {
- constructor({mediaLoader}) {
+ constructor({japaneseUtil, mediaLoader}) {
+ this._japaneseUtil = japaneseUtil;
this._mediaLoader = mediaLoader;
this._templates = null;
this._termPitchAccentStaticTemplateIsSetup = false;
@@ -354,6 +354,7 @@ class DisplayGenerator {
}
_createPitch(details) {
+ const jp = this._japaneseUtil;
const {reading, position, tags, exclusiveExpressions, exclusiveReadings} = details;
const morae = jp.getKanaMorae(reading);
@@ -417,6 +418,7 @@ class DisplayGenerator {
}
_populatePitchGraph(svg, position, morae) {
+ const jp = this._japaneseUtil;
const svgns = svg.getAttribute('xmlns');
const ii = morae.length;
svg.setAttribute('viewBox', `0 0 ${50 * (ii + 1)} 100`);
@@ -475,6 +477,7 @@ class DisplayGenerator {
}
_appendKanjiLinks(container, text) {
+ const jp = this._japaneseUtil;
let part = '';
for (const c of text) {
if (jp.isCodePointKanji(c.codePointAt(0))) {