aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/dictionary.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r--ext/bg/js/dictionary.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index 73efe7d1..6f9b30e4 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -231,3 +231,43 @@ function dictFieldFormat(field, definition, mode, options) {
return field;
}
+
+function dictNoteFormat(definition, mode, options) {
+ const note = {fields: {}, tags: options.anki.tags};
+ let fields = [];
+
+ if (mode === 'kanji') {
+ fields = options.anki.kanji.fields;
+ note.deckName = options.anki.kanji.deck;
+ note.modelName = options.anki.kanji.model;
+ } else {
+ fields = options.anki.terms.fields;
+ note.deckName = options.anki.terms.deck;
+ note.modelName = options.anki.terms.model;
+
+ if (definition.audio) {
+ const audio = {
+ url: definition.audio.url,
+ filename: definition.audio.filename,
+ skipHash: '7e2c2f954ef6051373ba916f000168dc',
+ fields: []
+ };
+
+ for (const name in fields) {
+ if (fields[name].includes('{audio}')) {
+ audio.fields.push(name);
+ }
+ }
+
+ if (audio.fields.length > 0) {
+ note.audio = audio;
+ }
+ }
+ }
+
+ for (const name in fields) {
+ note.fields[name] = dictFieldFormat(fields[name], definition, mode, options);
+ }
+
+ return note;
+}