summaryrefslogtreecommitdiff
path: root/ext/fg/js/client.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js/client.js')
-rw-r--r--ext/fg/js/client.js27
1 files changed, 9 insertions, 18 deletions
diff --git a/ext/fg/js/client.js b/ext/fg/js/client.js
index 60aa6883..37377984 100644
--- a/ext/fg/js/client.js
+++ b/ext/fg/js/client.js
@@ -38,11 +38,6 @@ class Client {
window.addEventListener('keydown', this.onKeyDown.bind(this));
window.addEventListener('scroll', (e) => this.hidePopup());
window.addEventListener('resize', (e) => this.hidePopup());
-
- bgGetOptions((opts) => {
- this.setOptions(opts);
- bgGetState((state) => this.setEnabled(state === 'enabled'));
- });
}
onKeyDown(e) {
@@ -67,14 +62,10 @@ class Client {
}
}
- onBgMessage({name, value}, sender, callback) {
- switch (name) {
- case 'state':
- this.setEnabled(value === 'enabled');
- break;
- case 'options':
- this.setOptions(value);
- break;
+ onBgMessage({action, params}, sender, callback) {
+ const method = this['api_' + action];
+ if (typeof(method) === 'function') {
+ method.call(this, params);
}
callback();
@@ -159,16 +150,16 @@ class Client {
this.definitions = null;
}
- setEnabled(enabled) {
+ api_setOptions(opts) {
+ this.options = opts;
+ }
+
+ api_setEnabled(enabled) {
if (!(this.enabled = enabled)) {
this.hidePopup();
}
}
- setOptions(opts) {
- this.options = opts;
- }
-
api_addNote({index, mode}) {
const state = {};
state[mode] = false;