From 0232325f960b1fbe41e03f74a46fb18a7abf33f7 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 26 May 2021 20:38:15 -0400 Subject: Refactor json audio source (#1711) * Move sources to the end of audio options object * Add custom-json audio source type * Add support for downloading custom-json * Remove customSourceType --- ext/js/display/display-audio.js | 7 ++++--- ext/js/display/display.js | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'ext/js/display') diff --git a/ext/js/display/display-audio.js b/ext/js/display/display-audio.js index d8553547..34e74004 100644 --- a/ext/js/display/display-audio.js +++ b/ext/js/display/display-audio.js @@ -116,7 +116,7 @@ class DisplayAudio { const {term, reading} = headword; const audioOptions = this._getAudioOptions(); - const {textToSpeechVoice, customSourceUrl, customSourceType, volume} = audioOptions; + const {textToSpeechVoice, customSourceUrl, volume} = audioOptions; if (!Array.isArray(sources)) { ({sources} = audioOptions); } @@ -131,7 +131,7 @@ class DisplayAudio { let audio; let title; let source = null; - const info = await this._createTermAudio(sources, sourceDetailsMap, term, reading, {textToSpeechVoice, customSourceUrl, customSourceType}); + const info = await this._createTermAudio(sources, sourceDetailsMap, term, reading, {textToSpeechVoice, customSourceUrl}); const valid = (info !== null); if (valid) { ({audio, source} = info); @@ -518,7 +518,8 @@ class DisplayAudio { ['jisho', 'Jisho.org', true], ['text-to-speech', 'Text-to-speech', ttsSupported], ['text-to-speech-reading', 'Text-to-speech (Kana reading)', ttsSupported], - ['custom', 'Custom', customSupported] + ['custom', 'Custom URL', customSupported], + ['custom-json', 'Custom URL (JSON)', customSupported] ]; const results = []; diff --git a/ext/js/display/display.js b/ext/js/display/display.js index bb089047..1c4602c5 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -1554,7 +1554,7 @@ class Display extends EventDispatcher { async _injectAnkiNoteMedia(dictionaryEntry, options, fields) { const { anki: {screenshot: {format, quality}}, - audio: {sources, customSourceUrl, customSourceType} + audio: {sources, customSourceUrl} } = options; const timestamp = Date.now(); @@ -1570,7 +1570,7 @@ class Display extends EventDispatcher { sources2 = [primaryCardAudio.source]; preferredAudioIndex = primaryCardAudio.index; } - audioDetails = {sources: sources2, preferredAudioIndex, customSourceUrl, customSourceType}; + audioDetails = {sources: sources2, preferredAudioIndex, customSourceUrl}; } const screenshotDetails = ( -- cgit v1.2.3