Skip to content

Commit

Permalink
remember me
Browse files Browse the repository at this point in the history
  • Loading branch information
shriyadindi committed Nov 5, 2024
1 parent cd4889e commit eba76a1
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 30 deletions.
1 change: 0 additions & 1 deletion Feedback.html
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,6 @@ <h3>Connect with us!</h3>


<script>
// Dark mode functionality
document.addEventListener('DOMContentLoaded', function () {
const toggleButton = document.getElementById('dark-mode-toggle');
const darkModeButton = document.querySelector('.dark-mode-toggle');
Expand Down
5 changes: 5 additions & 0 deletions jquery-1.12.js

Large diffs are not rendered by default.

89 changes: 61 additions & 28 deletions login.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,21 @@
<h2 class="title">Sign in</h2>
<div class="input-field">
<i class="fas fa-user"></i>
<input type="text" placeholder="Username" />
<input type="text" id="username" placeholder="Username" />
</div>
<div class="input-field">
<i class="fas fa-lock" id="toggle-password"></i>
<input type="password" placeholder="Password" id="password-input" />
</div>
<div class="form-check d-flex">
<input type="checkbox" class="form-check-input" id="remember-me" />
<label class="form-check-label">Remember me</label>
</div>

<input type="submit" value="Login" class="btn solid" />
<p class="social-text">Or Sign in with social platforms</p>
<div class="social-media">
<div class="social-icon g-signin2" id="google_btn" >
<div class="social-icon g-signin2" id="google_btn">
<i class="fab fa-google" style="font-size: 24px; color: #4285F4;"></i>
</div>
<a href="https://facebook.com/YourPage" target="_blank" class="social-icon">
Expand Down Expand Up @@ -105,11 +110,14 @@ <h2 class="title">Sign up</h2>
<div class="strength-label" id="strength-label-signup" style="font-size: 14px; margin-top: 10px;">Weak</div>
</div>
<!-- Password strength meter ends here -->

<div class="form-check d-flex">
<input type="checkbox" class="form-check-input" id="login-remember" />
<label class="form-check-label">Remember me</label>
</div>
<input type="submit" class="btn" value="Sign up" />
<p class="social-text">Or Sign up with social platforms</p>
<div class="social-media">
<div class="social-icon g-signin2" id="google_btn" >
<div class="social-icon g-signin2" id="google_btn">
<i class="fab fa-google" style="font-size: 24px; color: #4285F4;"></i>
</div>
<a href="https://facebook.com/YourPage" target="_blank" class="social-icon">
Expand Down Expand Up @@ -248,34 +256,34 @@ <h3>One of us ?</h3>
*/
});



// Uncomment the below code when MongoDB is ready
/*
try {
const response = await fetch("http://localhost:3000/signup", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: data,
});
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.message || "Signup failed");
}

const result = await response.json();
console.log("Server response:", result);
// Uncomment the below code when MongoDB is ready
/*
try {
const response = await fetch("http://localhost:3000/signup", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: data,
});
alert("Signup successful!");
window.location.href = "login.html";
} catch (error) {
alert(error.message);
console.error("Error during signup:", error);
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.message || "Signup failed");
}
*/
const result = await response.json();
console.log("Server response:", result);
alert("Signup successful!");
window.location.href = "login.html";
} catch (error) {
alert(error.message);
console.error("Error during signup:", error);
}
*/

// Toggle password visibility
function togglePassword(fieldId, icon) {
Expand Down Expand Up @@ -396,6 +404,31 @@ <h3>One of us ?</h3>

animateCircles();
</script>
<script>
document.addEventListener("DOMContentLoaded", function () {
const rememberMeCheckbox = document.getElementById("remember-me");
const usernameInput = document.getElementById("username");

// Load saved username if it exists
if (localStorage.getItem("rememberedUsername")) {
usernameInput.value = localStorage.getItem("rememberedUsername");
rememberMeCheckbox.checked = true;
}

// When the form is submitted, save the username if "Remember Me" is checked
document.querySelector(".sign-in-form").addEventListener("submit", function (e) {
e.preventDefault(); // Prevent default form submission

if (rememberMeCheckbox.checked) {
localStorage.setItem("rememberedUsername", usernameInput.value);
} else {
localStorage.removeItem("rememberedUsername");
}
// Add form submission logic here
});
});

</script>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<!-- <script src="Firebase.js" type="module"></script> -->
</body>
Expand Down
2 changes: 1 addition & 1 deletion login.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ function displayStrengthMessage(strength) {
}

// Call the checkPasswordStrength function on password input
passwordField.addEventListener("input", checkPasswordStrength);
passwordField.addEventListener("input", checkPasswordStrength);

0 comments on commit eba76a1

Please sign in to comment.