From 64db42d536318cc4b91ed5a7484de302db7979f4 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 19 Feb 2017 10:09:15 -0800 Subject: switch to new ankiconnect interface --- ext/bg/js/ankiconnect.js | 2 +- ext/bg/js/yomichan.js | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/ankiconnect.js b/ext/bg/js/ankiconnect.js index f6f94329..3a6e3690 100644 --- a/ext/bg/js/ankiconnect.js +++ b/ext/bg/js/ankiconnect.js @@ -20,7 +20,7 @@ class AnkiConnect { constructor(server) { this.server = server; this.asyncPools = {}; - this.localVersion = 1; + this.localVersion = 2; this.remoteVersion = null; } diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js index 80a67588..4c70bf0f 100644 --- a/ext/bg/js/yomichan.js +++ b/ext/bg/js/yomichan.js @@ -100,20 +100,23 @@ class Yomichan { note.deckName = this.options.anki.terms.deck; note.modelName = this.options.anki.terms.model; - const audio = { - kanji: definition.expression, - kana: definition.reading, - fields: [] - }; - - for (const name in fields) { - if (fields[name].includes('{audio}')) { - audio.fields.push(name); + if (definition.audio) { + const audio = { + url: definition.audio.url, + filename: definition.audio.filename, + skipHash: '7e2c2f954ef6051373ba916f000168dc', + fields: [] + }; + + for (const name in fields) { + if (fields[name].includes('{audio}')) { + audio.fields.push(name); + } } - } - if (audio.fields.length > 0) { - note.audio = audio; + if (audio.fields.length > 0) { + note.audio = audio; + } } } -- cgit v1.2.3