diff --git a/assets/js/proxy-toggle.js b/assets/js/proxy-toggle.js new file mode 100644 index 0000000..b9c2972 --- /dev/null +++ b/assets/js/proxy-toggle.js @@ -0,0 +1,27 @@ +document.addEventListener("DOMContentLoaded", function () { + const showAllProxiesToggle = document.getElementById("show-all-proxies"); + const imageProxySelect = document.getElementById("image-proxy"); + + showAllProxiesToggle.addEventListener("change", function () { + const showAll = this.checked; + const options = imageProxySelect.options; + let firstVisibleOption = null; + + for (let i = 0; i < options.length; i++) { + const option = options[i]; + const proxyType = option.getAttribute("data-proxy-type"); + + if (proxyType === "working" || (proxyType === "all" && showAll)) { + option.style.display = ""; + if (!firstVisibleOption) firstVisibleOption = option; + } else { + option.style.display = "none"; + } + } + + // If the currently selected option is now hidden, select the first visible option + if (imageProxySelect.selectedOptions[0].style.display === "none") { + firstVisibleOption.selected = true; + } + }); +}); diff --git a/assets/views/layout/default.jet.html b/assets/views/layout/default.jet.html index ddafe71..ff0c89b 100644 --- a/assets/views/layout/default.jet.html +++ b/assets/views/layout/default.jet.html @@ -17,7 +17,6 @@ - @@ -26,10 +25,12 @@ --> + + diff --git a/assets/views/settings.jet.html b/assets/views/settings.jet.html index 2e60aa0..c37e0b8 100644 --- a/assets/views/settings.jet.html +++ b/assets/views/settings.jet.html @@ -82,12 +82,19 @@ also specify a custom proxy server by entering its URL and clicking 'Save Changes'.

+
+ + +