aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mixed')
-rw-r--r--ext/mixed/js/display.js38
1 files changed, 32 insertions, 6 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index e0994f8a..bab82015 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -74,8 +74,8 @@ class Display {
context.source.source = this.context.source;
}
- const kanjiDefs = await apiKanjiFind(link.textContent, this.getOptionsContext());
- this.kanjiShow(kanjiDefs, context);
+ const definitions = await apiKanjiFind(link.textContent, this.getOptionsContext());
+ this.setContentKanji(definitions, context);
} catch (e) {
this.onError(e);
}
@@ -122,7 +122,7 @@ class Display {
context.source.source = this.context.source;
}
- this.termsShow(definitions, context);
+ this.setContentTerms(definitions, context);
} catch (e) {
this.onError(e);
}
@@ -263,7 +263,20 @@ class Display {
});
}
- async termsShow(definitions, context) {
+ setContent(type, details) {
+ switch (type) {
+ case 'terms':
+ return this.setContentTerms(details.definitions, details.context);
+ case 'kanji':
+ return this.setContentKanji(details.definitions, details.context);
+ case 'orphaned':
+ return this.setContentOrphaned();
+ default:
+ return Promise.resolve();
+ }
+ }
+
+ async setContentTerms(definitions, context) {
if (!this.isInitialized()) { return; }
try {
@@ -317,7 +330,7 @@ class Display {
}
}
- async kanjiShow(definitions, context) {
+ async setContentKanji(definitions, context) {
if (!this.isInitialized()) { return; }
try {
@@ -363,6 +376,19 @@ class Display {
}
}
+ async setContentOrphaned() {
+ const definitions = document.querySelector('#definitions');
+ const errorOrphaned = document.querySelector('#error-orphaned');
+
+ if (definitions !== null) {
+ definitions.style.setProperty('display', 'none', 'important');
+ }
+
+ if (errorOrphaned !== null) {
+ errorOrphaned.style.setProperty('display', 'block', 'important');
+ }
+ }
+
autoPlayAudio() {
this.audioPlay(this.definitions[0], this.firstExpressionIndex, 0);
}
@@ -441,7 +467,7 @@ class Display {
source: this.context.source.source
};
- this.termsShow(this.context.source.definitions, context);
+ this.setContentTerms(this.context.source.definitions, context);
}
}