aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/settings.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-09-11 16:56:27 -0700
committerAlex Yatskov <alex@foosoft.net>2017-09-11 16:56:27 -0700
commit3a1aad07d61411f634e86f905babd6fbbac2eae1 (patch)
treef343fc427c0c791823a39a482dc3d1cd35d34253 /ext/bg/js/settings.js
parent65b679caeb7ae7261ea6f2ba76d1b14ff1d68c5c (diff)
parent2eb85cb835a4aece7839eba25c0030e9eb186f85 (diff)
Merge branch 'master' into firefox-amo
Diffstat (limited to 'ext/bg/js/settings.js')
-rw-r--r--ext/bg/js/settings.js20
1 files changed, 16 insertions, 4 deletions
diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js
index c029b30b..55b469d0 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 {
@@ -217,7 +218,7 @@ async function dictionaryGroupsPopulate(options) {
for (const dictRow of dictRowsSort(dictRows, options)) {
const dictOptions = options.dictionaries[dictRow.title] || {enabled: false, priority: 0};
- const dictHtml = handlebarsRender('dictionary.html', {
+ const dictHtml = await apiTemplateRender('dictionary.html', {
title: dictRow.title,
version: dictRow.version,
revision: dictRow.revision,
@@ -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);
+ }
+}