diff options
Diffstat (limited to 'ext/mixed/js')
-rw-r--r-- | ext/mixed/js/audio.js (renamed from ext/mixed/js/util.js) | 19 | ||||
-rw-r--r-- | ext/mixed/js/display.js | 18 |
2 files changed, 16 insertions, 21 deletions
diff --git a/ext/mixed/js/util.js b/ext/mixed/js/audio.js index 0a8c914d..451fe1d9 100644 --- a/ext/mixed/js/util.js +++ b/ext/mixed/js/audio.js @@ -18,25 +18,6 @@ /* - * Cloze - */ - -function clozeBuild(sentence, source) { - const result = { - sentence: sentence.text.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; -} - - -/* * Audio */ diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index da0cd351..e54bc0f9 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -80,7 +80,7 @@ class Display { if (context) { for (const definition of definitions) { if (context.sentence) { - definition.cloze = clozeBuild(context.sentence, definition.source); + definition.cloze = Display.clozeBuild(context.sentence, definition.source); } definition.url = context.url; @@ -119,7 +119,7 @@ class Display { if (context) { for (const definition of definitions) { if (context.sentence) { - definition.cloze = clozeBuild(context.sentence); + definition.cloze = Display.clozeBuild(context.sentence); } definition.url = context.url; @@ -394,6 +394,20 @@ class Display { }).catch(this.handleError.bind(this)).then(() => this.spinner.hide()); } + static clozeBuild(sentence, source) { + const result = { + sentence: sentence.text.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; + } + static entryIndexFind(element) { return $('.entry').index(element.closest('.entry')); } |