summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-09 22:38:08 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-09 22:40:25 -0400
commit025b1f398b7e498a0a61ebee095498caccb46819 (patch)
treed40c4cbb289f4f5dbab4c5e3a1b4e2c3d59bb9dd /ext
parent06183ec12442fc127a7f723225bcf1782eb15ebc (diff)
Simplify access to details fields in createTermEntry
Diffstat (limited to 'ext')
-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);