From 5682273c74f46383908131c9299613b7e6cfdcfc Mon Sep 17 00:00:00 2001 From: miniduikboot Date: Wed, 10 Jan 2024 19:35:08 +0100 Subject: [PATCH] Redesign protocol field We got a few people who put http:// into the server address field. By putting the dropdown next to the address field this hopefully doesn't happen anymore --- index.html | 26 +++++++++++--------------- script.js | 20 +++++++++----------- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/index.html b/index.html index 82bdd781..6d3a5a38 100644 --- a/index.html +++ b/index.html @@ -26,25 +26,21 @@
-
+
+
+ +
+
+
+
-
-
- -
-
- -
-
- - -
-
- - +
diff --git a/script.js b/script.js index fa4439b5..a8934586 100644 --- a/script.js +++ b/script.js @@ -9,7 +9,7 @@ function parseForm() { const address = document.getElementById("address").value.trim(); const port = parseInt(document.getElementById("port").value) ?? DEFAULT_PORT_HTTP; const name = document.getElementById("name").value || "Impostor"; - const protocol = document.querySelector("input[name=serverProtocol]:checked").value || "http"; + const protocol = document.querySelector("select[name=serverProtocol]").value || "http"; return { address, port, name, protocol, url: `${protocol}://${address}` }; } @@ -58,17 +58,15 @@ function setPlatform(platform) { } // HTTPS is mandatory on ios/android - const httpRadio = document.getElementById("http"); - const httpsRadio = document.getElementById("https"); + const protocol = document.getElementById("protocol"); if (platform === "android" || platform === "ios") { - httpsSetExplicitly = httpsRadio.checked; - httpsRadio.checked = true; - httpRadio.disabled = true; + protocol.value = "https"; + protocol.disabled = true; setPortIfDefault("https"); } else { - httpRadio.disabled = false; + protocol.disabled = false; if (!httpsSetExplicitly) { - httpRadio.checked = true; + protocol.value = "http"; setPortIfDefault("http"); } } @@ -150,7 +148,7 @@ function fillFromLocationHash() { if (protocol !== "http" && protocol !== "https") { protocol = "http"; } - document.getElementById(protocol).checked = true; + document.querySelector("select[name=serverProtocol]").value = protocol; document.getElementById("name").value = serverName; } @@ -160,8 +158,6 @@ function setLocationHash() { document.location.hash = [serverInfo.address, serverInfo.port, serverInfo.protocol, serverInfo.name].join(":"); } -fillFromLocationHash(); - if (["iPhone", "iPad", "iPod"].indexOf(window.navigator.platform) !== -1) { setPlatform("ios"); } else if (/Android/.test(window.navigator.userAgent)) { @@ -169,3 +165,5 @@ if (["iPhone", "iPad", "iPod"].indexOf(window.navigator.platform) !== -1) { } else { setPlatform("desktop"); } + +fillFromLocationHash();