aboutsummaryrefslogtreecommitdiff
path: root/ext/bg
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
parent055174efd2955464b21c653bfa3ed889e9d03e69 (diff)
Cleanup
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/yomichan.js46
-rw-r--r--ext/bg/options.html7
2 files changed, 29 insertions, 24 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();
diff --git a/ext/bg/options.html b/ext/bg/options.html
index 2b2e283b..73e3b790 100644
--- a/ext/bg/options.html
+++ b/ext/bg/options.html
@@ -59,9 +59,10 @@
</div>
<div>
- <img src="img/spinner.gif" class="pull-right" id="anki-spinner" alt>
-
- <h3>Anki Options</h3>
+ <div>
+ <img src="img/spinner.gif" class="pull-right" id="anki-spinner" alt>
+ <h3>Anki Options</h3>
+ </div>
<div class="alert alert-danger" id="anki-error">
<strong>Error:</strong>