diff options
author | Alex Yatskov <alex@foosoft.net> | 2016-04-24 18:59:29 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2016-04-24 18:59:29 -0700 |
commit | cac6fc1427106420b28777d94907bf27ab1995a3 (patch) | |
tree | e8ab59bed16d7e2ba1ed887ffb2b9ccee510f9a9 /ext/fg/js/client.js | |
parent | a192a8d8b549d5979a427d86c51f94bb5f4be907 (diff) |
Basic kanji output
Diffstat (limited to 'ext/fg/js/client.js')
-rw-r--r-- | ext/fg/js/client.js | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/ext/fg/js/client.js b/ext/fg/js/client.js index 7f07d918..2355cf81 100644 --- a/ext/fg/js/client.js +++ b/ext/fg/js/client.js @@ -26,6 +26,7 @@ class Client { this.activateBtn = 2; this.enabled = false; this.options = {}; + this.fgRoot = chrome.extension.getURL('fg'); chrome.runtime.onMessage.addListener(this.onBgMessage.bind(this)); window.addEventListener('message', this.onFrameMessage.bind(this)); @@ -101,14 +102,8 @@ class Client { this.hidePopup(); } else { range.setLength(length); - - const params = { - defs: results, - root: chrome.extension.getURL('fg') - }; - renderText( - params, + {defs: results, root: this.fgRoot}, 'term-list.html', (content) => this.showPopup(range, content) ); @@ -116,6 +111,16 @@ class Client { }); } + displayKanji(kanji) { + findKanji(kanji, (results) => { + renderText( + {defs: results, root: this.fgRoot}, + 'kanji-list.html', + (content) => this.popup.setContent(content) + ); + }); + } + showPopup(range, content) { this.popup.showNextTo(range.getRect(), content); @@ -136,10 +141,6 @@ class Client { this.lastRange = null; } - displayKanji(kanji) { - this.popup.setContent(kanji); - } - setEnabled(enabled) { if (!(this.enabled = enabled)) { this.hidePopup(); |