summaryrefslogtreecommitdiff
path: root/ext/fg
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-07-18 08:08:31 -0700
committerAlex Yatskov <alex@foosoft.net>2016-07-18 08:08:31 -0700
commita567ef360523e71040348fdded761c6d71a6d4d5 (patch)
treef662ea0b4566c69c21418fd9e5f05c5b7504f078 /ext/fg
parentcea8471290d906cc268902e82704f8efad82fda6 (diff)
Pronounce => Play Audio
Diffstat (limited to 'ext/fg')
-rw-r--r--ext/fg/img/play_audio.png (renamed from ext/fg/img/pronounce.png)bin610 -> 610 bytes
-rw-r--r--ext/fg/js/client.js10
-rw-r--r--ext/fg/js/frame.js8
3 files changed, 11 insertions, 7 deletions
diff --git a/ext/fg/img/pronounce.png b/ext/fg/img/play_audio.png
index 6056d234..6056d234 100644
--- a/ext/fg/img/pronounce.png
+++ b/ext/fg/img/play_audio.png
Binary files 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) {