summaryrefslogtreecommitdiff
path: root/ext/mixed
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mixed')
-rw-r--r--ext/mixed/js/display.js19
1 files changed, 7 insertions, 12 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index f1829198..c32852ad 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -422,7 +422,7 @@ class Display {
};
for (const definition of definitions) {
- definition.cloze = Display.clozeBuild(context.sentence);
+ definition.cloze = Display.clozeBuild(context.sentence, definition.character);
definition.url = context.url;
}
@@ -686,18 +686,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 = source.trim();
- result.suffix = sentence.text.substring(sentence.offset + source.length).trim();
- }
-
- return result;
}
entryIndexFind(element) {