From aa7fb8137af5179a1824d8774984bd5461d9e99f Mon Sep 17 00:00:00 2001 From: idk Date: Thu, 7 Feb 2019 17:18:49 -0500 Subject: [PATCH] Add settings configuration, not using it yet --- options/options.html | 4 ++-- options/options.js | 30 +++++++++++++++++++++++------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/options/options.html b/options/options.html index 841009c..985ab0d 100644 --- a/options/options.html +++ b/options/options.html @@ -18,9 +18,9 @@
Proxy Options
- +
- +
diff --git a/options/options.js b/options/options.js index fffb2b7..b215739 100644 --- a/options/options.js +++ b/options/options.js @@ -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")); } }