diff options
author | Alex Yatskov <alex@foosoft.net> | 2016-04-17 18:38:29 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2016-04-17 18:38:29 -0700 |
commit | 5bebf3ed2cff5c460afe6f0d3df56f26f12ae240 (patch) | |
tree | b1e4d30eac7ca150fb1a0e38287b7b488869644f /ext/fg/js/client.js | |
parent | 52a8e2207c70573abd1e47cc8d019ba9e592a9dd (diff) |
Revert "Support switching between edict and enamdict"
This reverts commit f079db0471424a873f22315c7911571d467e97ad.
Diffstat (limited to 'ext/fg/js/client.js')
-rw-r--r-- | ext/fg/js/client.js | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/ext/fg/js/client.js b/ext/fg/js/client.js index aae051fa..271caa58 100644 --- a/ext/fg/js/client.js +++ b/ext/fg/js/client.js @@ -19,12 +19,11 @@ class Client { constructor() { - this.popupMousePos = null; - this.popupQuery = ''; - this.popupOffset = 10; - this.enabled = false; - this.options = {}; - this.activeDict = ''; + this.lastMosePos = null; + this.popupQuery = ''; + this.popupOffset = 10; + this.enabled = false; + this.options = null; this.popup = document.createElement('iframe'); this.popup.classList.add('yomichan-popup'); @@ -41,29 +40,29 @@ class Client { window.addEventListener('resize', (e) => this.hidePopup()); getOptions((opts) => { - this.setActiveDict('edict'); + this.setDict('edict'); this.setOptions(opts); getState((state) => this.setEnabled(state === 'enabled')); }); } onKeyDown(e) { - if (this.enabled && this.popupMousePos !== null && (e.keyCode === 16 || e.charCode === 16)) { - this.searchAtPoint(this.popupMousePos); + if (this.enabled && this.lastMousePos !== null && (e.keyCode === 16 || e.charCode === 16)) { + this.searchAtPoint(this.lastMousePos); } } onMouseMove(e) { - this.popupMousePos = {x: e.clientX, y: e.clientY}; + this.lastMousePos = {x: e.clientX, y: e.clientY}; if (this.enabled && (e.shiftKey || e.which === 2)) { - this.searchAtPoint(this.popupMousePos); + this.searchAtPoint(this.lastMousePos); } } onMouseDown(e) { - this.popupMousePos = {x: e.clientX, y: e.clientY}; + this.lastMousePos = {x: e.clientX, y: e.clientY}; if (this.enabled && (e.shiftKey || e.which === 2)) { - this.searchAtPoint(this.popupMousePos); + this.searchAtPoint(this.lastMousePos); } else { this.hidePopup(); } @@ -85,8 +84,8 @@ class Client { onFrameMessage(e) { const {action, data} = e.data; switch (action) { - case 'setActiveDict': - this.setActiveDict(data); + case 'selectDict': + this.setDict(data); break; } } @@ -114,11 +113,11 @@ class Client { return; } - findTerm(popupQuery, this.activeDict, ({results, length}) => { + findTerm(popupQuery, ({results, length}) => { if (length === 0) { this.hidePopup(); } else { - const params = {defs: results, root: chrome.extension.getURL('fg'), activeDict: this.activeDict}; + const params = {defs: results, root: chrome.extension.getURL('fg')}; renderText(params, 'term-list.html', (html) => this.showPopup(range, html, popupQuery, length)); } }); @@ -169,8 +168,9 @@ class Client { this.options = opts; } - setActiveDict(activeDict) { - this.activeDict = activeDict; + setDict(dict) { + this.dict = dict; + alert(dict); } } |