summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAlex Yatskov <FooSoft@users.noreply.github.com>2019-12-03 14:19:33 -0800
committerGitHub <noreply@github.com>2019-12-03 14:19:33 -0800
commita24146538c94f0871c7ae91d4ebb9f663c22acf8 (patch)
tree90784b3d8743074bcfe505d06e5138f1e582754b /ext
parent774db569eb3746e8d0fe44325d76e4040196263a (diff)
parent3a7ef6c560fc6437dc33ad197c136af4498db15c (diff)
Merge pull request #291 from toasted-nutbread/cloze-fixes
Cloze fixes
Diffstat (limited to 'ext')
-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) {