mirror of
https://codeberg.org/emersion/gamja.git
synced 2024-11-28 18:26:19 -05:00
Smarter server URL auto-detection
This commit is contained in:
parent
1a1c3f9052
commit
73723f6696
2 changed files with 11 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
<div id="connect-url-container">
|
||||
<label for="connect-url">Server URL:</label><br/>
|
||||
<input type="url" name="url" id="connect-url" value="ws://localhost:8080"/>
|
||||
<input type="url" name="url" id="connect-url"/>
|
||||
<br/><br/>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue