|
|
@ -1,4 +1,5 @@ |
|
|
|
import * as settingActions from '../actions/setting'; |
|
|
|
import * as settingActions from '../actions/setting'; |
|
|
|
|
|
|
|
import { validate } from '../shared/validators/setting'; |
|
|
|
|
|
|
|
|
|
|
|
export default class SettingComponent { |
|
|
|
export default class SettingComponent { |
|
|
|
constructor(wrapper, store) { |
|
|
|
constructor(wrapper, store) { |
|
|
@ -9,6 +10,9 @@ export default class SettingComponent { |
|
|
|
let form = doc.getElementById('vimvixen-settings-form'); |
|
|
|
let form = doc.getElementById('vimvixen-settings-form'); |
|
|
|
form.addEventListener('submit', this.onSubmit.bind(this)); |
|
|
|
form.addEventListener('submit', this.onSubmit.bind(this)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let plainJson = form.elements['plain-json']; |
|
|
|
|
|
|
|
plainJson.addEventListener('input', this.onPlainJsonChanged.bind(this)); |
|
|
|
|
|
|
|
|
|
|
|
store.dispatch(settingActions.load()); |
|
|
|
store.dispatch(settingActions.load()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -20,6 +24,16 @@ export default class SettingComponent { |
|
|
|
e.preventDefault(); |
|
|
|
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() { |
|
|
|
update() { |
|
|
|
let { settings } = this.store.getState(); |
|
|
|
let { settings } = this.store.getState(); |
|
|
|
|
|
|
|
|
|
|
|