aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/components/setting.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/components/setting.js b/src/components/setting.js
index afbd56c..1f3b3fe 100644
--- a/src/components/setting.js
+++ b/src/components/setting.js
@@ -1,4 +1,5 @@
import * as settingActions from '../actions/setting';
+import { validate } from '../shared/validators/setting';
export default class SettingComponent {
constructor(wrapper, store) {
@@ -9,6 +10,9 @@ export default class SettingComponent {
let form = doc.getElementById('vimvixen-settings-form');
form.addEventListener('submit', this.onSubmit.bind(this));
+ let plainJson = form.elements['plain-json'];
+ plainJson.addEventListener('input', this.onPlainJsonChanged.bind(this));
+
store.dispatch(settingActions.load());
}
@@ -20,6 +24,16 @@ export default class SettingComponent {
e.preventDefault();
}
+ onPlainJsonChanged(e) {
+ try {
+ let settings = JSON.parse(e.target.value);
+ validate(settings);
+ e.target.setCustomValidity('');
+ } catch (err) {
+ e.target.setCustomValidity(err.message);
+ }
+ }
+
update() {
let { settings } = this.store.getState();