summaryrefslogtreecommitdiff
path: root/ext/mixed
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mixed')
-rw-r--r--ext/mixed/js/display-generator.js18
1 files changed, 8 insertions, 10 deletions
diff --git a/ext/mixed/js/display-generator.js b/ext/mixed/js/display-generator.js
index b2d34cfc..19f6a56e 100644
--- a/ext/mixed/js/display-generator.js
+++ b/ext/mixed/js/display-generator.js
@@ -44,13 +44,15 @@ class DisplayGenerator {
const debugInfoContainer = node.querySelector('.debug-info');
const bodyContainer = node.querySelector('.term-entry-body');
+ const {termTags, expressions, definitions} = details;
+
const pitches = this._getPitchInfos(details);
const pitchCount = pitches.reduce((i, v) => i + v[1].length, 0);
- const expressionMulti = Array.isArray(details.expressions);
- const definitionMulti = Array.isArray(details.definitions);
- const expressionCount = expressionMulti ? details.expressions.length : 1;
- const definitionCount = definitionMulti ? details.definitions.length : 1;
+ const expressionMulti = Array.isArray(expressions);
+ const definitionMulti = Array.isArray(definitions);
+ const expressionCount = expressionMulti ? expressions.length : 1;
+ const definitionCount = definitionMulti ? definitions.length : 1;
const uniqueExpressionCount = Array.isArray(details.expression) ? new Set(details.expression).size : 1;
node.dataset.expressionMulti = `${expressionMulti}`;
@@ -66,15 +68,11 @@ class DisplayGenerator {
(pitches.length > 0 ? 1 : 0)
}`;
- const termTags = details.termTags;
- let expressions = details.expressions;
- expressions = Array.isArray(expressions) ? expressions : [details];
-
- this._appendMultiple(expressionsContainer, this._createTermExpression.bind(this), expressions, termTags);
+ this._appendMultiple(expressionsContainer, this._createTermExpression.bind(this), expressionMulti ? expressions : [details], termTags);
this._appendMultiple(reasonsContainer, this._createTermReason.bind(this), details.reasons);
this._appendMultiple(frequenciesContainer, this._createFrequencyTag.bind(this), details.frequencies);
this._appendMultiple(pitchesContainer, this._createPitches.bind(this), pitches);
- this._appendMultiple(definitionsContainer, this._createTermDefinitionItem.bind(this), definitionMulti ? details.definitions : [details]);
+ this._appendMultiple(definitionsContainer, this._createTermDefinitionItem.bind(this), definitionMulti ? definitions : [details]);
if (debugInfoContainer !== null) {
debugInfoContainer.textContent = JSON.stringify(details, null, 4);