forked from Jadhao2500/ManageEngineProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.js
More file actions
93 lines (80 loc) · 3.18 KB
/
log.js
File metadata and controls
93 lines (80 loc) · 3.18 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
let arr= document.querySelectorAll(".sideimg");
console.log(arr);
let i=1;
arr[0].style.display="flex";
setInterval(displaysideimage,3000)
function displaysideimage(){
for(let j=0;j<arr.length;j++){
arr[j].style.display="none"
}
if(i==arr.length){
i=0;
}
arr[i].style.display="flex";
i++;
}
document.querySelector("form").addEventListener("submit",displayPasswordBox);
function displayPasswordBox(){
event.preventDefault();
let passwordBox=document.getElementById("passwordBox")
document.getElementById("submit").value="SIGN IN";
document.getElementById("submit").style.marginBottom="70px"
document.getElementById("email").style.marginBottom="20px";
document.getElementById("email").style.borderRadius="10px";
document.getElementById("email").style.width="75%";
document.getElementById("email").style.backgroundColor="white";
document.getElementById("hidePassword").style.display="none";
document.getElementById("skipComment").style.display="none";
document.getElementById("options").style.display="none";
document.getElementById("br1").style.display="none";
document.getElementById("passwordBox").style.display="block";
document.getElementById("showPassword").style.display="block";
document.getElementById("changes").style.display="block";
document.getElementById("eye").style.display="block";
document.querySelector("form").addEventListener("submit",login);
}
async function login(){
event.preventDefault();
let userpassword=document.getElementById("passwordBox").value
let useremail=document.getElementById("email").value
// console.log(useremail,userpassword);
let data= await getuser(useremail,userpassword);
console.log(data)
let filterarray=data.filter(function(user){
return(user.Email==useremail)&&(user.Password==userpassword);
})
console.log(filterarray)
if(filterarray.length==0){
document.getElementById("alertmess").style.display="block";
document.getElementById("passwordBox").style.border="2px solid #ff8484"
document.getElementById("submit").style.marginBottom="30px"
}else{
localStorage.setItem("userInfo",JSON.stringify(filterarray[0]));
window.location.href="./pages/index.html";
}
}
document.getElementById("eye").addEventListener("click",displayPassword);
document.getElementById("eyeopen").addEventListener("click",displayPassword);
let eyecheck=0;
function displayPassword(){
if(eyecheck==0){
document.getElementById("passwordBox").setAttribute("type","text")
document.getElementById("eyeopen").style.display="block";
document.getElementById("eye").style.display="none";
eyecheck=1;
}else{
document.getElementById("passwordBox").setAttribute("type","password")
document.getElementById("eye").style.display="block";
document.getElementById("eyeopen").style.display="none";
eyecheck= 0;
}
}
async function getuser(e,p){
try {
let res=await fetch(` http://localhost:3000/users`);
let data=await res.json();
return data;
} catch (error) {
console.log(error)
}
}