diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-09-08 12:16:12 -0400 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-09-10 21:43:52 -0400 |
commit | 1f8c7358cb017e0c96a454d9e9a1f53eb6d4fe15 (patch) | |
tree | c8cf669de185896a329c59851b01d6e3236c0ed3 /ext/bg/js | |
parent | 36b39e2f6530bfba5019462313b29b90a2db2aec (diff) |
Create function for setting up form event listeners
Diffstat (limited to 'ext/bg/js')
-rw-r--r-- | ext/bg/js/settings.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js index 3c261b88..06dba538 100644 --- a/ext/bg/js/settings.js +++ b/ext/bg/js/settings.js @@ -121,9 +121,6 @@ async function formWrite(options) { $('#scan-modifier-key').val(options.scanning.modifier); $('#popup-nesting-max-depth').val(options.scanning.popupNestingMaxDepth); - $('#dict-purge-link').click(utilAsync(onDictionaryPurge)); - $('#dict-file').change(utilAsync(onDictionaryImport)); - $('#anki-enable').prop('checked', options.anki.enable); $('#card-tags').val(options.anki.tags.join(' ')); $('#sentence-detection-extent').val(options.anki.sentenceExt); @@ -131,9 +128,6 @@ async function formWrite(options) { $('#screenshot-format').val(options.anki.screenshot.format); $('#screenshot-quality').val(options.anki.screenshot.quality); $('#field-templates').val(options.anki.fieldTemplates); - $('#field-templates-reset').click(utilAsync(onAnkiFieldTemplatesReset)); - $('input, select, textarea').not('.anki-model').change(utilAsync(onFormOptionsChanged)); - $('.anki-model').change(utilAsync(onAnkiModelChanged)); try { await dictionaryGroupsPopulate(options); @@ -151,6 +145,15 @@ async function formWrite(options) { formUpdateVisibility(options); } +function formSetupEventListeners() { + $('#dict-purge-link').click(utilAsync(onDictionaryPurge)); + $('#dict-file').change(utilAsync(onDictionaryImport)); + + $('#field-templates-reset').click(utilAsync(onAnkiFieldTemplatesReset)); + $('input, select, textarea').not('.anki-model').not('.profile-form *').change(utilAsync(onFormOptionsChanged)); + $('.anki-model').change(utilAsync(onAnkiModelChanged)); +} + function formUpdateVisibility(options) { const general = $('#anki-general'); if (options.anki.enable) { @@ -237,6 +240,7 @@ async function onReady() { const optionsContext = getOptionsContext(); const options = await apiOptionsGet(optionsContext); + formSetupEventListeners(); await formWrite(options); storageInfoInitialize(); |