www.spaceplanner.app

Web client to the spaceplanner API
git clone git://jacobedwards.org/www.spaceplanner.app
Log | Files | Refs

commit 61813b2487bbc8f7dc3e65c132350dd2934ac6e9
parent 45223ae57a072fce40da2a4391284d8157ee090c
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Sun,  6 Oct 2024 20:59:16 -0700

Fix and style login

Two submit handlers were running calling the api twice which is now
fixed, also give a bit of contrast by using a grey background.

Diffstat:
Afiles/css/creds.css | 7+++++++
Mfiles/lib/ui.js | 3+++
Mfiles/login/index.html | 3+--
Mfiles/login/main.js | 17+----------------
4 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/files/css/creds.css b/files/css/creds.css @@ -0,0 +1,7 @@ +body { + background-color: grey; +} + +.credentials { + background-color: white; +} diff --git a/files/lib/ui.js b/files/lib/ui.js @@ -79,6 +79,9 @@ export function login(callback) { let form = document.createElement("form") form.classList.add("credentials") + let h = form.appendChild(document.createElement("h1")) + h.append(document.createTextNode("Login")) + let aside = form.appendChild(document.createElement("aside")) aside.append(document.createTextNode("Don't have an account? ")) let a = aside.appendChild(document.createElement("a")) diff --git a/files/login/index.html b/files/login/index.html @@ -4,11 +4,10 @@ <meta name="viewport" content="width=device-width"> <title>Spaceplanner Login</title> <link rel="stylesheet" type="text/css" href="/css/main.css"> + <link rel="stylesheet" type="text/css" href="/css/creds.css"> <script type="module" src="./main.js"></script> </head> <body> - <h1>Login</h1> - <noscript><p>Unfortunately you must enable Javascript to login.</p></noscript> </body> </html> diff --git a/files/login/main.js b/files/login/main.js @@ -9,23 +9,8 @@ function init() { window.location.href = default_page } - let login = document.body.appendChild(ui.login()) - let username = document.getElementById("username") - let password = document.getElementById("password") - if (!login || !username || !password) { - throw new Error("Expected login form, username, password fields") - } + let login = document.body.appendChild(ui.login(function() { window.location.href = default_page })) - login.addEventListener("submit", function(event) { - event.preventDefault() - api.login(username.value, password.value) - .then(function() { - window.location.href = default_page - }) - .catch(function(err) { - etc.error(err, login) - }) - }) } window.onload = etc.handle_wrap(init)