aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-04-08 18:04:37 -0700
committerAlex Yatskov <alex@foosoft.net>2017-04-08 18:04:37 -0700
commit1b49f91a9b252447ab791ccef7b26a0b8b6062dd (patch)
tree1cee3846da13d317be015a6ec4c244864e8b9247 /ext/mixed
parentbea50cca462be631dadbd2f5bde1bc0a12ad17bf (diff)
parentd263a93d446096abfc33e47f591dbb71eb7fe928 (diff)
Merge branch 'master' into firefox-amo
Diffstat (limited to 'ext/mixed')
-rw-r--r--ext/mixed/js/display.js8
-rw-r--r--ext/mixed/js/util.js23
2 files changed, 27 insertions, 4 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index f5ad4849..64d462ae 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.sentence, definition.source);
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.sentence);
definition.url = context.url;
}
}
@@ -181,7 +181,7 @@ class Display {
};
if (this.context) {
- context.cloze = this.context.cloze;
+ context.sentence = this.context.sentence;
context.url = this.context.url;
}
@@ -308,7 +308,7 @@ class Display {
if (this.context && this.context.source) {
const context = {
url: this.context.source.url,
- cloze: this.context.source.cloze,
+ sentence: this.context.source.sentence,
index: this.context.source.index
};
diff --git a/ext/mixed/js/util.js b/ext/mixed/js/util.js
index edd49873..62838674 100644
--- a/ext/mixed/js/util.js
+++ b/ext/mixed/js/util.js
@@ -18,6 +18,25 @@
/*
+ * 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
*/
@@ -103,6 +122,10 @@ function audioBuildFilename(definition) {
}
function audioInject(definition, fields, mode) {
+ if (mode === 'disabled') {
+ return Promise.resolve(true);
+ }
+
const filename = audioBuildFilename(definition);
if (!filename) {
return Promise.resolve(true);