diff --git a/assets/client.js b/assets/client.js index 5317e5f..4f1ee09 100644 --- a/assets/client.js +++ b/assets/client.js @@ -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(); +} diff --git a/assets/style.css b/assets/style.css index 97cf861..12a8a25 100644 --- a/assets/style.css +++ b/assets/style.css @@ -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%; } diff --git a/index.html b/index.html index 3e4ddb0..0a39835 100644 --- a/index.html +++ b/index.html @@ -38,6 +38,10 @@

+ + +

+
More options