diff options
Diffstat (limited to 'src/settings/index.js')
-rw-r--r-- | src/settings/index.js | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/settings/index.js b/src/settings/index.js index f2bba32..89a9533 100644 --- a/src/settings/index.js +++ b/src/settings/index.js @@ -1,19 +1,24 @@ import './settings.scss'; +import DefaultSettings from './default-settings'; let form = document.getElementById('vimvixen-settings-form'); form.addEventListener('submit', (e) => { - let value = { - json: e.target.elements['plain-json'].value - }; e.preventDefault(); - browser.storage.local.set(value); + browser.storage.local.set({ + settings: { + json: e.target.elements['plain-json'].value + } + }); }); document.addEventListener('DOMContentLoaded', () => { - browser.storage.local.get().then((value) => { - if (value.json) { - form.elements['plain-json'].value = value.json; + browser.storage.local.get('settings').then((value) => { + if (value.settings.json) { + form.elements['plain-json'].value = value.settings.json; + } else { + form.elements['plain-json'].value = + JSON.stringify(DefaultSettings, null, 2); } }, console.error); }); |