diff options
author | Alex Yatskov <alex@foosoft.net> | 2017-02-19 14:18:25 -0800 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2017-02-19 14:18:25 -0800 |
commit | a1ba96145d7a98f851d85cac5be640a69662f954 (patch) | |
tree | 7781ce86de7c9fd8df62d21904cd2b38b8b60c36 /ext/fg/js/frame.js | |
parent | 76dd176706eddcdc605896093bb4efdfaeffa3c4 (diff) | |
parent | 5500ae27b24fc4242a5d180c129d649c3e992daa (diff) |
Merge branch 'dev'
Diffstat (limited to 'ext/fg/js/frame.js')
-rw-r--r-- | ext/fg/js/frame.js | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/ext/fg/js/frame.js b/ext/fg/js/frame.js index ca0636f9..1028f0f6 100644 --- a/ext/fg/js/frame.js +++ b/ext/fg/js/frame.js @@ -113,7 +113,16 @@ class Frame { const index = link.data('index'); const mode = link.data('mode'); - addDefinition(this.definitions[index], mode).then(success => { + const definition = this.definitions[index]; + if (mode !== 'kanji') { + const url = buildAudioUrl(definition); + const filename = buildAudioFilename(definition); + if (url && filename) { + definition.audio = {url, filename}; + } + } + + addDefinition(definition, mode).then(success => { if (success) { const button = this.findAddNoteButton(index, mode); button.addClass('disabled'); @@ -164,11 +173,6 @@ class Frame { } playAudio(definition) { - let url = `https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=${encodeURIComponent(definition.expression)}`; - if (definition.reading) { - url += `&kana=${encodeURIComponent(definition.reading)}`; - } - for (const key in this.audioCache) { const audio = this.audioCache[key]; if (audio !== null) { @@ -176,6 +180,11 @@ class Frame { } } + const url = buildAudioUrl(definition); + if (!url) { + return; + } + let audio = this.audioCache[url]; if (audio) { audio.currentTime = 0; |