More cleanup

This commit is contained in:
Alex Yatskov 2016-05-28 15:21:01 -07:00
parent 9c51f2ecda
commit b229295688

View File

@ -55,6 +55,10 @@ function populateAnkiDeckAndModel(opts) {
names.forEach((name) => ankiDeck.append($('<option/>', {value: name, text: name}))); names.forEach((name) => ankiDeck.append($('<option/>', {value: name, text: name})));
} }
$('#anki-vocab-deck').val(opts.ankiVocabDeck);
$('#anki-kanji-deck').val(opts.ankiKanjiDeck);
}});
const ankiModel = $('.anki-model'); const ankiModel = $('.anki-model');
ankiModel.find('option').remove(); ankiModel.find('option').remove();
yomi.api_getModelNames({callback: (names) => { yomi.api_getModelNames({callback: (names) => {
@ -62,12 +66,9 @@ function populateAnkiDeckAndModel(opts) {
names.forEach((name) => ankiModel.append($('<option/>', {value: name, text: name}))); names.forEach((name) => ankiModel.append($('<option/>', {value: name, text: name})));
} }
$('#anki-vocab-deck').val(opts.ankiVocabDeck);
populateAnkiFields($('#anki-vocab-model').val(opts.ankiVocabModel), opts); populateAnkiFields($('#anki-vocab-model').val(opts.ankiVocabModel), opts);
$('#anki-kanji-deck').val(opts.ankiKanjiDeck);
populateAnkiFields($('#anki-kanji-model').val(opts.ankiKanjiModel), opts); populateAnkiFields($('#anki-kanji-model').val(opts.ankiKanjiModel), opts);
}}); }});
}});
} }
function populateAnkiFields(element, opts) { function populateAnkiFields(element, opts) {