Automatically save settings in the options page
Change-Id: Ib9e9642a9883dde1d2fd4e77b0dab1c7fc734256
diff --git a/src/js/options.js b/src/js/options.js
index ca66004..b502450 100644
--- a/src/js/options.js
+++ b/src/js/options.js
@@ -62,7 +62,14 @@
});
$('#save').addEventListener('click', _ => {
- saveOptions();
+ saveOptions(true);
+ });
+
+ // Save automatically
+ $all('input[type="radio"]').forEach(radio => {
+ radio.addEventListener('change', _ => {
+ saveOptions();
+ });
});
// Print selected language list
@@ -86,6 +93,8 @@
'li[data-language=' + this.getAttribute('data-language') +
']'));
printListModal();
+ // Save automatically
+ saveOptions();
});
}
}
@@ -124,8 +133,13 @@
$('li[data-language=' + this.getAttribute('data-language') +
']'));
printListModal();
+ // Save automatically
+ saveOptions();
});
$('dialog').close();
+
+ // Save automatically
+ saveOptions();
});
// About credits...
@@ -219,7 +233,7 @@
});
}
-function saveOptions() {
+function saveOptions(close = false) {
var languages = document.getElementById('languages');
var options = {
uniquetab: '',
@@ -242,7 +256,7 @@
background.translator_tab = false;
background.translator_window = false;
- window.close();
+ if (close) window.close();
});
}