diff options
author | Alex Yatskov <alex@foosoft.net> | 2016-04-17 18:42:44 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2016-04-17 18:42:44 -0700 |
commit | de268e73a613b963ea982f34ca7439d57694facd (patch) | |
tree | 346778a33ca7ec0bd14867c1f744c9b1a24f0b3e /ext/fg/js | |
parent | 5bebf3ed2cff5c460afe6f0d3df56f26f12ae240 (diff) |
Rethinking dictionary switching
Diffstat (limited to 'ext/fg/js')
-rw-r--r-- | ext/fg/js/client.js | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/ext/fg/js/client.js b/ext/fg/js/client.js index 271caa58..09bd7d14 100644 --- a/ext/fg/js/client.js +++ b/ext/fg/js/client.js @@ -19,11 +19,11 @@ class Client { constructor() { - this.lastMosePos = null; - this.popupQuery = ''; - this.popupOffset = 10; - this.enabled = false; - this.options = null; + this.popupMousePos = null; + this.popupQuery = ''; + this.popupOffset = 10; + this.enabled = false; + this.options = {}; this.popup = document.createElement('iframe'); this.popup.classList.add('yomichan-popup'); @@ -40,29 +40,28 @@ class Client { window.addEventListener('resize', (e) => this.hidePopup()); getOptions((opts) => { - this.setDict('edict'); this.setOptions(opts); getState((state) => this.setEnabled(state === 'enabled')); }); } onKeyDown(e) { - if (this.enabled && this.lastMousePos !== null && (e.keyCode === 16 || e.charCode === 16)) { - this.searchAtPoint(this.lastMousePos); + if (this.enabled && this.popupMousePos !== null && (e.keyCode === 16 || e.charCode === 16)) { + this.searchAtPoint(this.popupMousePos); } } onMouseMove(e) { - this.lastMousePos = {x: e.clientX, y: e.clientY}; + this.popupMousePos = {x: e.clientX, y: e.clientY}; if (this.enabled && (e.shiftKey || e.which === 2)) { - this.searchAtPoint(this.lastMousePos); + this.searchAtPoint(this.popupMousePos); } } onMouseDown(e) { - this.lastMousePos = {x: e.clientX, y: e.clientY}; + this.popupMousePos = {x: e.clientX, y: e.clientY}; if (this.enabled && (e.shiftKey || e.which === 2)) { - this.searchAtPoint(this.lastMousePos); + this.searchAtPoint(this.popupMousePos); } else { this.hidePopup(); } @@ -82,12 +81,9 @@ class Client { } onFrameMessage(e) { - const {action, data} = e.data; - switch (action) { - case 'selectDict': - this.setDict(data); - break; - } + // const {action, data} = e.data; + // switch (action) { + // } } searchAtPoint(point) { @@ -167,11 +163,6 @@ class Client { setOptions(opts) { this.options = opts; } - - setDict(dict) { - this.dict = dict; - alert(dict); - } } window.yomiClient = new Client(); |