-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
212 lines (127 loc) · 5.14 KB
/
script.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
let mode = "light";
let body = document.body;
let toggle_btn = document.getElementById("toggle-btn");
let link_1 = document.getElementById("link-1");
let link_2 = document.getElementById("link-2");
let link_3 = document.getElementById("link-3");
let link_4 = document.getElementById("link-4");
function change_mode() {
if (mode === "light") {
body.style.backgroundColor = "black";
body.style.color = "white";
toggle_btn.style = "justify-content: end";
link_1.style = "color: white;";
link_2.style = "color: white;";
link_3.style = "color: white;";
link_4.style = "color: white;";
mode = "dark";
}
else {
body.style.backgroundColor = "white";
body.style.color = "black";
toggle_btn.style = "justify-content: start";
link_1.style = "color: black;";
link_2.style = "color: black;";
link_3.style = "color: black;";
link_4.style = "color: black;";
mode = "light";
}
}
// --------------------------------------------------------------------------------------------------
function sign_up() {
let name = document.getElementById("name");
let e_mail = document.getElementById("e-mail");
let number = document.getElementById("number");
let password = document.getElementById("password");
let c_password = document.getElementById("c-password");
if (name.value == "") {
alert("Please Enter Your Full Name!");
}
else if (e_mail.value == "") {
alert("Please Enter Your E-Mail Address!");
}
else if (number.value == "") {
alert("Please Enter Your Mobile Number!");
}
else if (password.value == "") {
alert("Please Enter Your Password!");
}
else if (c_password.value == "") {
alert("Please Enter Your Confirm Password!");
}
else if (c_password.value !== password.value) {
alert("Confirm Password Is Not Same As Password!");
}
else {
let get_data = JSON.parse(localStorage.getItem("user")) || [];
let new_user = { name: name.value, e_mail: e_mail.value, number: number.value, password: password.value, c_password: c_password.value };
get_data.push(new_user);
localStorage.setItem("user", JSON.stringify(get_data));
name.value = "";
e_mail.value = "";
e_mail.value = "";
number.value = "";
password.value = "";
c_password.value = "";
alert("You Are Now Registered! Please Log In!");
window.location = "Login Page.html";
}
}
// --------------------------------------------------------------------------------------------------
function log_in() {
let e_mail = document.getElementById("e-mail");
let password = document.getElementById("password");
let checkbox = document.getElementById("check");
let get_data = JSON.parse(localStorage.getItem("user")) || [];
let filtered_data = get_data.filter((filtered_data) => filtered_data.e_mail == e_mail.value);
let existed_data = filtered_data[0];
if (e_mail.value == "") {
alert("Please Enter Your E-Mail Address!");
}
else if (password.value == "") {
alert("Please Enter Your Password!");
}
else if (password.value != existed_data.password) {
alert("Please Enter Correct Password!");
}
else if (checkbox.checked == false) {
alert("Please Select The Check Box!");
}
else if (e_mail.value == existed_data.e_mail && password.value == existed_data.password) {
e_mail.value = "";
password.value = "";
alert("You Are Now Logged In! Please Shop!");
window.location = "index.html";
}
}
// --------------------------------------------------------------------------------------------------
let main_image = document.getElementById("main-img");
function change_image(path) {
main_image.setAttribute("src", path);
}
// --------------------------------------------------------------------------------------------------
let input = document.getElementById("input");
function increase() {
let inputvalue = parseInt(input.value);
let newinputvalue = inputvalue + 1;
input.value = newinputvalue;
}
function decrease() {
if (input.value > 1) {
let inputvalue = parseInt(input.value);
let newinputvalue = inputvalue - 1;
input.value = newinputvalue;
}
}
// --------------------------------------------------------------------------------------------------
let cart_count = document.getElementById("nav-cart-count");
function add_to_cart() {
alert("Added To Cart!");
cart_count.innerText++;
localStorage.setItem("count", JSON.stringify(cart_count.innerText));
}
cart_count.innerText = JSON.parse(localStorage.getItem("count")) || ["3"];
// --------------------------------------------------------------------------------------------------
function offer() {
prompt("Please Enter Your Coupen Code Here!");
}