mirror of
https://codeberg.org/emersion/gamja.git
synced 2024-11-14 19:05:01 -05:00
Add "server" query parameter
This commit is contained in:
parent
3612dd3e63
commit
deb82c7abe
2 changed files with 25 additions and 4 deletions
|
@ -330,6 +330,19 @@ function setConnectFormDisabled(disabled) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseQueryString() {
|
||||||
|
var query = window.location.search.substring(1);
|
||||||
|
var params = {};
|
||||||
|
query.split('&').forEach(function(s) {
|
||||||
|
if (!s) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var pair = s.split('=');
|
||||||
|
params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || "");
|
||||||
|
});
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
connectFormElt.onsubmit = function(event) {
|
connectFormElt.onsubmit = function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
setConnectFormDisabled(true);
|
setConnectFormDisabled(true);
|
||||||
|
@ -374,4 +387,10 @@ if (localStorage && localStorage.getItem("server")) {
|
||||||
connectFormElt.elements["remember-me"].checked = true;
|
connectFormElt.elements["remember-me"].checked = true;
|
||||||
setConnectFormDisabled(true);
|
setConnectFormDisabled(true);
|
||||||
connect();
|
connect();
|
||||||
|
} else {
|
||||||
|
var params = parseQueryString();
|
||||||
|
if (params.server) {
|
||||||
|
connectFormElt.elements.url.value = params.server;
|
||||||
|
document.querySelector("#connect-url-container").style.display = "none";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,11 @@
|
||||||
<form>
|
<form>
|
||||||
<h2>Connect to IRC</h2>
|
<h2>Connect to IRC</h2>
|
||||||
|
|
||||||
|
<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" value="ws://localhost:8080"/>
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<label for="connect-nick">Nickname:</label><br/>
|
<label for="connect-nick">Nickname:</label><br/>
|
||||||
<input type="username" name="nick" id="connect-nick" autofocus required/>
|
<input type="username" name="nick" id="connect-nick" autofocus required/>
|
||||||
|
@ -43,7 +45,7 @@
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>More options</summary>
|
<summary>Advanced options</summary>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue