summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/fg/js/driver.js8
-rw-r--r--ext/fg/js/util.js8
-rw-r--r--ext/mixed/js/display.js8
-rw-r--r--ext/mixed/js/util.js8
4 files changed, 16 insertions, 16 deletions
diff --git a/ext/fg/js/driver.js b/ext/fg/js/driver.js
index 49147c8f..e94a4ac2 100644
--- a/ext/fg/js/driver.js
+++ b/ext/fg/js/driver.js
@@ -172,13 +172,13 @@ window.driver = new class {
} else {
textSource.setEndOffset(length);
- const cloze = docClozeExtract(textSource, this.options.anki.sentenceExt);
+ const sentence = docSentenceExtract(textSource, this.options.anki.sentenceExt);
const url = window.location.href;
this.popup.showTermDefs(
textSource.getRect(),
definitions,
this.options,
- {cloze, url}
+ {sentence, url}
);
this.lastTextSource = textSource;
@@ -198,13 +198,13 @@ window.driver = new class {
if (definitions.length === 0) {
return false;
} else {
- const cloze = docClozeExtract(textSource, this.options.anki.sentenceExt);
+ const sentence = docSentenceExtract(textSource, this.options.anki.sentenceExt);
const url = window.location.href;
this.popup.showKanjiDefs(
textSource.getRect(),
definitions,
this.options,
- {cloze, url}
+ {sentence, url}
);
this.lastTextSource = textSource;
diff --git a/ext/fg/js/util.js b/ext/fg/js/util.js
index 59060221..445efa5b 100644
--- a/ext/fg/js/util.js
+++ b/ext/fg/js/util.js
@@ -152,7 +152,7 @@ function docRangeFromPoint(point, imposter) {
return null;
}
-function docClozeExtract(source, extent) {
+function docSentenceExtract(source, extent) {
const quotesFwd = {'「': '」', '『': '』', "'": "'", '"': '"'};
const quotesBwd = {'」': '「', '』': '『', "'": "'", '"': '"'};
const terminators = '…。..??!!';
@@ -204,11 +204,11 @@ function docClozeExtract(source, extent) {
}
}
- const sentence = content.substring(startPos, endPos);
- const padding = sentence.length - sentence.replace(/^\s+/, '');
+ const text = content.substring(startPos, endPos);
+ const padding = text.length - text.replace(/^\s+/, '');
return {
- sentence: sentence.trim(),
+ text: text.trim(),
offset: position - startPos - padding
};
}
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index e77ca7da..973b7749 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 = clozeBuild(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 = clozeBuild(context.cloze);
+ definition.cloze = clozeBuild(context.sentence, definition.source);
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 aeeb830e..eae54f49 100644
--- a/ext/mixed/js/util.js
+++ b/ext/mixed/js/util.js
@@ -21,12 +21,12 @@
* Cloze
*/
-function clozeBuild(sentence, offset, source) {
+function clozeBuild(sentence, source) {
return {
- sentence: sentence.trim(),
- prefix: sentence.substring(0, offset).trim(),
+ sentence: sentence.text.trim(),
+ prefix: sentence.text.substring(0, sentence.offset).trim(),
body: source.trim(),
- suffix: sentence.substring(offset + source.length).trim()
+ suffix: sentence.text.substring(sentence.offset + source.length).trim()
};
}