aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-05-22 22:27:09 -0700
committerAlex Yatskov <alex@foosoft.net>2017-05-22 22:27:09 -0700
commit48693fa5942b8dc908615f73f08ceac8937b8216 (patch)
tree2a02dc2183d99d3a57610a87359951b0308d4c6c /ext/fg/js
parentfd346ae44b75afa2a081d3ce270568258dd8390b (diff)
fix search for input controls
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/driver.js3
-rw-r--r--ext/fg/js/util.js8
2 files changed, 3 insertions, 8 deletions
diff --git a/ext/fg/js/driver.js b/ext/fg/js/driver.js
index e94a4ac2..98c50a02 100644
--- a/ext/fg/js/driver.js
+++ b/ext/fg/js/driver.js
@@ -144,6 +144,7 @@ window.driver = new class {
const textSource = docRangeFromPoint(point, this.options.scanning.imposter);
if (!textSource || !textSource.containsPoint(point)) {
+ docImposterDestroy();
return;
}
@@ -168,6 +169,7 @@ window.driver = new class {
return bgTermsFind(textSource.text()).then(({definitions, length}) => {
if (definitions.length === 0) {
+ docImposterDestroy();
return false;
} else {
textSource.setEndOffset(length);
@@ -186,6 +188,7 @@ window.driver = new class {
textSource.select();
}
+ docImposterDestroy();
return true;
}
});
diff --git a/ext/fg/js/util.js b/ext/fg/js/util.js
index e5705ffd..88d160cc 100644
--- a/ext/fg/js/util.js
+++ b/ext/fg/js/util.js
@@ -112,12 +112,6 @@ function docImposterDestroy() {
}
}
-function docImposterHide() {
- for (const element of document.getElementsByClassName('yomichan-imposter')) {
- element.style.visibility = 'hidden';
- }
-}
-
function docRangeFromPoint(point, imposter) {
const element = document.elementFromPoint(point.x, point.y);
if (element !== null) {
@@ -144,11 +138,9 @@ function docRangeFromPoint(point, imposter) {
const range = document.caretRangeFromPoint(point.x, point.y);
if (range !== null) {
- docImposterHide();
return new TextSourceRange(range);
}
- docImposterDestroy();
return null;
}