This commit is contained in:
Alex Yatskov 2016-05-02 20:40:41 -07:00
parent c70aedc2ff
commit 57a426f4f2

View File

@ -101,15 +101,23 @@ class Yomichan {
findTerm(text, callback) { findTerm(text, callback) {
const results = this.translator.findTerm(text); const results = this.translator.findTerm(text);
this.callAnkiApi('canAddNotes', results, (resultsFull) => { this.callAnkiApi('canAddNotes', results.results, (definitions) => {
callback(resultsFull || results); if (definitions !== null) {
results.results = definitions;
}
callback(results);
}); });
} }
findKanji(text, callback) { findKanji(text, callback) {
const results = this.translator.findKanji(text); const results = this.translator.findKanji(text);
this.callAnkiApi('cannAddNotes', results, (resultsFull) => { this.callAnkiApi('cannAddNotes', results.results, (definitions) => {
callback(resultsFull || results); if (definitions !== null) {
results.results = definitions;
}
callback(results);
}); });
} }
@ -120,7 +128,7 @@ class Yomichan {
xhr.open('POST', 'http://127.0.0.1:8888'); xhr.open('POST', 'http://127.0.0.1:8888');
xhr.withCredentials = true; xhr.withCredentials = true;
xhr.setRequestHeader('Content-Type', 'text/json'); xhr.setRequestHeader('Content-Type', 'text/json');
xhr.send(JSON.stringify(data)); xhr.send(JSON.stringify({action: action, data: data}));
} else { } else {
callback(null); callback(null);
} }