diff --git a/public/frontend_login.js b/public/frontend_login.js index e5c1451..a5814ad 100644 --- a/public/frontend_login.js +++ b/public/frontend_login.js @@ -15,9 +15,8 @@ if (loginRes.ok) { const loginData = await loginRes.json(); - alert(`Welcome back, ${loginData.username}!`); - document.cookie = `authorization=${loginData.token}` - window.location.href = "/"; + document.cookie = `authorization=${loginData.token}`; + showLoadingScreen("Login successful. Loading Lobby..."); return; } @@ -29,9 +28,8 @@ if (registerRes.ok) { const registerData = await registerRes.json(); - alert(`Account created! Welcome!`); - document.cookie = `authorization=${registerData.token}` - window.location.href = "/"; + document.cookie = `authorization=${registerData.token}`; + showLoadingScreen("Register successful. Loading Lobby..."); } else { const error = await registerRes.json(); alert("Register failed: " + (error.error || "Unknown error")); @@ -41,4 +39,28 @@ alert("Server unreachable."); } }); + + function showLoadingScreen(message) { + const loadingScreen = document.getElementById("loading-screen"); + const loadingText = document.getElementById("loading-text"); + const progress = document.getElementById("progress"); + + loadingText.textContent = message; + loadingScreen.classList.remove("hidden"); + + let percent = 0; + const interval = setInterval(() => { + percent += Math.floor(Math.random() * 10) + 5; + if (percent >= 100) { + percent = 100; + progress.style.width = percent + "%"; + clearInterval(interval); + setTimeout(() => { + window.location.href = "/"; + }, 500); + } else { + progress.style.width = percent + "%"; + } + }, 200); + } }); \ No newline at end of file diff --git a/public/login.html b/public/login.html index c38af82..1525ee4 100644 --- a/public/login.html +++ b/public/login.html @@ -12,6 +12,12 @@ + \ No newline at end of file diff --git a/public/styles_login.css b/public/styles_login.css index d2943d1..ad7f9dd 100644 --- a/public/styles_login.css +++ b/public/styles_login.css @@ -61,4 +61,45 @@ button { button:hover { background: #1f1; -} \ No newline at end of file +} + +.hidden { + display: none !important; +} + +#loading-screen { + position: fixed; + top: 0; + left: 0; + width: 100vw; + height: 100vh; + background: #000; + color: #0f0; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + z-index: 9999; +} + +.loading-text { + font-size: 24px; + margin-bottom: 20px; + text-shadow: 0 0 10px #0f0; +} + +.progress-bar { + width: 80%; + height: 20px; + border: 2px solid #0f0; + border-radius: 10px; + background: #111; +} + +.progress { + height: 100%; + width: 0; + background-color: #0f0; + border-radius: 10px; + transition: width 0.3s ease; +}