aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-03-28 11:27:37 -0400
committerGitHub <noreply@github.com>2021-03-28 11:27:37 -0400
commit98994d0b6529e665863bc9f6125eb3e116e0f9d5 (patch)
tree6230d7f1e2fac0645b0483b590c7cb8dcd1db08b /ext
parent1664cc75f1afe6a98793b16a3b138537c4d144ef (diff)
Add playAudioFromSource hotkey (#1570)
Diffstat (limited to 'ext')
-rw-r--r--ext/js/display/display.js5
-rw-r--r--ext/js/pages/settings/keyboard-shortcuts-controller.js1
-rw-r--r--ext/settings.html13
3 files changed, 19 insertions, 0 deletions
diff --git a/ext/js/display/display.js b/ext/js/display/display.js
index b0805aca..3ae55da0 100644
--- a/ext/js/display/display.js
+++ b/ext/js/display/display.js
@@ -126,6 +126,7 @@ class Display extends EventDispatcher {
['addNoteTermKana', () => { this._tryAddAnkiNoteForSelectedDefinition('term-kana'); }],
['viewNote', () => { this._tryViewAnkiNoteForSelectedDefinition(); }],
['playAudio', () => { this._playAudioCurrent(); }],
+ ['playAudioFromSource', this._onHotkeyActionPlayAudioFromSource.bind(this)],
['copyHostSelection', () => this._copyHostSelection()],
['nextEntryDifferentDictionary', () => { this._focusEntryWithDifferentDictionary(1, true); }],
['previousEntryDifferentDictionary', () => { this._focusEntryWithDifferentDictionary(-1, true); }]
@@ -1830,6 +1831,10 @@ class Display extends EventDispatcher {
this._focusEntry(this._index + count * sign, true);
}
+ _onHotkeyActionPlayAudioFromSource(source) {
+ this._displayAudio.playAudio(this._index, 0, [source]);
+ }
+
_closeAllPopupMenus() {
for (const popupMenu of PopupMenu.openMenus) {
popupMenu.close();
diff --git a/ext/js/pages/settings/keyboard-shortcuts-controller.js b/ext/js/pages/settings/keyboard-shortcuts-controller.js
index a63430ee..7dbf5aa2 100644
--- a/ext/js/pages/settings/keyboard-shortcuts-controller.js
+++ b/ext/js/pages/settings/keyboard-shortcuts-controller.js
@@ -48,6 +48,7 @@ class KeyboardShortcutController {
['addNoteTermKana', {scopes: new Set(['popup', 'search'])}],
['viewNote', {scopes: new Set(['popup', 'search'])}],
['playAudio', {scopes: new Set(['popup', 'search'])}],
+ ['playAudioFromSource', {scopes: new Set(['popup', 'search']), argument: {template: 'hotkey-argument-audio-source', default: 'jpod101'}}],
['copyHostSelection', {scopes: new Set(['popup'])}],
['scanSelectedText', {scopes: new Set(['web'])}]
]);
diff --git a/ext/settings.html b/ext/settings.html
index 8a2c1308..e9f27751 100644
--- a/ext/settings.html
+++ b/ext/settings.html
@@ -3169,6 +3169,7 @@
<option value="addNoteTermKana">Add term note (reading)</option>
<option value="viewNote">View note</option>
<option value="playAudio">Play audio</option>
+ <option value="playAudioFromSource">Play audio from source</option>
<option value="copyHostSelection">Copy host window selection</option>
<option value="scanSelectedText">Scan selected text</option>
</select>
@@ -3220,6 +3221,18 @@
<input type="number" step="1" min="1" class="hotkey-argument-input">
</div></template>
+<template id="hotkey-argument-audio-source-template"><div class="flex-row-nowrap">
+ <span class="hotkey-argument-label">Source:</span>
+ <select class="audio-source-select hotkey-argument-input">
+ <option value="jpod101">JapanesePod101</option>
+ <option value="jpod101-alternate">JapanesePod101 (Alternate)</option>
+ <option value="jisho">Jisho.org</option>
+ <option value="text-to-speech">Text-to-speech</option>
+ <option value="text-to-speech-reading">Text-to-speech (Kana reading)</option>
+ <option value="custom">Custom</option>
+ </select>
+</div></template>
+
<!-- Scripts -->
<script src="/lib/jszip.min.js"></script>