forked from shreymishra27/Unit-2-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kids.html
362 lines (329 loc) · 12.1 KB
/
kids.html
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="common.css" />
</head>
<body>
<div class="nav">
<div class="guest">
<a href="guest.html"> <h1>Guest Services</h1></a>
</div>
<div class="logo" onclick="window.location.href='index.html'">
<img
src="https://shopdisney.in/media/logo/stores/1/shopDisney_1.png"
alt=""
/>
</div>
<div class="nav-right">
<div class="sign">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
<path
d="M224 256c70.7 0 128-57.31 128-128s-57.3-128-128-128C153.3 0 96 57.31 96 128S153.3 256 224 256zM274.7 304H173.3C77.61 304 0 381.6 0 477.3c0 19.14 15.52 34.67 34.66 34.67h378.7C432.5 512 448 496.5 448 477.3C448 381.6 370.4 304 274.7 304z"
/>
</svg>
<span id="para">Hi Shrey!</span>
</div>
<div class="wishList">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<!--! Font Awesome Pro 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. -->
<path
d="M0 190.9V185.1C0 115.2 50.52 55.58 119.4 44.1C164.1 36.51 211.4 51.37 244 84.02L256 96L267.1 84.02C300.6 51.37 347 36.51 392.6 44.1C461.5 55.58 512 115.2 512 185.1V190.9C512 232.4 494.8 272.1 464.4 300.4L283.7 469.1C276.2 476.1 266.3 480 256 480C245.7 480 235.8 476.1 228.3 469.1L47.59 300.4C17.23 272.1 .0003 232.4 .0003 190.9L0 190.9z"
/>
</svg>
<a href="">My Wishlist</a>
</div>
<div class="cart">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
<!--! Font Awesome Pro 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. -->
<path
d="M112 112C112 50.14 162.1 0 224 0C285.9 0 336 50.14 336 112V160H400C426.5 160 448 181.5 448 208V416C448 469 405 512 352 512H96C42.98 512 0 469 0 416V208C0 181.5 21.49 160 48 160H112V112zM160 160H288V112C288 76.65 259.3 48 224 48C188.7 48 160 76.65 160 112V160zM136 256C149.3 256 160 245.3 160 232C160 218.7 149.3 208 136 208C122.7 208 112 218.7 112 232C112 245.3 122.7 256 136 256zM312 208C298.7 208 288 218.7 288 232C288 245.3 298.7 256 312 256C325.3 256 336 245.3 336 232C336 218.7 325.3 208 312 208z"
/>
</svg>
<span id="cartno">0</span>
<a href="cartpage.html">My Bag</a>
</div>
</div>
</div>
<br />
<div class="nav-2">
<div class="sale">
<a href="deals.html"><h1>NEW</h1></a>
<h1>|</h1>
<a href="deals.html"><h1>SALE</h1></a>
</div>
<div class="opt">
<a href="gifts.html"><h1>GIFTS</h1></a>
<a href="fashion.html"><h1>FASHION AND ACCESSORIES</h1></a>
<a href="toys.html"><h1>TOYS</h1></a>
<a href="backtoschool.html"> <h1>BACK TO SCHOOL</h1></a>
<a href="afterSign.html"><h1>HOME</h1></a>
<a href="gadgets.html"><h1>GADGETS</h1></a>
</div>
<div class="search-container">
<input type="text" class="search-box" placeholder="Search..." />
<button class="search-button">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<!--! Font Awesome Pro 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. -->
<path
d="M500.3 443.7l-119.7-119.7c27.22-40.41 40.65-90.9 33.46-144.7C401.8 87.79 326.8 13.32 235.2 1.723C99.01-15.51-15.51 99.01 1.724 235.2c11.6 91.64 86.08 166.7 177.6 178.9c53.8 7.189 104.3-6.236 144.7-33.46l119.7 119.7c15.62 15.62 40.95 15.62 56.57 0C515.9 484.7 515.9 459.3 500.3 443.7zM79.1 208c0-70.58 57.42-128 128-128s128 57.42 128 128c0 70.58-57.42 128-128 128S79.1 278.6 79.1 208z"
/>
</svg>
</button>
</div>
</div>
<div id="pic">
<img
src="https://shopdisney.in/media/March/2022/banner/d_Fashion-Accessories.jpg"
alt=""
/>
</div>
<div id="text">
<p>ShopDisney / Fashion & Accessories</p>
</div>
<div id="flex">
<div id="filter">
<select id="sortNames" onchange="handleNameSort()">
<option value="">Sort By Names</option>
<option value="ascending">Ascending</option>
<option value="descending">Descending</option>
</select>
<br />
<select
name="Sort by price"
id="sortprice"
onchange="handlePriceSort()"
>
<option value="">Sort By Price</option>
<option value="htl">High To Low</option>
<option value="lth">Low To High</option>
</select>
<select id="filtercat" onchange="handleCatSort()">
<option value="">Filter by catagery</option>
<option value="T-shirt">T-shirt</option>
<option value="Shoes">Foot Wear</option>
<option value="Bag">Bag</option>
</select>
</div>
<div id="grid"></div>
</div>
</body>
</html>
<script>
cartdata = JSON.parse(localStorage.getItem("cart")) || [];
kidsdata = [
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-001917_1_3.jpg",
Name: "Marvel Spider-Man Blue Sweatshirt",
Strikeoffprice: 2099.0,
Price: 840.0,
Catagery: "T-shirt",
Incart: 1,
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-001766_1_2.jpg",
Name: "Marvel Spider-Man Grey Sweatshirt",
Strikeoffprice: 2199.0,
Price: 880.0,
Catagery: "T-shirt",
Incart: 1,
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-001735_1_2.jpg",
Name: "Marvel Spider-Man No Way Home Tshirt",
Strikeoffprice: 699.0,
Price: 594.0,
Catagery: "T-shirt",
Incart: 1,
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-001762_1_2.jpg",
Name: "Marvel Spider-Man Black Sweatshirt",
Strikeoffprice: 2199.0,
Price: 880.0,
Catagery: "T-shirt",
Incart: 1,
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-001739_1_2.jpg",
Name: "Marvel Spider-Man No Way Home Tshirt",
Strikeoffprice: 799.0,
Price: 679.0,
Catagery: "T-shirt",
Incart: 1,
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-001734_1_2.jpg",
Name: "Marvel Spider-Man No Way Home White Tshirt",
Strikeoffprice: 599.0,
Price: 509.0,
Catagery: "T-shirt",
Incart: 1,
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-001738_1_2.jpg",
Name: "Marvel Spider-Man No Way Home Black Tshir",
Strikeoffprice: 699.0,
Price: 594.0,
Catagery: "T-shirt",
Incart: 1,
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-001731_1_2.jpg",
Name: "Marvel Spider-Man No Way Home Red Tshirt",
Strikeoffprice: 699.0,
Price: 594.0,
Catagery: "T-shirt",
Incart: 1,
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-001770_1_2.jpg",
Name: "Marvel Spider-Man Grey Hoodie",
Strikeoffprice: 2299.0,
Price: 805.0,
Catagery: "T-shirt",
Incart: 1,
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-001760_1_2.jpg",
Name: "Marvel Spider-Man Red Tshirt",
Strikeoffprice: 1299.0,
Price: 520.0,
Catagery: "T-shirt",
Incart: 1,
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-20-21-004632_1_2.jpg",
Name: "Marvel Spider-Man Red Tshirt",
Strikeoffprice: 1099.0,
Price: 479.0,
Catagery: "T-shirt",
Incart: 1,
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-001917_1_3.jpg",
Name: "Marvel Spider-Man Blue Sweatshirt",
Strikeoffprice: 2099.0,
Price: 840.0,
Catagery: "T-shirt",
Incart: 1,
},
];
displayData(kidsdata);
function handlePriceSort() {
console.log("YES");
var sort = document.querySelector("#sortprice").value;
if (sort == "htl") {
kidsdata.sort(function (a, b) {
return b.Price - a.Price;
});
displayData(kidsdata);
}
if (sort == "lth") {
kidsdata.sort(function (a, b) {
return a.Price - b.Price;
});
displayData(kidsdata);
}
}
function handleNameSort() {
// console.log("Yes")
var sort = document.querySelector("#sortNames").value;
// console.log(sort)
if (sort == "ascending") {
kidsdata.sort(function (a, b) {
if (a.Name > b.Name) return 1;
if (a.Name < b.Name) return -1;
return 0;
});
console.log("Yes");
displayData(kidsdata);
}
if (sort == "descending") {
kidsdata.sort(function (a, b) {
if (a.Name > b.Name) return -1;
if (a.Name < b.Name) return 1;
return 0;
});
console.log("NOO");
displayData(kidsdata);
}
}
function handleCatSort() {
var sort = document.querySelector("#filtercat").value;
var sortlist = mensdata.filter(function (elem) {
return elem.Catagery == sort;
});
console.log("Sorted");
displayData(sortlist);
}
function displayData(kidsdata) {
document.querySelector("#grid").innerHTML = "";
kidsdata.map(function (elem) {
var maindiv = document.createElement("div");
maindiv.setAttribute("id", "maindiv");
var div1 = document.createElement("div");
var image = document.createElement("img");
image.src = elem.Image;
image.setAttribute("id", "img");
var name = document.createElement("p");
name.innerText = elem.Name;
div1.append(image, name);
var pricediv = document.createElement("div");
pricediv.setAttribute("id", "pricediv");
var strprice = document.createElement("p");
strprice.innerText = "₹" + " " + elem.Strikeoffprice;
strprice.setAttribute("id", "strike");
var price = document.createElement("P");
price.innerText = "₹" + " " + elem.Price;
var cart = document.createElement("button");
cart.innerText = "Add to cart";
cart.setAttribute("id", "btn");
cart.addEventListener("click", function () {
cartfun(elem);
cartNumber();
});
pricediv.append(strprice, price);
maindiv.append(div1, pricediv, cart);
document.querySelector("#grid").append(maindiv);
});
}
function cartfun(elem) {
cartdata.push(elem);
localStorage.setItem("cart", JSON.stringify(cartdata));
alert("Item added to cart");
console.log(cartdata);
}
function onloadcartnumber() {
var productnumber = localStorage.getItem("cartNumber");
if (productnumber) {
document.querySelector(" #cartno").textContent = productnumber;
}
}
function cartNumber() {
var productnumber = localStorage.getItem("cartNumber") || [];
productnumber = parseInt(productnumber);
if (productnumber) {
localStorage.setItem("cartNumber", productnumber + 1);
document.querySelector("#cartno").textContent = productnumber + 1;
} else {
localStorage.setItem("cartNumber", 1);
document.querySelector("#cartno").innerText = 1;
}
}
onloadcartnumber();
</script>