Add settings configuration, not using it yet
This commit is contained in:
@@ -18,9 +18,9 @@
|
||||
<section class="scheme-options proxy-options">
|
||||
<div class="title" >Proxy Options</div>
|
||||
|
||||
<label>Host: <input type="text" value="127.0.0.1"/></label>
|
||||
<label>Host: <input type="text" data="host" value="127.0.0.1"/></label>
|
||||
<br>
|
||||
<label>Port: <input type="text" value="4444"/></label>
|
||||
<label>Port: <input type="text" data="port" value="4444"/></label>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
@@ -8,22 +8,35 @@ function storeSettings() {
|
||||
return proxy_scheme.value;
|
||||
}
|
||||
|
||||
function getTypes() {
|
||||
let proxy_value = [];
|
||||
function getHost() {
|
||||
let proxy_host = "";
|
||||
const textboxes = document.querySelectorAll(".proxy-options [type=text]");
|
||||
for (let item of textboxes) {
|
||||
if (item.checked) {
|
||||
proxy_value.push(item.getAttribute("value"));
|
||||
if (item.getAttribute("data") == "host") {
|
||||
proxy_host.push(item.getAttribute("value"));
|
||||
}
|
||||
}
|
||||
return proxy_value;
|
||||
}
|
||||
|
||||
function getPort() {
|
||||
let proxy_port = "";
|
||||
const textboxes = document.querySelectorAll(".proxy-options [type=text]");
|
||||
for (let item of textboxes) {
|
||||
if (item.getAttribute("data") == "port") {
|
||||
proxy_port.push(item.getAttribute("value"));
|
||||
}
|
||||
}
|
||||
return proxy_value;
|
||||
}
|
||||
|
||||
const proxy_scheme = getSince();
|
||||
const proxy_value = getTypes();
|
||||
const proxy_host = getHost();
|
||||
const proxy_port = getPort();
|
||||
browser.storage.local.set({
|
||||
proxy_scheme,
|
||||
proxy_value
|
||||
proxy_host,
|
||||
proxy_port,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -37,7 +50,10 @@ function updateUI(restoredSettings) {
|
||||
|
||||
const textboxes = document.querySelectorAll(".proxy-options [type=text]");
|
||||
for (let item of textboxes) {
|
||||
if (restoredSettings.proxy_value.indexOf(item.getAttribute("value")) != -1) {
|
||||
if (restoredSettings.proxy_value.indexOf(item.getAttribute("data")) != -1) {
|
||||
item.value = restoredSettings.proxy_value.indexOf(item.getAttribute("value"));
|
||||
}
|
||||
if (restoredSettings.proxy_value.indexOf(item.getAttribute("data")) != -1 ) {
|
||||
item.value = restoredSettings.proxy_value.indexOf(item.getAttribute("value"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user