summaryrefslogtreecommitdiff
path: root/ext/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js')
-rw-r--r--ext/js/api.js8
-rw-r--r--ext/js/client.js9
2 files changed, 13 insertions, 4 deletions
diff --git a/ext/js/api.js b/ext/js/api.js
index 7f552a1e..c65b1702 100644
--- a/ext/js/api.js
+++ b/ext/js/api.js
@@ -29,8 +29,12 @@ function findKanji(text, callback) {
sendMessage('findKanji', {text: text}, callback);
}
-function renderTemplate(data, template, callback) {
- sendMessage('renderTemplate', {data: data, template: template}, callback);
+function renderText(data, template, callback) {
+ sendMessage('renderText', {data: data, template: template}, callback);
+}
+
+function getOptions(callback) {
+ sendMessage('getOptions', null, callback);
}
function getState(callback) {
diff --git a/ext/js/client.js b/ext/js/client.js
index 2c513187..3c75068c 100644
--- a/ext/js/client.js
+++ b/ext/js/client.js
@@ -37,7 +37,12 @@ class Client {
window.addEventListener('scroll', (e) => this.hidePopup());
window.addEventListener('resize', (e) => this.hidePopup());
- getState((state) => this.setEnabled(state === 'enabled'));
+ getOptions((opts) => {
+ this.setOptions(opts);
+ getState((state) => {
+ this.setEnabled(state === 'enabled');
+ });
+ });
}
onKeyDown(e) {
@@ -93,7 +98,7 @@ class Client {
this.hidePopup();
} else {
range.setEnd(range.endContainer, range.startOffset + length);
- renderTemplate({defs: results}, 'defs.html', (html) => {
+ renderText({defs: results}, 'defs.html', (html) => {
this.popup.innerHTML = html;
this.showPopup(range);
});