diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/bg/js/display-window.js | 4 | ||||
-rw-r--r-- | ext/fg/js/display-frame.js | 4 | ||||
-rw-r--r-- | ext/fg/js/driver.js | 18 | ||||
-rw-r--r-- | ext/mixed/js/display.js | 42 |
4 files changed, 30 insertions, 38 deletions
diff --git a/ext/bg/js/display-window.js b/ext/bg/js/display-window.js index 8c732ddd..ae97cd36 100644 --- a/ext/bg/js/display-window.js +++ b/ext/bg/js/display-window.js @@ -49,6 +49,10 @@ window.displayWindow = new class extends Display { window.alert(`Error: ${error}`); } + clearSearch() { + $('#query').focus().select(); + } + onSearch(e) { e.preventDefault(); $('#intro').slideUp(); diff --git a/ext/fg/js/display-frame.js b/ext/fg/js/display-frame.js index 8f15b1bc..d930d325 100644 --- a/ext/fg/js/display-frame.js +++ b/ext/fg/js/display-frame.js @@ -47,6 +47,10 @@ window.displayFrame = new class extends Display { } } + clearSearch() { + window.parent.postMessage('popupClose', '*'); + } + showOrphaned() { $('#content').hide(); $('#orphan').show(); diff --git a/ext/fg/js/driver.js b/ext/fg/js/driver.js index 5e17537e..7a56dd9c 100644 --- a/ext/fg/js/driver.js +++ b/ext/fg/js/driver.js @@ -46,14 +46,14 @@ window.driver = new class { } popupTimerClear() { - if (this.popupTimer !== null) { + if (this.popupTimer) { window.clearTimeout(this.popupTimer); this.popupTimer = null; } } onMouseOver(e) { - if (e.target === this.popup.container && this.popuptimer !== null) { + if (e.target === this.popup.container && this.popupTimer) { this.popupTimerClear(); } } @@ -106,14 +106,6 @@ window.driver = new class { const handlers = { popupClose: () => { this.searchClear(); - }, - - scanLeft: () => { - - }, - - scanRight: () => { - } }; @@ -147,11 +139,11 @@ window.driver = new class { } const textSource = docRangeFromPoint(point, this.options.scanning.imposter); - if (textSource === null || !textSource.containsPoint(point)) { + if (!textSource || !textSource.containsPoint(point)) { return; } - if (this.lastTextSource !== null && this.lastTextSource.equals(textSource)) { + if (this.lastTextSource && this.lastTextSource.equals(textSource)) { return; } @@ -225,7 +217,7 @@ window.driver = new class { docImposterDestroy(); this.popup.hide(); - if (this.options.scanning.selectText && this.lastTextSource !== null) { + if (this.options.scanning.selectText && this.lastTextSource) { this.lastTextSource.deselect(); } diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index 30f703bb..140185cc 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -50,6 +50,10 @@ class Display { throw 'override me'; } + clearSearch() { + throw 'override me'; + } + showTermDefs(definitions, options, context) { window.focus(); @@ -207,17 +211,13 @@ class Display { } onKeyDown(e) { - const notifyParent = action => { - window.parent.postMessage(action, '*'); - }; - const handlers = { - 36: /* home */ () => { - this.entryScroll(0, true); + 8: /* backspace */ () => { + }, - 35: /* end */ () => { - this.entryScroll(this.definitions.length - 1, true); + 27: /* escape */ () => { + this.clearSearch(); }, 33: /* page up */ () => { @@ -228,6 +228,14 @@ class Display { this.entryScroll(this.index + 3, true); }, + 35: /* end */ () => { + this.entryScroll(this.definitions.length - 1, true); + }, + + 36: /* home */ () => { + this.entryScroll(0, true); + }, + 38: /* up */ () => { this.entryScroll(this.index - 1, true); }, @@ -240,28 +248,12 @@ class Display { }, - 221: /* ] */ () => { - - }, - 220: /* \ */ () => { this.audioPlay(this.definitions[this.index]); }, - 8: /* backspace */ () => { - - }, - - 27: /* escape */ () => { - notifyParent('popupClose'); - }, - - 37: /* left */ () => { - notifyParent('scanLeft'); - }, + 221: /* ] */ () => { - 39: /* right */ () => { - notifyParent('scanRight'); } }; |