-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
108 lines (84 loc) · 2.72 KB
/
index.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
let form = document.querySelector("#footForm")
form.addEventListener("submit", getEmail)
function getEmail(e){
e.preventDefault();
if(document.querySelector("#email").value == ""){
alert("Please Enter Your Email")
}else{
alert("Thank You")
}
}
function openNav() {
document.getElementById("mySidenav").style.width = "450px";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
}
function openSearch() {
document.getElementById("mySearch").style.width = "450px";
}
function closeSearch() {
document.getElementById("mySearch").style.width = "0";
}
function openReg() {
document.getElementById("myRegister").style.width = "450px";
}
function closeReg() {
document.getElementById("myRegister").style.width = "0";
}
document.querySelector("#regis").addEventListener("submit", regData)
let regArr = JSON.parse(localStorage.getItem("registerdata")) || [];
function regData(e){
e.preventDefault();
let name = document.querySelector("#regUsename").value
let email = document.querySelector("#regEmail").value
let password = document.querySelector("#regPassword").value
let obj = {
name,
email,
password
}
if(name == "" || email == "" || password == ""){
alert("Some Fields are empty")
}else if(name != "" || email != "" || password != ""){
regArr.push(obj)
localStorage.setItem("registerdata", JSON.stringify(regArr))
alert("Register Successful")
closeReg()
}else{
alert("Wrong Details")
}
}
document.querySelector("#login").addEventListener("submit", loginData)
function loginData(e){
e.preventDefault();
regArr.forEach(function(ele){
if(document.querySelector("#loginEmail").value === ele.email && document.querySelector("#password").value === ele.password){
alert("Login Successful" + " " +ele.name)
closeNav()
}else{
alert("Wrong Details")
}
})
}
document.querySelector("#box1").addEventListener("click", function(){
location.href="shop.html"
})
document.querySelector("#box2").addEventListener("click", function(){
location.href="shop.html"
})
document.querySelector("#box3").addEventListener("click", function(){
location.href="shop.html"
})
document.querySelector("#bath").addEventListener("click", function(){
location.href="shop.html"
})
document.querySelector("#elect").addEventListener("click", function(){
location.href="shop.html"
})
document.querySelector("#cloth").addEventListener("click", function(){
location.href="shop.html"
})
document.querySelector("#paint").addEventListener("click", function(){
location.href="shop.html"
})