diff options
author | Alex Yatskov <alex@foosoft.net> | 2016-05-22 20:51:06 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2016-05-22 20:51:06 -0700 |
commit | e7b6b171cba575f09498603698a98bd665031978 (patch) | |
tree | 2f9b284959a2a9262e0dda9376e2687f2f99b0ab /ext | |
parent | bd17b05eef0691f3f5ea618abb33da529e022dfd (diff) |
WIP
Diffstat (limited to 'ext')
-rw-r--r-- | ext/bg/js/options-form.js | 20 | ||||
-rw-r--r-- | ext/bg/js/options.js | 10 | ||||
-rw-r--r-- | ext/bg/options.html | 2 |
3 files changed, 21 insertions, 11 deletions
diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js index 1aa26384..d5d2eaee 100644 --- a/ext/bg/js/options-form.js +++ b/ext/bg/js/options-form.js @@ -22,20 +22,28 @@ function yomichan() { } function optionsToForm(opts) { + $('#scan-length').val(opts.scanLength); $('#activate-on-startup').prop('checked', opts.activateOnStartup); - $('#enable-anki-connect').prop('checked', opts.enableAnkiConnect); $('#load-enamdict').prop('checked', opts.loadEnamDict); - $('#scan-length').val(opts.scanLength); $('#select-matched-text').prop('checked', opts.selectMatchedText); + $('#enable-anki-connect').prop('checked', opts.enableAnkiConnect); + $('#anki-vocab-deck').val(opts.ankiVocabDeck); + $('#anki-vocab-model').val(opts.ankiVocabModel); + $('#anki-kanji-deck').val(opts.ankiKanjiDeck); + $('#anki-kanji-model').val(opts.ankiKanjiModel); } function formToOptions() { return sanitizeOptions({ + scanLength: $('#scan-length').val(), activateOnStartup: $('#activate-on-startup').prop('checked'), - enableAnkiConnect: $('#enable-anki-connect').prop('checked'), loadEnamDict: $('#load-enamdict').prop('checked'), - scanLength: $('#scan-length').val(), - selectMatchedText: $('#select-matched-text').prop('checked') + selectMatchedText: $('#select-matched-text').prop('checked'), + enableAnkiConnect: $('#enable-anki-connect').prop('checked'), + ankiVocabDeck: $('#anki-vocab-deck').val(), + ankiVocabModel: $('#anki-vocab-model').val(), + ankiKanjiDeck: $('#anki-kanji-deck').val(), + ankiKanjiModel: $('#anki-kanji-model').val() }); } @@ -104,7 +112,7 @@ $(document).ready(() => { loadOptions((opts) => { optionsToForm(opts); - $('input').on('input paste change', onOptionsChanged); + $('input, select').on('input paste change', onOptionsChanged); $('.anki-model').change(onModelChanged); updateAnkiFormVis(opts); diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index d0bbdb5f..f131ab9b 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -19,14 +19,16 @@ function sanitizeOptions(options) { const defaults = { - activateOnStartup: false, - loadEnamDict: false, scanLength: 20, + activateOnStartup: false, selectMatchedText: true, + loadEnamDict: false, enableAnkiConnect: false, - ankiDeck: '', - ankiModel: '', + ankiVocabDeck: '', + ankiVocabModel: '', ankiVocabFields: {}, + ankiKanjiDeck: '', + ankiKanjiModel: '', ankiKanjiFields: {} }; diff --git a/ext/bg/options.html b/ext/bg/options.html index 8aaacd04..fcfc2db3 100644 --- a/ext/bg/options.html +++ b/ext/bg/options.html @@ -119,7 +119,7 @@ </div> </div> - <table class="table table-bordered ankiFields"> + <table class="table table-bordered anki-fields"> <thead> <tr> <th>Field</th> |