-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #436 from samarsajad/doc3
Functionality added to Sign-in and Sign-up
- Loading branch information
Showing
3 changed files
with
176 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
const signUpButton = document.getElementById("signUp"); | ||
const signInButton = document.getElementById("signIn"); | ||
const container = document.getElementById("container"); | ||
let uppass = []; | ||
let inpass = []; | ||
let userImgPassInput = []; | ||
signUpButton.addEventListener("click", () => { | ||
container.classList.add("right-panel-active"); | ||
inpass = []; | ||
uppass = []; | ||
}); | ||
|
||
signInButton.addEventListener("click", () => { | ||
container.classList.remove("right-panel-active"); | ||
inpass = []; | ||
uppass = []; | ||
}); | ||
// adding and removing border | ||
function upimg(element) { | ||
var Image = element.querySelector("img"); | ||
if (Image) { | ||
if (Image.classList.contains("clicked")) { | ||
Image.classList.remove("clicked"); | ||
uppass.splice(uppass.indexOf(element.id), 1); | ||
} else { | ||
Image.classList.add("clicked"); | ||
uppass.push(element.id); | ||
} | ||
} | ||
} | ||
|
||
function inimg(element) { | ||
var Image = element.querySelector("img"); | ||
if (Image) { | ||
if (Image.classList.contains("clicked")) { | ||
Image.classList.remove("clicked"); | ||
} else { | ||
Image.classList.add("clicked"); | ||
} | ||
} | ||
} | ||
// element image recognition | ||
function signup() { | ||
sessionStorage.setItem("upname", document.getElementById("upmail").value); | ||
sessionStorage.setItem("uppass", uppass); | ||
sessionStorage.setItem("userpass", document.getElementById("s-pass").value); | ||
var myText = "Account Created Succesfully"; | ||
alert(myText); | ||
} | ||
// image pattern authentication | ||
var v2 = new Boolean(false); | ||
function signin() { | ||
userImgPassInput = []; | ||
const userEmailInput = document.getElementById("inmail").value; | ||
const userPassInput = document.getElementById("l-pass").value; | ||
const userImgPass = sessionStorage.getItem("uppass"); | ||
const userEmail = sessionStorage.getItem("upname"); | ||
const userPass = sessionStorage.getItem("userpass"); | ||
const clickedImage = document.getElementsByClassName("clicked"); | ||
for (let index = 0; index < clickedImage.length; index++) { | ||
userImgPassInput.push(clickedImage[index].parentElement.id); | ||
} | ||
console.log(userPass, userPassInput); | ||
if (!graphicMode) { | ||
if ( | ||
userImgPass === userImgPassInput.toString() && | ||
userEmailInput === userEmail | ||
) { | ||
var myText = "Login is successful"; | ||
alert(myText); | ||
NewTab(); | ||
} else { | ||
var myText = "Login Failed"; | ||
alert(myText); | ||
} | ||
} else { | ||
if ( | ||
userImgPass === userImgPassInput.toString() && | ||
userEmailInput === userEmail && | ||
userPassInput.toString() == userPass.toString() | ||
) { | ||
var myText = "Login is successful"; | ||
alert(myText); | ||
NewTab(); | ||
} else { | ||
var myText = "Login Failed"; | ||
alert(myText); | ||
} | ||
} | ||
} | ||
|
||
function NewTab() { | ||
window.open("index.html", "_blank"); | ||
} | ||
|
||
// TIMEPASS KA CODE // | ||
// const inpassBtn = document.getElementsByClassName("inpass"); | ||
// const timepassBtn = document.getElementsByClassName("timepass"); | ||
// graphicMode = true; | ||
// for (let index = 0; index < timepassBtn.length; index++) { | ||
// timepassBtn[index].addEventListener("click", function (event) { | ||
// console.log(event.target); | ||
// if (graphicMode) { | ||
// graphicMode = false; | ||
// inpassBtn[0].style.display = "none"; | ||
// inpassBtn[1].style.display = "none"; | ||
// } else { | ||
// graphicMode = true; | ||
// inpassBtn[0].style.display = "block"; | ||
// inpassBtn[1].style.display = "block"; | ||
// } | ||
// }); | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,43 @@ | ||
const registerButton = document.getElementById("register"); | ||
const loginButton = document.getElementById("login"); | ||
const container = document.getElementById("container"); | ||
document.addEventListener("DOMContentLoaded", function() { | ||
const registerButton = document.getElementById("register"); | ||
const loginButton = document.getElementById("login"); | ||
const container = document.getElementById("container"); | ||
const registerForm = document.getElementById("registerForm"); | ||
const loginForm = document.getElementById("loginForm"); | ||
|
||
registerButton.addEventListener("click", () => { | ||
container.classList.add("right-panel-active"); | ||
}); | ||
registerButton.addEventListener("click", (event) => { | ||
event.preventDefault(); | ||
container.classList.add("right-panel-active"); | ||
registerForm.scrollIntoView({ behavior: "smooth" }); | ||
}); | ||
|
||
loginButton.addEventListener("click", (event) => { | ||
event.preventDefault(); | ||
container.classList.remove("right-panel-active"); | ||
loginForm.scrollIntoView({ behavior: "smooth" }); | ||
}); | ||
|
||
registerForm.addEventListener("submit", (event) => { | ||
event.preventDefault(); | ||
// Your registration logic goes here | ||
|
||
loginButton.addEventListener("click", () => { | ||
container.classList.remove("right-panel-active"); | ||
}); | ||
// Simulate registration success | ||
document.getElementById("registerMessage").style.display = "block"; | ||
setTimeout(() => { | ||
container.classList.remove("right-panel-active"); | ||
loginForm.scrollIntoView({ behavior: "smooth" }); | ||
}, 2000); | ||
}); | ||
|
||
loginForm.addEventListener("submit", (event) => { | ||
event.preventDefault(); | ||
// Your login logic goes here | ||
|
||
// Simulate login success | ||
alert("Login successful!"); | ||
// Redirect to the homepage after login | ||
setTimeout(() => { | ||
window.location.href = "index.html"; // Change "index.html" to your desired URL | ||
}, 1000); // Redirect after 1 second (1000 milliseconds) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters