aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/frame.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-02-19 10:09:15 -0800
committerAlex Yatskov <alex@foosoft.net>2017-02-19 10:09:15 -0800
commit64db42d536318cc4b91ed5a7484de302db7979f4 (patch)
tree5b397c579f478600e7969585cbe9e9474de3813d /ext/fg/js/frame.js
parent1a52a2d8d5f5ea5c106ae244ca1e5bbf0da22b6e (diff)
switch to new ankiconnect interface
Diffstat (limited to 'ext/fg/js/frame.js')
-rw-r--r--ext/fg/js/frame.js34
1 files changed, 13 insertions, 21 deletions
diff --git a/ext/fg/js/frame.js b/ext/fg/js/frame.js
index 4f4a6378..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');
@@ -171,28 +180,11 @@ class Frame {
}
}
- let kana = definition.reading;
- let kanji = definition.expression;
- if (!kana) {
- if (!kanji) {
- return;
- }
-
- if (wanakana.isHiragana(kanji)) {
- kana = kanji;
- kanji = null;
- }
- }
-
- const params = [];
- if (kanji) {
- params.push(`kanji=${encodeURIComponent(kanji)}`);
- }
- if (kana) {
- params.push(`kana=${encodeURIComponent(kana)}`);
+ const url = buildAudioUrl(definition);
+ if (!url) {
+ return;
}
- const url = `https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?${params.join('&')}`;
let audio = this.audioCache[url];
if (audio) {
audio.currentTime = 0;