aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-11-26 10:53:21 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-11-26 12:35:17 -0500
commit3a7ef6c560fc6437dc33ad197c136af4498db15c (patch)
tree78c3a165a3afe86d09f08446e269aec14e7b31a3 /ext/mixed/js
parentafddec66eb749aa0a39c7e7142f929e68697995d (diff)
Simplify clozeBuild
Diffstat (limited to 'ext/mixed/js')
-rw-r--r--ext/mixed/js/display.js17
1 files changed, 6 insertions, 11 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index 21d00bbc..f231fab5 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -633,18 +633,13 @@ class Display {
return index >= 0 && index < entries.length ? entries[index] : null;
}
- static clozeBuild(sentence, source) {
- const result = {
- sentence: sentence.text.trim()
+ static clozeBuild({text, offset}, source) {
+ return {
+ sentence: text.trim(),
+ prefix: text.substring(0, offset).trim(),
+ body: text.substring(offset, offset + source.length),
+ suffix: text.substring(offset + source.length).trim()
};
-
- if (source) {
- result.prefix = sentence.text.substring(0, sentence.offset).trim();
- result.body = sentence.text.substring(sentence.offset, sentence.offset + source.length);
- result.suffix = sentence.text.substring(sentence.offset + source.length).trim();
- }
-
- return result;
}
entryIndexFind(element) {