aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/settings.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-09-06 13:18:06 -0700
committerAlex Yatskov <alex@foosoft.net>2017-09-06 13:18:06 -0700
commita3c8508031a1073629803d0616a2ee416cd3cccc (patch)
treebd7f2525f68724ac1be82f6a9a8449c9e77ce208 /ext/bg/js/settings.js
parent083999212e262c0a51b9401cb9666e6a49e35de9 (diff)
work on sandbox
Diffstat (limited to 'ext/bg/js/settings.js')
-rw-r--r--ext/bg/js/settings.js18
1 files changed, 15 insertions, 3 deletions
diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js
index c029b30b..d4e6ab17 100644
--- a/ext/bg/js/settings.js
+++ b/ext/bg/js/settings.js
@@ -41,9 +41,9 @@ async function formRead() {
optionsNew.anki.enable = $('#anki-enable').prop('checked');
optionsNew.anki.tags = $('#card-tags').val().split(/[,; ]+/);
- optionsNew.anki.htmlCards = $('#generate-html-cards').prop('checked');
optionsNew.anki.sentenceExt = parseInt($('#sentence-detection-extent').val(), 10);
optionsNew.anki.server = $('#interface-server').val();
+ optionsNew.anki.fieldTemplates = $('#field-templates').val();
if (optionsOld.anki.enable && !ankiErrorShown()) {
optionsNew.anki.terms.deck = $('#anki-terms-deck').val();
@@ -143,10 +143,11 @@ async function onReady() {
$('#anki-enable').prop('checked', options.anki.enable);
$('#card-tags').val(options.anki.tags.join(' '));
- $('#generate-html-cards').prop('checked', options.anki.htmlCards);
$('#sentence-detection-extent').val(options.anki.sentenceExt);
$('#interface-server').val(options.anki.server);
- $('input, select').not('.anki-model').change(utilAsync(onFormOptionsChanged));
+ $('#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 {
@@ -429,3 +430,14 @@ async function onAnkiModelChanged(e) {
ankiSpinnerShow(false);
}
}
+
+async function onAnkiFieldTemplatesReset(e) {
+ try {
+ e.preventDefault();
+ const options = await optionsLoad();
+ $('#field-templates').val(options.anki.fieldTemplates = optionsFieldTemplates());
+ await optionsSave(options);
+ } catch (e) {
+ ankiErrorShow(e);
+ }
+}