diff options
author | Alex Yatskov <alex@foosoft.net> | 2016-05-02 20:40:41 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2016-05-02 20:40:41 -0700 |
commit | 57a426f4f277d1e5dac98b0427efcb43f5ab20e4 (patch) | |
tree | 7dda09e9d30f9973f2c1c2f75703a17a0ae454f4 /ext/bg/js/yomichan.js | |
parent | c70aedc2ff546cb6a8ed1401e8b5e3a0ca681c28 (diff) |
Plumbing
Diffstat (limited to 'ext/bg/js/yomichan.js')
-rw-r--r-- | ext/bg/js/yomichan.js | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js index a412eef7..32c12407 100644 --- a/ext/bg/js/yomichan.js +++ b/ext/bg/js/yomichan.js @@ -101,15 +101,23 @@ class Yomichan { findTerm(text, callback) { const results = this.translator.findTerm(text); - this.callAnkiApi('canAddNotes', results, (resultsFull) => { - callback(resultsFull || results); + this.callAnkiApi('canAddNotes', results.results, (definitions) => { + if (definitions !== null) { + results.results = definitions; + } + + callback(results); }); } findKanji(text, callback) { const results = this.translator.findKanji(text); - this.callAnkiApi('cannAddNotes', results, (resultsFull) => { - callback(resultsFull || results); + this.callAnkiApi('cannAddNotes', results.results, (definitions) => { + if (definitions !== null) { + results.results = definitions; + } + + callback(results); }); } @@ -120,7 +128,7 @@ class Yomichan { xhr.open('POST', 'http://127.0.0.1:8888'); xhr.withCredentials = true; xhr.setRequestHeader('Content-Type', 'text/json'); - xhr.send(JSON.stringify(data)); + xhr.send(JSON.stringify({action: action, data: data})); } else { callback(null); } |