diff options
author | Alex Yatskov <alex@foosoft.net> | 2016-07-18 08:08:31 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2016-07-18 08:08:31 -0700 |
commit | a567ef360523e71040348fdded761c6d71a6d4d5 (patch) | |
tree | f662ea0b4566c69c21418fd9e5f05c5b7504f078 | |
parent | cea8471290d906cc268902e82704f8efad82fda6 (diff) |
Pronounce => Play Audio
-rw-r--r-- | ext/bg/js/templates.js | 4 | ||||
-rw-r--r-- | ext/fg/img/play_audio.png (renamed from ext/fg/img/pronounce.png) | bin | 610 -> 610 bytes | |||
-rw-r--r-- | ext/fg/js/client.js | 10 | ||||
-rw-r--r-- | ext/fg/js/frame.js | 8 | ||||
-rw-r--r-- | ext/manifest.json | 2 | ||||
-rw-r--r-- | tmpl/term.html | 2 |
6 files changed, 15 insertions, 11 deletions
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 " <a href=\"#\" title=\"Pronounce\" class=\"action-pronounce\" data-index=\"" + return " <a href=\"#\" title=\"Play audio\" class=\"action-play-audio\" data-index=\"" + alias1(((helper = (helper = helpers.index || (data && data.index)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"index","hash":{},"data":data}) : helper))) + "\"><img src=\"" + alias1(container.lambda((depths[1] != null ? depths[1].root : depths[1]), depth0)) - + "/img/pronounce.png\"></a>\n"; + + "/img/play_audio.png\"></a>\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/pronounce.png b/ext/fg/img/play_audio.png Binary files differindex 6056d234..6056d234 100644 --- a/ext/fg/img/pronounce.png +++ b/ext/fg/img/play_audio.png 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" diff --git a/tmpl/term.html b/tmpl/term.html index 6296a2f3..1bb79375 100644 --- a/tmpl/term.html +++ b/tmpl/term.html @@ -2,7 +2,7 @@ {{#with options}} <div class="action-bar" data-sequence="{{../sequence}}"> {{#if enableAudioPlayback}} - <a href="#" title="Pronounce" class="action-pronounce" data-index="{{@index}}"><img src="{{../root}}/img/pronounce.png"></a> + <a href="#" title="Play audio" class="action-play-audio" data-index="{{@index}}"><img src="{{../root}}/img/play_audio.png"></a> {{/if}} {{#if enableAnkiConnect}} <a href="#" title="Add term as expression" class="action-add-note disabled" data-mode="vocab_kanji" data-index="{{@index}}"><img src="{{../root}}/img/add_vocab_kanji.png"></a> |