aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/options-form.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-10-15 19:05:53 -0700
committerAlex Yatskov <alex@foosoft.net>2016-10-15 19:05:53 -0700
commit7aa6d6feee78307d998596082caf73a3c1577285 (patch)
tree71a158c08c0e277f10887a43339228c8cbb28a3f /ext/bg/js/options-form.js
parentef25ad144e8e93ca280ba218b28f981425eed2e3 (diff)
WIP
Diffstat (limited to 'ext/bg/js/options-form.js')
-rw-r--r--ext/bg/js/options-form.js18
1 files changed, 12 insertions, 6 deletions
diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js
index 653521d6..7d280429 100644
--- a/ext/bg/js/options-form.js
+++ b/ext/bg/js/options-form.js
@@ -85,6 +85,9 @@ function getAnkiOptions() {
return loadOptions().then(optsOld => {
const optsNew = $.extend({}, optsOld);
+ optsNew.ankiMethod = $('#anki-method').val();
+ optsNew.ankiUsername = $('#anki-username').val();
+ optsNew.ankiPassword = $('#anki-password').val();
optsNew.ankiCardTags = $('#anki-card-tags').val().split(/[,; ]+/);
optsNew.sentenceExtent = parseInt($('#sentence-extent').val(), 10);
optsNew.ankiTermDeck = $('#anki-term-deck').val();
@@ -219,13 +222,11 @@ function onOptionsBasicChanged(e) {
}
function onOptionsAnkiChanged(e) {
- if (!e.originalEvent && !e.isTrigger) {
- return;
+ if (e.originalEvent || e.isTrigger) {
+ getAnkiOptions().then(({optsNew, optsOld}) => {
+ saveOptions(optsNew).then(() => yomichan().setOptions(optsNew));
+ });
}
-
- getAnkiOptions().then(({optsNew, optsOld}) => {
- saveOptions(optsNew).then(() => yomichan().setOptions(optsNew));
- });
}
function onAnkiModelChanged(e) {
@@ -248,9 +249,14 @@ $(document).ready(() => {
$('#select-matched-text').prop('checked', opts.selectMatchedText);
$('#scan-delay').val(opts.scanDelay);
$('#scan-length').val(opts.scanLength);
+
+ $('#anki-method').val(opts.ankiMethod);
+ $('#anki-username').val(opts.ankiUsername);
+ $('#anki-password').val(opts.ankiPassword);
$('#anki-card-tags').val(opts.ankiCardTags.join(' '));
$('#sentence-extent').val(opts.sentenceExtent);
+ $('#anki-method').change(onOptionsAnkiChanged);
$('.options-basic input').change(onOptionsBasicChanged);
$('.options-anki input').change(onOptionsAnkiChanged);
$('.anki-deck').change(onOptionsAnkiChanged);