forked from shreymishra27/Unit-2-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backtoschool.html
410 lines (369 loc) · 15 KB
/
backtoschool.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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
<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">
<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>
<a href="">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_BTS.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="clothes">Clothes</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"))||[]
schooldata =[
{
Image:"https://shopdisney.in/media/catalog/product/4/1/4102b_1.jpg?width=300&height=&canvas=300,&quality=80&bg-color=255,255,255&fit=bounds",
Name: "Disney Mickey Mouse Pencil Box -Blue",
Strikeoffprice :299 ,
Price: 199,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/5/3/5319h_1.jpg?width=300&height=&canvas=300,&quality=80&bg-color=255,255,255&fit=bounds",
Name: "Disney Mickey Mouse Johny Vacuum Insulated Red Water Bottles",
Strikeoffprice : 649 ,
Price: 599,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/8/9/8901736239677.jpg?width=300&height=&canvas=300,&quality=80&bg-color=255,255,255&fit=bounds",
Name: "Disney Minnie Sipper Bottle Dots & Bows for Kids-Multicolor -Size M",
Strikeoffprice :449 ,
Price: 349,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/8/9/8901736239585.jpg?width=300&height=&canvas=300,&quality=80&bg-color=255,255,255&fit=bounds",
Name: "Marvel Iron Man Tumbler Water Bottle for Kids-Red -Size M",
Strikeoffprice : 349 ,
Price: 249,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/i/m/img_1511_2_.jpg",
Name: "Disney Mikey Mouse Multicolor Erasers",
Strikeoffprice : 249 ,
Price: 129,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/1/_/1_12_4.jpg",
Name: "Marvel Avengers Coin Pouch White",
Strikeoffprice : 499 ,
Price: 249,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/1/_/1_12_3.jpg",
Name: "Marvel Avengers Coin Pouch Red",
Strikeoffprice : 499,
Price: 249,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/4/1/4112_2_1.jpg?width=300&height=&canvas=300,&quality=80&bg-color=255,255,255&fit=bounds",
Name: "Disney Frozen Pencil Box -Pink",
Strikeoffprice :249 ,
Price: 199,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/7/1/7123e_2.jpg?width=300&height=&canvas=300,&quality=80&bg-color=255,255,255&fit=bounds",
Name: "Marvel Spiderman Carnival Steel Lunch Box ",
Strikeoffprice : 759 ,
Price: 699,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/9/7/9781474836517.jpg",
Name: "Disney Frozen Sticker Treasury Shape Book",
Strikeoffprice :459 ,
Price: 395,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/8/9/8901736239288.jpg?width=300&height=&canvas=300,&quality=80&bg-color=255,255,255&fit=bounds",
Name: "Marvel Avengers Full Deco Sandwich Box ",
Strikeoffprice : 249 ,
Price: 179,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/4/1/4168f_1.jpg?width=300&height=&canvas=300,&quality=80&bg-color=255,255,255&fit=bounds",
Name: "Marvel Spider-Man Pencil Pouch-Red For ",
Strikeoffprice : 449 ,
Price: 429,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/4/1/4114k_1.jpg?width=300&height=&canvas=300,&quality=80&bg-color=255,255,255&fit=bounds",
Name: "Disney Frozen Pencil Box -purple",
Strikeoffprice : 249 ,
Price: 229,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/4/1/4181_1_1.jpg",
Name: "Marvel Captain America Pencil Pouch-Blue",
Strikeoffprice :499 ,
Price: 399,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/4/1/4180_1_1.jpg",
Name: "Disney Minnie Mouse Mouse Pencil Pouch Pink",
Strikeoffprice : 499 ,
Price: 399,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/4/1/4178_1_1.jpg",
Name: "Disney Mickey Mouse Pencil Pouch-Red",
Strikeoffprice : 499 ,
Price: 399,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/4/1/4177_1_1.jpg",
Name: "Disney Mickey Mouse Pencil Pouch-Blue",
Strikeoffprice : 499 ,
Price: 399,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/9/7/9781789056204.jpg",
Name: "Marvel: Grow Up, Ant-Man! Story Book-Multicolor",
Strikeoffprice : 350 ,
Price: 315,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/9/7/9781838527174.jpg",
Name: "Marvel Spider-Man Story Book-Multicolor",
Strikeoffprice :395 ,
Price: 349 ,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/9/7/9781789058437.jpg",
Name: "Marvel Avengers (F): 1001 Stickers Book-Multicolor",
Strikeoffprice : 495 ,
Price: 359,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/9/7/9781789051131.jpg",
Name: "Marvel Avengers Colouring Fun Pad-Multicolor",
Strikeoffprice :699 ,
Price: 659,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/9/7/9781789056211.jpg",
Name: "Marvel Loki Where Mischief Lies Story Book-Multicolor",
Strikeoffprice : 895 ,
Price: 494,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/9/7/9781838523626.jpg",
Name: "Marvel Avengers Story Book-Multicolor",
Strikeoffprice : 1195 ,
Price: 795,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/9/7/9781789055474.jpg",
Name: "Disney Frozen 2 Magical Story Book-Multicolor",
Strikeoffprice : 259 ,
Price:195 ,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/9/7/9781788109307.jpg",
Name: "Disney Princess Beauty and the Beast",
Strikeoffprice : 350 ,
Price: 299,
// Catagery:""
},
{
Image:"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/9/7/9781788102346.jpg",
Name: "Disney Princess The Little Mermaid",
Strikeoffprice :549 ,
Price: 295 ,
// Catagery:""
},
]
displayData(schooldata)
function handlePriceSort(){
console.log("YES")
var sort= document.querySelector("#sortprice").value
if(sort == "htl"){
schooldata.sort(function (a, b) {
return b.Price - a.Price;
});
displayData(schooldata);
}
if(sort == "lth"){
schooldata.sort(function (a, b) {
return a.Price - b.Price;
});
displayData(schooldata);
}
}
function handleNameSort(){
// console.log("Yes")
var sort = document.querySelector("#sortNames").value
// console.log(sort)
if(sort == "ascending"){
schooldata.sort(function (a,b){
if(a.Name > b.Name) return 1
if(a.Name< b.Name ) return -1
return 0
})
console.log("Yes")
displayData(schooldata)
}
if(sort == "descending"){
schooldata.sort(function (a,b){
if(a.Name > b.Name) return -1
if(a.Name < b.Name ) return 1
return 0
})
console.log("NOO")
displayData(schooldata)
}
}
function displayData(schooldata){
document.querySelector("#grid").innerHTML=""
schooldata.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)
})
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)
}
</script>