mirror of
https://codeberg.org/emersion/gamja.git
synced 2024-11-25 08:48:09 -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();
|
connect();
|
||||||
} else {
|
} else {
|
||||||
var params = parseQueryString();
|
var params = parseQueryString();
|
||||||
|
|
||||||
if (params.server) {
|
if (params.server) {
|
||||||
connectFormElt.elements.url.value = params.server;
|
|
||||||
document.querySelector("#connect-url-container").style.display = "none";
|
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) {
|
if (params.channels) {
|
||||||
connectFormElt.elements.autojoin.value = params.channels;
|
connectFormElt.elements.autojoin.value = params.channels;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
<div id="connect-url-container">
|
<div id="connect-url-container">
|
||||||
<label for="connect-url">Server URL:</label><br/>
|
<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/>
|
<br/><br/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue