aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/client.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-07-23 15:14:13 -0700
committerAlex Yatskov <alex@foosoft.net>2016-07-23 15:14:13 -0700
commit22d73228ca2899047bcf39a6a2e7146d68c69e0a (patch)
tree51a95db8157688e16d6f877b9417a33ac68386b2 /ext/fg/js/client.js
parent6d9b4392e2cd78b5e76e3b47cc3b8ca76d37129b (diff)
Cleanup
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;