This commit is contained in:
Alex Yatskov 2016-08-08 20:02:58 -07:00
parent b080e30b14
commit dcce58fc2e
2 changed files with 27 additions and 28 deletions

View File

@ -40,7 +40,7 @@ function formToOptions(section, callback) {
switch (section) {
case 'general':
optsNew.scanLength = parseInt($('#scan-length').val());
optsNew.scanLength = parseInt($('#scan-length').val(), 10);
optsNew.activateOnStartup = $('#activate-on-startup').prop('checked');
optsNew.loadEnamDict = $('#load-enamdict').prop('checked');
optsNew.selectMatchedText = $('#select-matched-text').prop('checked');
@ -49,7 +49,7 @@ function formToOptions(section, callback) {
break;
case 'anki':
optsNew.ankiCardTags = $('#anki-card-tags').val().split(/[,; ]+/);
optsNew.sentenceExtent = parseInt($('#sentence-extent').val());
optsNew.sentenceExtent = parseInt($('#sentence-extent').val(), 10);
optsNew.ankiVocabDeck = $('#anki-vocab-deck').val();
optsNew.ankiVocabModel = $('#anki-vocab-model').val();
optsNew.ankiVocabFields = fieldsToDict($('#vocab .anki-field-value'));
@ -91,6 +91,7 @@ function populateAnkiDeckAndModel(opts) {
function updateAnkiStatus() {
$('.error-dlg').hide();
yomichan().api_getVersion({callback: (version) => {
if (version === null) {
$('.error-dlg-connection').show();

View File

@ -35,14 +35,12 @@ function sanitizeOptions(options) {
ankiKanjiFields: {}
};
for (let key in defaults) {
if (!options.hasOwnProperty(key)) {
for (const key in defaults) {
if (!(key in options)) {
options[key] = defaults[key];
}
}
options.scanLength = parseInt(options.scanLength);
return options;
}