aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/frontend.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-08-09 13:27:21 -0400
committerGitHub <noreply@github.com>2020-08-09 13:27:21 -0400
commit6da02c6eee803756d9a9075bfde333eeb31ce64b (patch)
tree158d81b89ca99095c06db31c1ebc7bb46a57c33a /ext/fg/js/frontend.js
parent480e0e15e3109165d077c18985893d7cca79959e (diff)
document.js refactor (#719)
* Refactor document.js into a class * Move public functions first * Rename private functions * Rename * Rename argument * Use instance of DocumentUtil * Update tests * Refactor * Rename (test-)document.js to (test-)document-util.js
Diffstat (limited to 'ext/fg/js/frontend.js')
-rw-r--r--ext/fg/js/frontend.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 1214e74b..ccffbab6 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -17,12 +17,12 @@
/* global
* DOM
+ * DocumentUtil
* FrameOffsetForwarder
* PopupProxy
* TextScanner
* TextSourceElement
* api
- * docSentenceExtract
*/
class Frontend {
@@ -36,11 +36,13 @@ class Frontend {
this._lastShowPromise = Promise.resolve();
this._activeModifiers = new Set();
this._optionsUpdatePending = false;
+ this._documentUtil = new DocumentUtil();
this._textScanner = new TextScanner({
node: window,
ignoreElements: this._ignoreElements.bind(this),
ignorePoint: this._ignorePoint.bind(this),
- search: this._search.bind(this)
+ search: this._search.bind(this),
+ documentUtil: this._documentUtil
});
const {
@@ -432,7 +434,7 @@ class Frontend {
const {url} = optionsContext;
const sentenceExtent = this._options.anki.sentenceExt;
const layoutAwareScan = this._options.scanning.layoutAwareScan;
- const sentence = docSentenceExtract(textSource, sentenceExtent, layoutAwareScan);
+ const sentence = this._documentUtil.extractSentence(textSource, sentenceExtent, layoutAwareScan);
const query = textSource.text();
const details = {
focus,