From a567ef360523e71040348fdded761c6d71a6d4d5 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 18 Jul 2016 08:08:31 -0700 Subject: Pronounce => Play Audio --- ext/bg/js/templates.js | 4 ++-- ext/fg/img/play_audio.png | Bin 0 -> 610 bytes ext/fg/img/pronounce.png | Bin 610 -> 0 bytes ext/fg/js/client.js | 10 +++++++--- ext/fg/js/frame.js | 8 ++++---- ext/manifest.json | 2 +- 6 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 ext/fg/img/play_audio.png delete mode 100644 ext/fg/img/pronounce.png (limited to 'ext') diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js index 11529eff..079389f2 100644 --- a/ext/bg/js/templates.js +++ b/ext/bg/js/templates.js @@ -104,11 +104,11 @@ templates['term.html'] = template({"1":function(container,depth0,helpers,partial },"2":function(container,depth0,helpers,partials,data,blockParams,depths) { var helper, alias1=container.escapeExpression; - return " \n"; + + "/img/play_audio.png\">\n"; },"4":function(container,depth0,helpers,partials,data,blockParams,depths) { var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression, alias5=container.lambda; diff --git a/ext/fg/img/play_audio.png b/ext/fg/img/play_audio.png new file mode 100644 index 00000000..6056d234 Binary files /dev/null and b/ext/fg/img/play_audio.png differ diff --git a/ext/fg/img/pronounce.png b/ext/fg/img/pronounce.png deleted file mode 100644 index 6056d234..00000000 Binary files a/ext/fg/img/pronounce.png and /dev/null differ diff --git a/ext/fg/js/client.js b/ext/fg/js/client.js index 1f77ed95..10e8a0ae 100644 --- a/ext/fg/js/client.js +++ b/ext/fg/js/client.js @@ -168,9 +168,13 @@ class Client { }); } - api_pronounce(index) { - const dfn = this.definitions[index]; - const url = `http://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kana=${dfn.reading}&kanji=${dfn.expression}`; + api_playAudio(index) { + const definition = this.definitions[index]; + + let url = `https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=${definition.expression}`; + if (definition.reading) { + url += `&kana=${definition.reading}`; + } for (let key in this.audio) { this.audio[key].pause(); diff --git a/ext/fg/js/frame.js b/ext/fg/js/frame.js index 9c4b9318..165a9795 100644 --- a/ext/fg/js/frame.js +++ b/ext/fg/js/frame.js @@ -36,12 +36,12 @@ function registerAddNoteLinks() { } } -function registerPronounceLinks() { - for (let link of [].slice.call(document.getElementsByClassName('action-pronounce'))) { +function registerAudioLinks() { + for (let link of [].slice.call(document.getElementsByClassName('action-play-audio'))) { link.addEventListener('click', (e) => { e.preventDefault(); const ds = e.currentTarget.dataset; - window.parent.postMessage({action: 'pronounce', params: ds.index}, '*'); + window.parent.postMessage({action: 'playAudio', params: ds.index}, '*'); }); } } @@ -49,7 +49,7 @@ function registerPronounceLinks() { function onDomContentLoaded() { registerKanjiLinks(); registerAddNoteLinks(); - registerPronounceLinks(); + registerAudioLinks(); } function onMessage(e) { diff --git a/ext/manifest.json b/ext/manifest.json index 0c315fa4..5234ed5d 100644 --- a/ext/manifest.json +++ b/ext/manifest.json @@ -24,7 +24,7 @@ "fg/img/add_kanji.png", "fg/img/add_vocab_kana.png", "fg/img/add_vocab_kanji.png", - "fg/img/pronounce.png", + "fg/img/play_audio.png", "fg/js/frame.js", "fg/ttf/kanji-stroke-orders.ttf", "fg/ttf/vl-gothic-regular.ttf" -- cgit v1.2.3