add simple form
This commit is contained in:
parent
4edb0331a1
commit
8791ed4e5e
5 changed files with 54 additions and 3 deletions
|
@ -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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
19
src/settings/index.js
Normal file
19
src/settings/index.js
Normal 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);
|
||||||
|
});
|
15
src/settings/settings.html
Normal file
15
src/settings/settings.html
Normal 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>
|
7
src/settings/settings.scss
Normal file
7
src/settings/settings.scss
Normal file
|
@ -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
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue