add simple form

This commit is contained in:
Shin'ya Ueoka 2017-09-25 22:15:56 +09:00
parent 4edb0331a1
commit 8791ed4e5e
5 changed files with 54 additions and 3 deletions

19
src/settings/index.js Normal file
View file

@ -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);
});

View file

@ -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>

View file

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