Initial commit
This commit is contained in:
55
options/options.css
Normal file
55
options/options.css
Normal file
@@ -0,0 +1,55 @@
|
||||
body {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
input[type="text"],
|
||||
select,
|
||||
textarea {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
label {
|
||||
padding: 10px 10px 10px 0;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
input[type="submit"] {
|
||||
background-color: #1e65ff;
|
||||
color: white;
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
float: right;
|
||||
}
|
||||
|
||||
input[type="submit"]:hover {
|
||||
background-color: #3071ff;
|
||||
}
|
||||
|
||||
.col-25 {
|
||||
float: left;
|
||||
width: 25%;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.col-75 {
|
||||
float: left;
|
||||
width: 75%;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.row {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
/* Clear floats after the columns */
|
||||
.row:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
43
options/options.html
Normal file
43
options/options.html
Normal file
@@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="options.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<form>
|
||||
<div class="row">
|
||||
<div class="col-25">
|
||||
<label for="local">Local</label>
|
||||
</div>
|
||||
<div class="col-75">
|
||||
<input type="text" id="local" placeholder="https://localhost:8080/">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-25">
|
||||
<label for="test">Test</label>
|
||||
</div>
|
||||
<div class="col-75">
|
||||
<input type="text" id="test" placeholder="https://test.mydomain.com/">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-25">
|
||||
<label for="prod">Production</label>
|
||||
</div>
|
||||
<div class="col-75">
|
||||
<input type="text" id="prod" placeholder="https://mydomain.com/">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<input type="submit" value="Save">
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script src="options.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
26
options/options.js
Normal file
26
options/options.js
Normal file
@@ -0,0 +1,26 @@
|
||||
function saveOptions(e) {
|
||||
e.preventDefault();
|
||||
browser.storage.local.set({
|
||||
local: document.querySelector("#local").value,
|
||||
test: document.querySelector("#test").value,
|
||||
prod: document.querySelector("#prod").value,
|
||||
});
|
||||
}
|
||||
|
||||
function restoreOptions() {
|
||||
function updateUI(restoredSettings) {
|
||||
document.querySelector("#local").value = restoredSettings.local || "";
|
||||
document.querySelector("#test").value = restoredSettings.test || "";
|
||||
document.querySelector("#prod").value = restoredSettings.prod || "";
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
|
||||
const gettingStoredSettings = browser.storage.local.get();
|
||||
gettingStoredSettings.then(updateUI, onError);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", restoreOptions);
|
||||
document.querySelector("form").addEventListener("submit", saveOptions);
|
||||
Reference in New Issue
Block a user