mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-11-14 19:25:26 -05:00
Add "remember me" checkbox in connect form
This commit is contained in:
parent
a8e876843b
commit
a08fdeea8f
3 changed files with 32 additions and 1 deletions
|
@ -314,6 +314,14 @@ connectFormElt.onsubmit = function(event) {
|
|||
server.username = connectFormElt.elements.username.value || server.nick;
|
||||
server.realname = connectFormElt.elements.realname.value || server.nick;
|
||||
|
||||
if (localStorage) {
|
||||
if (connectFormElt.elements["remember-me"].checked) {
|
||||
localStorage.setItem("server", JSON.stringify(server));
|
||||
} else {
|
||||
localStorage.removeItem("server");
|
||||
}
|
||||
}
|
||||
|
||||
connect();
|
||||
};
|
||||
|
||||
|
@ -325,3 +333,19 @@ window.onkeydown = function(event) {
|
|||
composerInputElt.value = "";
|
||||
}
|
||||
};
|
||||
|
||||
if (localStorage && localStorage.getItem("server")) {
|
||||
server = JSON.parse(localStorage.getItem("server"));
|
||||
connectFormElt.elements.url.value = server.url;
|
||||
connectFormElt.elements.nick.value = server.nick;
|
||||
connectFormElt.elements.password.value = server.pass;
|
||||
if (server.username != server.nick) {
|
||||
connectFormElt.elements.username.value = server.username;
|
||||
}
|
||||
if (server.realname != server.nick) {
|
||||
connectFormElt.elements.realname.value = server.realname;
|
||||
}
|
||||
connectFormElt.elements["remember-me"].checked = true;
|
||||
setConnectFormDisabled(true);
|
||||
connect();
|
||||
}
|
||||
|
|
|
@ -61,7 +61,10 @@ body {
|
|||
margin: 0 auto;
|
||||
max-width: 300px;
|
||||
}
|
||||
#connect input {
|
||||
#connect input[type="text"],
|
||||
#connect input[type="username"],
|
||||
#connect input[type="password"],
|
||||
#connect input[type="url"] {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,10 @@
|
|||
<input type="password" name="password" id="connect-password"/>
|
||||
<br/><br/>
|
||||
|
||||
<input type="checkbox" name="remember-me" id="connect-remember-me"/>
|
||||
<label for="connect-remember-me">Remember me</label>
|
||||
<br/><br/>
|
||||
|
||||
<details>
|
||||
<summary>More options</summary>
|
||||
|
||||
|
|
Loading…
Reference in a new issue