diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-27 21:51:39 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-30 13:32:34 +0900 |
commit | e97ffafea319af56c8e446623f33dc32bebba40e (patch) | |
tree | fefc2326841c21e181a86c73adc1dfd808691e87 /src/settings | |
parent | 8ba490ea1179fee73407815f69cdcea6e25c9281 (diff) |
load keymaps from storage
Diffstat (limited to 'src/settings')
-rw-r--r-- | src/settings/default-settings.js | 39 | ||||
-rw-r--r-- | src/settings/index.js | 19 |
2 files changed, 51 insertions, 7 deletions
diff --git a/src/settings/default-settings.js b/src/settings/default-settings.js new file mode 100644 index 0000000..5a89f58 --- /dev/null +++ b/src/settings/default-settings.js @@ -0,0 +1,39 @@ +export default { + 'keymaps': { + '0': { 'type': 'scroll.home' }, + ':': { 'type': 'command.show' }, + 'o': { 'type': 'command.show.open', 'alter': false }, + 'O': { 'type': 'command.show.open', 'alter': true }, + 't': { 'type': 'command.show.tabopen', 'alter': false }, + 'T': { 'type': 'command.show.tabopen', 'alter': true }, + 'b': { 'type': 'command.show.buffer' }, + 'k': { 'type': 'scroll.lines', 'count': -1 }, + 'j': { 'type': 'scroll.lines', 'count': 1 }, + '<C-E>': { 'type': 'scroll.lines', 'count': -1 }, + '<C-Y>': { 'type': 'scroll.lines', 'count': 1 }, + '<C-U>': { 'type': 'scroll.pages', 'count': -0.5 }, + '<C-D>': { 'type': 'scroll.pages', 'count': 0.5 }, + '<C-B>': { 'type': 'scroll.pages', 'count': -1 }, + '<C-F>': { 'type': 'scroll.pages', 'count': 1 }, + 'gg': { 'type': 'scroll.top' }, + 'G': { 'type': 'scroll.bottom' }, + '$': { 'type': 'scroll.end' }, + 'd': { 'type': 'tabs.close' }, + 'u': { 'type': 'tabs.reopen' }, + 'h': { 'type': 'tabs.prev', 'count': 1 }, + 'l': { 'type': 'tabs.next', 'count': 1 }, + 'r': { 'type': 'tabs.reload', 'cache': false }, + 'R': { 'type': 'tabs.reload', 'cache': true }, + 'zi': { 'type': 'zoom.in' }, + 'zo': { 'type': 'zoom.out' }, + 'zz': { 'type': 'zoom.neutral' }, + 'f': { 'type': 'follow.start', 'newTab': false }, + 'F': { 'type': 'follow.start', 'newTab': true }, + 'H': { 'type': 'navigate.history.prev' }, + 'L': { 'type': 'navigate.history.next' }, + '[[': { 'type': 'navigate.link.prev' }, + ']]': { 'type': 'navigate.link.next' }, + 'gu': { 'type': 'navigate.parent' }, + 'gU': { 'type': 'navigate.root' } + } +}; 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); }); |