add simple form

jh-changes
Shin'ya Ueoka 7 years ago
parent 4edb0331a1
commit 8791ed4e5e
  1. 10
      manifest.json
  2. 19
      src/settings/index.js
  3. 15
      src/settings/settings.html
  4. 7
      src/settings/settings.scss
  5. 6
      webpack.config.js

@ -15,11 +15,15 @@
] ]
}, },
"permissions": [ "permissions": [
"history",
"sessions", "sessions",
"tabs", "storage",
"history" "tabs"
], ],
"web_accessible_resources": [ "web_accessible_resources": [
"build/console.html" "build/console.html"
] ],
"options_ui": {
"page": "build/settings.html"
}
} }

@ -0,0 +1,19 @@
import './settings.scss';
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);
});
document.addEventListener('DOMContentLoaded', () => {
browser.storage.local.get().then((value) => {
if (value.json) {
form.elements['plain-json'].value = value.json;
}
}, console.error);
});

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
</head>
<body>
<form id='vimvixen-settings-form' class='vimvixen-settings-form'>
<label for='plain-json'>Settings by plain json: </label>
<textarea
name='plain-json'></textarea>
<button type='submit'>Save</button>
</form>
<script src='settings.js'></script>
</body>
</html>

@ -0,0 +1,7 @@
.vimvixen-settings-form {
textarea[name=plain-json] {
font-family: monospace;
width: 100%;
resize: vertical;
}
}

@ -7,6 +7,7 @@ const dist = path.resolve(__dirname, 'build');
module.exports = { module.exports = {
entry: { entry: {
index: path.join(src, 'content'), index: path.join(src, 'content'),
settings: path.join(src, 'settings'),
background: path.join(src, 'background'), background: path.join(src, 'background'),
console: path.join(src, 'console', 'console.js') console: path.join(src, 'console', 'console.js')
}, },
@ -46,6 +47,11 @@ module.exports = {
template: path.join(src, 'console', 'console.html'), template: path.join(src, 'console', 'console.html'),
filename: path.join(dist, 'console.html'), filename: path.join(dist, 'console.html'),
inject: false inject: false
}),
new HtmlWebpackPlugin({
template: path.join(src, 'settings', 'settings.html'),
filename: path.join(dist, 'settings.html'),
inject: false
}) })
] ]
}; };