Simplify how anki templates are reset

This commit is contained in:
toasted-nutbread 2019-12-01 21:08:46 -05:00
parent 767a480a84
commit 3e1b080cd3

View File

@ -22,22 +22,14 @@ function onAnkiFieldTemplatesReset(e) {
$('#field-template-reset-modal').modal('show');
}
async function onAnkiFieldTemplatesResetConfirm(e) {
try {
function onAnkiFieldTemplatesResetConfirm(e) {
e.preventDefault();
$('#field-template-reset-modal').modal('hide');
const optionsContext = getOptionsContext();
const options = await apiOptionsGet(optionsContext);
const fieldTemplates = profileOptionsGetDefaultFieldTemplates();
options.anki.fieldTemplates = fieldTemplates;
$('#field-templates').val(fieldTemplates);
onAnkiTemplatesValidateCompile();
await settingsSaveOptions();
} catch (error) {
ankiErrorShow(error);
}
const element = document.querySelector('#field-templates');
element.value = profileOptionsGetDefaultFieldTemplates();
element.dispatchEvent(new Event('change'));
}
function ankiTemplatesInitialize() {