aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/client.js23
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();