summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-03-25 15:22:28 -0700
committerAlex Yatskov <alex@foosoft.net>2017-03-25 15:22:28 -0700
commit90eaae1725511bbc039f84f684b7b080e0fa2d44 (patch)
treee7a5a783dc9e94ac7d1d2bb2471d093df9b5b95b /ext
parent4a232151e065400495ec2ed0ca57dff8da84c4b7 (diff)
wip
Diffstat (limited to 'ext')
-rw-r--r--ext/fg/js/driver.js22
-rw-r--r--ext/mixed/js/display.js16
2 files changed, 38 insertions, 0 deletions
diff --git a/ext/fg/js/driver.js b/ext/fg/js/driver.js
index 16b12d5e..5e17537e 100644
--- a/ext/fg/js/driver.js
+++ b/ext/fg/js/driver.js
@@ -35,6 +35,7 @@ window.driver = new class {
window.addEventListener('mouseup', this.onMouseUp.bind(this));
window.addEventListener('mousemove', this.onMouseMove.bind(this));
window.addEventListener('resize', e => this.searchClear());
+ window.addEventListener('message', this.onFrameMessage.bind(this));
chrome.runtime.onMessage.addListener(this.onBgMessage.bind(this));
}).catch(this.handleError.bind(this));
}
@@ -101,6 +102,27 @@ window.driver = new class {
}
}
+ onFrameMessage(e) {
+ const handlers = {
+ popupClose: () => {
+ this.searchClear();
+ },
+
+ scanLeft: () => {
+
+ },
+
+ scanRight: () => {
+
+ }
+ };
+
+ const handler = handlers[e.data];
+ if (handler) {
+ handler();
+ }
+ }
+
onBgMessage({action, params}, sender, callback) {
const handlers = new class {
api_optionsSet(options) {
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index f3423878..30f703bb 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -207,6 +207,10 @@ class Display {
}
onKeyDown(e) {
+ const notifyParent = action => {
+ window.parent.postMessage(action, '*');
+ };
+
const handlers = {
36: /* home */ () => {
this.entryScroll(0, true);
@@ -246,6 +250,18 @@ class Display {
8: /* backspace */ () => {
+ },
+
+ 27: /* escape */ () => {
+ notifyParent('popupClose');
+ },
+
+ 37: /* left */ () => {
+ notifyParent('scanLeft');
+ },
+
+ 39: /* right */ () => {
+ notifyParent('scanRight');
}
};