diff options
author | Alex Yatskov <alex@foosoft.net> | 2016-05-21 17:11:17 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2016-05-21 17:11:17 -0700 |
commit | ad54735a80ede1980eca4ab51273256c5fd8d3bd (patch) | |
tree | 8a30901eb2ed5766da6d49b78ea5421313878878 /ext/bg/js/yomichan.js | |
parent | 8b4d19c9f2d35ef53bbd8543f1d39f95c355bf12 (diff) |
WIP
Diffstat (limited to 'ext/bg/js/yomichan.js')
-rw-r--r-- | ext/bg/js/yomichan.js | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js index 14d311c0..88280ab0 100644 --- a/ext/bg/js/yomichan.js +++ b/ext/bg/js/yomichan.js @@ -51,19 +51,29 @@ class Yomichan { onMessage(request, sender, callback) { const {action, params} = request, handlers = { - canAddNotes: ({definitions, modes}) => this.ankiInvoke('canAddNotes', {definitions: definitions, modes: modes}, 'notes', callback), - addNote: ({definition, mode}) => this.ankiInvoke('addNote', {definition: definition, mode: mode}, null, callback), - findKanji: (text) => callback(this.translator.findKanji(text)), - findTerm: (text) => callback(this.translator.findTerm(text)), - getOptions: () => callback(this.options), - getState: () => callback(this.state), - renderText: ({data, template}) => callback(Handlebars.templates[template](data)) + addNote: ({definition, mode}) => this.ankiInvoke('addNote', {definition: definition, mode: mode}, null, callback), + canAddNotes: ({definitions, modes}) => this.ankiInvoke('canAddNotes', {definitions: definitions, modes: modes}, 'notes', callback), + findKanji: (text) => callback(this.translator.findKanji(text)), + findTerm: (text) => callback(this.translator.findTerm(text)), + getDeckNames: () => this.getDeckNames(callback), + getModelNames: () => this.getModelNames(callback), + getOptions: () => callback(this.options), + getState: () => callback(this.state), + renderText: ({data, template}) => callback(Handlebars.templates[template](data)) }; handlers[action].call(this, params); return true; } + getDeckNames(callback) { + this.ankiInvoke('deckNames', {}, null, callback); + } + + getModelNames(callback) { + this.ankiInvoke('modelNames', {}, null, callback); + } + onBrowserAction(tab) { switch (this.state) { case 'disabled': |