Add "remember me" checkbox in connect form

This commit is contained in:
Simon Ser 2020-06-06 10:19:44 +02:00
parent a8e876843b
commit a08fdeea8f
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
3 changed files with 32 additions and 1 deletions

View file

@ -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();
}

View file

@ -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%;
}

View file

@ -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>