aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-11-06 18:30:51 -0800
committerAlex Yatskov <alex@foosoft.net>2016-11-06 18:30:51 -0800
commit73c7c225f11b9a1da550b9b866f106b188bd82ea (patch)
tree38f2b3a72ae5204c61cd00c41e4808f21e686530 /ext
parent20304b5460e54621511a98b9dba9236d4d192ac3 (diff)
Save dictionary options
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/options-form.js12
-rw-r--r--ext/bg/options.html20
2 files changed, 12 insertions, 20 deletions
diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js
index 3ea850b7..f9346d7d 100644
--- a/ext/bg/js/options-form.js
+++ b/ext/bg/js/options-form.js
@@ -91,6 +91,14 @@ function getFormValues() {
optsNew.ankiKanjiModel = $('#anki-kanji-model').val();
optsNew.ankiKanjiFields = fieldsToDict($('#kanji .anki-field-value'));
+ $('.dictionary').each((index, element) => {
+ const dictionary = $(element);
+ const name = dictionary.data('name');
+ const enableTerms = dictionary.find('.dict-enable-terms').prop('checked');
+ const enableKanji = dictionary.find('.dict-enable-kanji').prop('checked');
+ optsNew.dictionaries[name] = {enableTerms, enableKanji};
+ });
+
return {
optsNew: sanitizeOptions(optsNew),
optsOld: sanitizeOptions(optsOld)
@@ -172,12 +180,14 @@ function populateDictionaries(opts) {
container.append($(html));
});
+
+ container.find('.dictionary input').change(onOptionsChanged);
});
}
function populateAnkiFields(element, opts) {
const tab = element.closest('.tab-pane');
- const container = tab.find('.anki-fields tbody');
+ const container = tab.find('tbody');
container.empty();
const modelName = element.val();
diff --git a/ext/bg/options.html b/ext/bg/options.html
index acd786cf..bc87d654 100644
--- a/ext/bg/options.html
+++ b/ext/bg/options.html
@@ -65,25 +65,7 @@
<div>
<h3>Dictionaries</h3>
- <div class="dictionaries">
- <div class="dictionary well well-sm">
- <div class="row">
- <div class="col-xs-8">
- <h4><span class="text-muted glyphicon glyphicon-book"></span> Dictionary <small>v.1</small></h4>
- </div>
- <div class="col-xs-4 text-right">
- <button type="button" class="dict-delete btn btn-danger">Delete</button>
- </div>
- </div>
-
- <div class="checkbox">
- <label><input type="checkbox" class="dict-enable-terms"> Enable term search</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" class="dict-enable-kanji"> Enable Kanji search</label>
- </div>
- </div>
- </div>
+ <div class="dictionaries"></div>
<div class="alert alert-danger" id="dict-error">
<strong>Error:</strong>