diff options
author | Alex Yatskov <alex@foosoft.net> | 2016-07-17 10:35:16 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2016-07-17 10:35:16 -0700 |
commit | 09ec4af3c17c44302b9489379001cdfb9af761d7 (patch) | |
tree | 5681ab413018284c7065ab6c7deea0a9ac42deb9 | |
parent | f2bd0ec7bb7cd8abf351868929261026429c383a (diff) |
Audio support
-rw-r--r-- | ext/bg/js/yomichan.js | 20 | ||||
-rw-r--r-- | ext/bg/options.html | 2 |
2 files changed, 21 insertions, 1 deletions
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js index 9d03aff6..e8bd07b6 100644 --- a/ext/bg/js/yomichan.js +++ b/ext/bg/js/yomichan.js @@ -152,6 +152,7 @@ class Yomichan { formatField(field, definition, mode) { const tags = [ + 'audio', 'character', 'expression', 'glossary', @@ -165,6 +166,9 @@ class Yomichan { for (let tag of tags) { let value = definition[tag] || null; switch (tag) { + case 'audio': + value = ''; + break; case 'expression': if (mode === 'vocab_kana' && definition.reading) { value = definition.reading; @@ -213,6 +217,22 @@ class Yomichan { fields = this.options.ankiVocabFields; note.deckName = this.options.ankiVocabDeck; note.modelName = this.options.ankiVocabModel; + + const audio = { + kanji: definition.expression, + kana: definition.reading, + fields: [] + }; + + for (let name in fields) { + if (fields[name].indexOf('{audio}') !== -1) { + audio.fields.push(name); + } + } + + if (audio.fields.length > 0) { + note.audio = audio; + } } for (let name in fields) { diff --git a/ext/bg/options.html b/ext/bg/options.html index 1200b6c0..b856d7fa 100644 --- a/ext/bg/options.html +++ b/ext/bg/options.html @@ -124,7 +124,7 @@ </tbody> </table> - <p>Allowed tags: <code>{expression}</code>, <code>{reading}</code>, <code>{glossary}</code>, <code>{glossary-list}</code>, <code>{tags}</code></p> + <p>Allowed tags: <code>{audio}</code>, <code>{expression}</code>, <code>{reading}</code>, <code>{glossary}</code>, <code>{glossary-list}</code>, <code>{tags}</code></p> </div> <div id="kanji" class="tab-pane fade"> |