diff options
Diffstat (limited to 'src/pages')
-rw-r--r-- | src/pages/settings.js | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/src/pages/settings.js b/src/pages/settings.js index 6e00ed3..9bad967 100644 --- a/src/pages/settings.js +++ b/src/pages/settings.js @@ -1,22 +1,15 @@ import './settings.scss'; -import messages from '../content/messages'; +import SettingComponent from '../components/setting'; +import settingReducer from '../reducers/setting'; +import * as store from '../store'; -document.addEventListener('DOMContentLoaded', () => { - let form = document.getElementById('vimvixen-settings-form'); - form.addEventListener('submit', (e) => { - e.preventDefault(); - browser.storage.local.set({ - settings: { - json: e.target.elements['plain-json'].value - } - }).then(() => { - return browser.runtime.sendMessage({ - type: messages.SETTINGS_RELOAD - }); - }); - }); +const settingStore = store.createStore(settingReducer); +let settingComponent = null; + +settingStore.subscribe(() => { + settingComponent.update(); +}); - browser.storage.local.get('settings').then((value) => { - form.elements['plain-json'].value = value.settings.json; - }, console.error); +document.addEventListener('DOMContentLoaded', () => { + settingComponent = new SettingComponent(document.body, settingStore); }); |