forked from heyvipul/blueFly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.js
67 lines (65 loc) · 2.47 KB
/
login.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var alrts=true;
var login_details=JSON.parse(localStorage.getItem("login-details")) || [];
document.querySelector("#login").addEventListener("submit",function(){
event.preventDefault();
var email=document.getElementById("mail").value;
var password=document.getElementById("password").value;
console.log(login_details);
if(login_details.length==0){
if(alrts){
addAlrt();
alrts=false;
}
}
if(email=="" || password==""){
if(alrts){
addAlrt();
alrts=false;
}
}
login_details.forEach(function(ele){
if(ele.email==email && password==ele.password){
removeAlrt();
var obj={};
obj["f_name"]=ele.f_name;
obj["l_name"]=ele.l_name;
localStorage.setItem("current_details",JSON.stringify(obj));
window.location.href="details.html";
}else{
if(alrts){
addAlrt();
alrts=false;
}
}
});
});
document.querySelector("#create_Account").addEventListener("click",function(){
window.location.href="create_Account.html";
});
function addAlrt(){
var div=document.createElement("div");
var p=document.createElement("p");
p.innerText="● Incorrect email or password.";
p.setAttribute("id","incorrect_password");
div.append(p);
document.querySelector("#alrt").append(p);
document.getElementById("alrt").style.width="90%"
document.getElementById("alrt").style.height="37px"
document.getElementById("alrt").style.border="1px solid #D02E2E"
document.querySelector("#alrt>p").style.color="#D02E2E";
document.querySelector("#alrt>p").style.fontSize="medium";
document.querySelector("#alrt>p").style.fontFamily="Times New Roman"
document.querySelector("#alrt>p").style.fontWeigth="300";
document.querySelector("#alrt>p").style.margin="5px auto auto auto"
bool=false;
document.querySelector("footer").style.marginTop="0px";
}
function removeAlrt(){
if(document.querySelector("#alrt>p")!=undefined){
document.querySelector("#alrt>p").remove();
document.getElementById("alrt").style.height="";
document.getElementById("alrt").style.border="";
document.getElementById("alrt").style.width="";
document.querySelector("footer").style.marginTop="-90px";
}
}