From c4b1a4a5b4811d7aaa70b3b83f740c9e3d2b86be Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Fri, 7 Apr 2017 21:17:13 -0700 Subject: wip --- ext/fg/js/driver.js | 8 ++++---- ext/fg/js/util.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'ext/fg/js') 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 }; } -- cgit v1.2.3