This commit is contained in:
Alex Yatskov 2016-04-04 22:07:57 -07:00
parent 37ffcbf3ee
commit 8774c783f6

View File

@ -17,26 +17,21 @@
*/ */
$('#saveOptions').click(() => {
saveOptions(sanitizeOptions(formToOptions()))
});
$('#resetOptions').click(() => {
if (confirm('Reset options to defaults?')) {
optionsToForm(sanitizeOptions({}));
}
});
function optionsToForm(opts) { function optionsToForm(opts) {
$('#scanLength').val(opts.scanLength); $('#scanLength').val(opts.scanLength);
} }
function formToOptions() { function formToOptions() {
return { return sanitizeOptions({
scanLength: $('#scanLength').val() scanLength: $('#scanLength').val()
}; });
} }
$(document).ready(() => { $(document).ready(() => loadOptions((opts) => optionsToForm(opts)));
loadOptions((opts) => optionsToForm(sanitizeOptions(opts)));
$('#saveOptions').click(() => saveOptions(formToOptions()));
$('#resetOptions').click(() => {
if (confirm('Reset options to defaults?')) {
optionsToForm(sanitizeOptions({}));
}
}); });