aboutsummaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-05-21 18:07:57 -0700
committerAlex Yatskov <alex@foosoft.net>2016-05-21 18:07:57 -0700
commitf1850defa6c6bc288d978b098ee33387b1f989ce (patch)
tree59cb3ac7f971687235ecda927545b848667a09f0 /ext/bg
parent5f97e8d16a18873f2a4f3cac47d295280764a142 (diff)
Cleanup
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/options-form.js8
-rw-r--r--ext/bg/js/yomichan.js24
2 files changed, 16 insertions, 16 deletions
diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js
index 93755745..496fc91c 100644
--- a/ext/bg/js/options-form.js
+++ b/ext/bg/js/options-form.js
@@ -49,19 +49,19 @@ function updateAnkiFormData() {
const ankiDeck = $('#ankiDeck');
ankiDeck.find('option').remove();
- yomichan.api_getDeckNames((names) => {
+ yomichan.api_getDeckNames({callback: (names) => {
if (names !== null) {
names.forEach((name) => ankiDeck.append($('<option/>', {value: name, text: name})));
}
- });
+ }});
const ankiModel = $('#ankiModel');
ankiModel.find('option').remove();
- yomichan.api_getModelNames((names) => {
+ yomichan.api_getModelNames({callback: (names) => {
if (names !== null) {
names.forEach((name) => ankiModel.append($('<option/>', {value: name, text: name})));
}
- });
+ }});
}
function onOptionsChanged() {
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index bceaa6ca..0187f76f 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -50,11 +50,11 @@ class Yomichan {
}
onMessage(request, sender, callback) {
- const {action, params} = request;
- const method = this['api_' + action];
+ const {action, params} = request, method = this['api_' + action];
if (typeof(method) === 'function') {
- method.call(this, callback, params);
+ params.callback = callback;
+ method.call(this, params);
}
return true;
@@ -132,39 +132,39 @@ class Yomichan {
});
}
- api_addNote(callback, {definition, mode}) {
+ api_addNote({definition, mode, callback}) {
this.ankiInvoke('addNote', {definition: definition, mode: mode}, null, callback);
}
- api_canAddNotes(callback, {definitions, modes}) {
+ api_canAddNotes({definitions, modes, callback}) {
this.ankiInvoke('canAddNotes', {definitions: definitions, modes: modes}, 'notes', callback);
}
- api_findKanji(callback, text) {
+ api_findKanji({text, callback}) {
callback(this.translator.findKanji(text));
}
- api_findTerm(callback, text) {
+ api_findTerm({text, callback}) {
callback(this.translator.findTerm(text));
}
- api_getDeckNames(callback) {
+ api_getDeckNames({callback}) {
this.ankiInvoke('deckNames', {}, null, callback);
}
- api_getModelNames(callback) {
+ api_getModelNames({callback}) {
this.ankiInvoke('modelNames', {}, null, callback);
}
- api_getOptions(callback) {
+ api_getOptions({callback}) {
callback(this.options);
}
- api_getState(callback) {
+ api_getState({callback}) {
callback(this.state);
}
- api_renderText(callback, {template, data}) {
+ api_renderText({template, data, callback}) {
callback(Handlebars.templates[template](data));
}
}