aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-10-19 20:57:08 -0700
committerAlex Yatskov <alex@foosoft.net>2016-10-19 20:57:08 -0700
commit7618b8e90904e354f43d3447363e2c5a1f98d357 (patch)
tree89a0a7fb7141eca2e7b73868d4dc3da8eb08cf4c /ext/bg/js
parent055174efd2955464b21c653bfa3ed889e9d03e69 (diff)
Cleanup
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/yomichan.js46
1 files changed, 25 insertions, 21 deletions
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index 0e39d3e8..416a4911 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -231,28 +231,44 @@ class Yomichan {
}
api_getEnabled({callback}) {
- callback(this.state === 'enabled');
+ callback(this.state === 'enabled', null);
}
api_getOptions({callback}) {
- loadOptions().then(opts => callback(opts)).catch(() => callback(null));
+ loadOptions().then(result => {
+ callback(result, null);
+ }).catch(error => {
+ callback(null, error);
+ });
}
api_findKanji({text, callback}) {
- this.translator.findKanji(text).then(result => callback(result)).catch(() => callback(null));
+ this.translator.findKanji(text).then(result => {
+ callback(result, null);
+ }).catch(error => {
+ callback(null, error);
+ });
}
api_findTerm({text, callback}) {
- this.translator.findTerm(text).then(result => callback(result)).catch(() => callback(null));
+ this.translator.findTerm(text).then(result => {
+ callback(result, null);
+ }).catch(error => {
+ callback(null, error);
+ });
}
api_renderText({template, data, callback}) {
- callback(Handlebars.templates[template](data));
+ callback(Handlebars.templates[template](data), null);
}
api_addDefinition({definition, mode, callback}) {
const note = this.formatNote(definition, mode);
- this.anki.addNote(note).then(callback).catch(() => callback(null));
+ this.anki.addNote(note).then(result => {
+ callback(result, null);
+ }).catch(error => {
+ callback(null, error);
+ });
}
api_canAddDefinitions({definitions, modes, callback}) {
@@ -276,23 +292,11 @@ class Yomichan {
}
}
- callback(states);
- }).catch(() => {
- callback(null);
+ callback(states, null);
+ }).catch(error => {
+ callback(null, error);
});
}
-
- api_getDeckNames({callback}) {
- this.anki.getDeckNames().then(callback).catch(() => callback(null));
- }
-
- api_getModelNames({callback}) {
- this.anki.getModelNames().then(callback).catch(() => callback(null));
- }
-
- api_getModelFieldNames({modelName, callback}) {
- this.anki.getModelFieldNames(modelName).then(callback).catch(() => callback(null));
- }
}
window.yomichan = new Yomichan();