From 73723f6696df0de2668a8eb8d659de5a9942f1d1 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sun, 7 Jun 2020 13:46:46 +0200 Subject: [PATCH] Smarter server URL auto-detection --- assets/client.js | 11 ++++++++++- index.html | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/assets/client.js b/assets/client.js index dabd477..d50ae98 100644 --- a/assets/client.js +++ b/assets/client.js @@ -410,10 +410,19 @@ if (localStorage && localStorage.getItem("server")) { connect(); } else { var params = parseQueryString(); + if (params.server) { - connectFormElt.elements.url.value = params.server; document.querySelector("#connect-url-container").style.display = "none"; + connectFormElt.elements.url.value = params.server; + } else if (!connectFormElt.elements.url.value) { + var host = window.location.host || "localhost:8080"; + var proto = "wss:"; + if (window.location.protocol != "https:") { + proto = "ws:"; + } + connectFormElt.elements.url.value = proto + "//" + host + "/socket"; } + if (params.channels) { connectFormElt.elements.autojoin.value = params.channels; } diff --git a/index.html b/index.html index dfb0b1a..b1ff7b3 100644 --- a/index.html +++ b/index.html @@ -28,7 +28,7 @@

- +