From bbe4afecf6a56f4bdaaafe083a3bf67191fd9cde Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Thu, 6 Apr 2017 21:07:55 -0700 Subject: wip --- ext/mixed/js/display.js | 4 ++-- ext/mixed/js/util.js | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'ext/mixed/js') diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index f5ad4849..e77ca7da 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -74,7 +74,7 @@ class Display { if (context) { for (const definition of definitions) { - definition.cloze = context.cloze; + definition.cloze = clozeBuild(context.cloze); definition.url = context.url; } } @@ -108,7 +108,7 @@ class Display { if (context) { for (const definition of definitions) { - definition.cloze = context.cloze; + definition.cloze = clozeBuild(context.cloze); definition.url = context.url; } } diff --git a/ext/mixed/js/util.js b/ext/mixed/js/util.js index c05fb679..aeeb830e 100644 --- a/ext/mixed/js/util.js +++ b/ext/mixed/js/util.js @@ -17,6 +17,20 @@ */ +/* + * Cloze + */ + +function clozeBuild(sentence, offset, source) { + return { + sentence: sentence.trim(), + prefix: sentence.substring(0, offset).trim(), + body: source.trim(), + suffix: sentence.substring(offset + source.length).trim() + }; +} + + /* * Audio */ -- cgit v1.2.3