summaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-03-26 22:42:17 -0700
committerAlex Yatskov <alex@foosoft.net>2017-03-26 22:42:17 -0700
commit3b0aa88de11427c841f85e860aef91ff5d5c793d (patch)
treea04266ff528dbf9ce19f7ab1ceb9ffe0ee5f6c29 /ext/bg
parent5de3005d0b9ce8dc30e6e1d8d869c57876ca136f (diff)
cleanup
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/yomichan.js32
1 files changed, 16 insertions, 16 deletions
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index cbbcae63..7a26d6c7 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -189,37 +189,37 @@ window.yomichan = new class {
}
}
- onMessage(request, sender, callback) {
- const handlers = new class {
- optionsGet({callback}) {
+ onMessage({action, params}, sender, callback) {
+ const handlers = {
+ optionsGet: ({callback}) => {
promiseCallback(optionsLoad(), callback);
- }
+ },
- kanjiFind({text, callback}) {
+ kanjiFind: ({text, callback}) => {
promiseCallback(this.kanjiFind(text), callback);
- }
+ },
- termsFind({text, callback}) {
+ termsFind: ({text, callback}) => {
promiseCallback(this.termsFind(text), callback);
- }
+ },
- templateRender({template, data, callback}) {
+ templateRender: ({template, data, callback}) => {
promiseCallback(this.templateRender(template, data), callback);
- }
+ },
- definitionAdd({definition, mode, callback}) {
+ definitionAdd: ({definition, mode, callback}) => {
promiseCallback(this.definitionAdd(definition, mode), callback);
- }
+ },
- definitionsAddable({definitions, modes, callback}) {
+ definitionsAddable: ({definitions, modes, callback}) => {
promiseCallback(this.definitionsAddable(definitions, modes), callback);
}
};
- const {action, params} = request, method = handlers[action];
- if (typeof(method) === 'function') {
+ const handler = handlers[action];
+ if (handler) {
params.callback = callback;
- method.call(this, params);
+ handler(params);
}
return true;