summaryrefslogtreecommitdiff
path: root/ext/bg/js/options.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-05-02 12:50:16 -0400
committerGitHub <noreply@github.com>2020-05-02 12:50:16 -0400
commitcae6b657ab418a1cafedcb1cf72d0e793fa5178b (patch)
treec50f77c713aa3573cbcea713fcede188d9d536cd /ext/bg/js/options.js
parent08ada6844af424e8ff28e592fc6b9dbc1a9a97eb (diff)
Anki audio download (#477)
* Update how audio is added to Anki cards * Upgrade Anki templates * Update comments
Diffstat (limited to 'ext/bg/js/options.js')
-rw-r--r--ext/bg/js/options.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 8e1814ed..47101b49 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -108,6 +108,25 @@ const profileOptionsVersionUpdates = [
fieldTemplates += '\n\n{{#*inline "document-title"}}\n {{~context.document.title~}}\n{{/inline}}';
options.anki.fieldTemplates = fieldTemplates;
}
+ },
+ (options) => {
+ // Version 14 changes:
+ // Changed template for Anki audio.
+ let fieldTemplates = options.anki.fieldTemplates;
+ if (typeof fieldTemplates !== 'string') { return; }
+
+ const replacement = '{{#*inline "audio"~}}\n [sound:{{definition.audioFileName}}]\n{{~/inline}}';
+ let replaced = false;
+ fieldTemplates = fieldTemplates.replace(/\{\{#\*inline "audio"\}\}\{\{\/inline\}\}/g, () => {
+ replaced = true;
+ return replacement;
+ });
+
+ if (!replaced) {
+ fieldTemplates += '\n\n' + replacement;
+ }
+
+ options.anki.fieldTemplates = fieldTemplates;
}
];