linny-r 1.5.7 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -162,24 +162,24 @@ NOTE: Grouping groups results in a single group, e.g., (1;2);(3;4;5) evaluates a
162
162
  Monadic operators take precedence over dyadic operators.
163
163
  Use parentheses to override the default evaluation precedence.
164
164
  </p>`;
165
- // Add listeners to the GUI elements
165
+ // Add listeners to the GUI elements.
166
166
  const md = UI.modals.expression;
167
167
  md.ok.addEventListener('click', () => X_EDIT.parseExpression());
168
168
  md.cancel.addEventListener('click', () => X_EDIT.cancel());
169
- // NOTE: this modal also has an information button in its header
169
+ // NOTE: This modal also has an information button in its header.
170
170
  md.info.addEventListener(
171
171
  'click', () => X_EDIT.toggleExpressionInfo());
172
- document.getElementById('variable-obj').addEventListener(
172
+ this.obj.addEventListener(
173
173
  'change', () => X_EDIT.updateVariableBar());
174
- document.getElementById('variable-name').addEventListener(
174
+ this.name.addEventListener(
175
175
  'change', () => X_EDIT.updateAttributeSelector());
176
176
  document.getElementById('variable-insert').addEventListener(
177
177
  'click', () => X_EDIT.insertVariable());
178
178
  }
179
179
 
180
180
  editExpression(event) {
181
- // Infers which entity property expression is to edited from the button
182
- // that was clicked, and then opens the dialog
181
+ // Infer which entity property expression is to edited from the button
182
+ // that was clicked, and then opens the dialog.
183
183
  const
184
184
  btn = event.target,
185
185
  ids = btn.id.split('-'), // 3-tuple [entity type, attribute, 'x']
@@ -196,7 +196,8 @@ NOTE: Grouping groups results in a single group, e.g., (1;2);(3;4;5) evaluates a
196
196
  let n = '',
197
197
  a = '';
198
198
  if(ids[0] === 'link') {
199
- n = document.getElementById('link-from-name').innerHTML + UI.LINK_ARROW +
199
+ n = document.getElementById('link-from-name').innerHTML +
200
+ UI.LINK_ARROW +
200
201
  document.getElementById('link-to-name').innerHTML;
201
202
  } else {
202
203
  n = document.getElementById(ids[0] + '-name').value;
@@ -211,20 +212,19 @@ NOTE: Grouping groups results in a single group, e.g., (1;2);(3;4;5) evaluates a
211
212
  this.edited_expression = UI.edited_object.attributeExpression(ids[1]);
212
213
  }
213
214
  const md = UI.modals.expression;
214
- md.element('property').innerHTML = prop;
215
- md.element('text').value = document.getElementById(
216
- this.edited_input_id).value.trim();
217
- document.getElementById('variable-obj').value = 0;
215
+ this.property.innerHTML = prop;
216
+ this.text.value = document.getElementById(this.edited_input_id).value.trim();
217
+ this.obj.value = 0;
218
218
  this.updateVariableBar();
219
219
  this.clearStatusBar();
220
220
  md.show('text');
221
221
  }
222
222
 
223
223
  cancel() {
224
- // Closes the expression editor dialog
224
+ // Close the expression editor dialog.
225
225
  UI.modals.expression.hide();
226
226
  // Clear the "shortcut flag" that may be set by Shift-clicking the
227
- // "add chart variable" button in the chart dialog
227
+ // "add chart variable" button in the chart dialog.
228
228
  EQUATION_MANAGER.add_to_chart = false;
229
229
  // CLear other properties that relate to the edited expression.
230
230
  this.edited_input_id = '';
@@ -232,20 +232,25 @@ NOTE: Grouping groups results in a single group, e.g., (1;2);(3;4;5) evaluates a
232
232
  }
233
233
 
234
234
  parseExpression() {
235
- // Parses the contents of the expression editor
236
- let xt = this.text.value;
237
- // NOTE: the Insert button is quite close to the OK button, and often
238
- // the modeler clicks OK before Insert, leaving the expression empty;
239
- // hence assume that modeler meant to insert a variable if text is empty,
240
- // but all three variable components have been selected
235
+ // Parse the contents of the expression editor.
236
+ let xt = this.text.value.trim();
237
+ // NOTE: The Insert button is quite close to the OK button, and often
238
+ // the modeler clicks OK before Insert, leaving the expression empty.
239
+ // Hence assume that modeler meant to insert a variable if text is
240
+ // empty but all three variable components have been selected.
241
241
  if(xt === '') {
242
242
  const
243
243
  n = this.name.options[this.name.selectedIndex].innerHTML,
244
244
  a = this.attr.options[this.attr.selectedIndex].innerHTML;
245
245
  if(n && a) xt = `[${n}${UI.OA_SEPARATOR}${a}]`;
246
246
  }
247
+ // Remove all non-functional whitespace from variable references.
248
+ xt = monoSpacedVariables(xt);
249
+ // Update the text shown in the editor, otherwise the position of
250
+ // errors in the text may be incorrect.
251
+ this.text.value = xt;
247
252
  // NOTE: If the expression is a dataset modifier or an equation, pass
248
- // the dataset and the selector as extra parameters for the parser
253
+ // the dataset and the selector as extra parameters for the parser.
249
254
  let own = null,
250
255
  sel = '';
251
256
  if(!this.edited_input_id && DATASET_MANAGER.edited_expression) {
@@ -270,7 +275,7 @@ NOTE: Grouping groups results in a single group, e.g., (1;2);(3;4;5) evaluates a
270
275
  } else {
271
276
  if(this.edited_input_id) {
272
277
  document.getElementById(this.edited_input_id).value = xp.expr;
273
- // NOTE: entity properties must be exogenous parameters
278
+ // NOTE: Entity properties must be exogenous parameters.
274
279
  const eo = UI.edited_object;
275
280
  if(eo && xp.is_level_based &&
276
281
  !(eo instanceof Dataset || eo instanceof Note)) {
@@ -175,7 +175,7 @@ class GUIMonitor {
175
175
  this.block_count = VM.block_count;
176
176
  // Shows the appropriate text in the monitor's textarea
177
177
  let b = this.shown_block;
178
- // By default, show information on the block being calculated
178
+ // By default, show information on the block being calculated.
179
179
  if(b === 0) b = this.block_count;
180
180
  if(this.block_count === 0) {
181
181
  this.messages_text.value = VM.no_messages;
@@ -184,9 +184,9 @@ class GUIMonitor {
184
184
  this.messages_text.value = VM.messages[b - 1];
185
185
  this.equations_text.value = VM.equations[b - 1];
186
186
  }
187
- // Legend to variables is not block-dependent
188
- this.variables_text.value = VM.variablesLegend(b);
189
- // Show the text area for the selected tab
187
+ // Legend to variables is not block-dependent.
188
+ this.variables_text.value = VM.variablesLegend();
189
+ // Show the text area for the selected tab.
190
190
  if(this.tab !== tab) {
191
191
  let mt = 'monitor-' + this.tab;
192
192
  document.getElementById(mt).style.display = 'none';