-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpartiofur.html
620 lines (561 loc) · 24.7 KB
/
partiofur.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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="productpage.css">
<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>Patio Furniture</title>
<script src="https://kit.fontawesome.com/94814fc2e6.js" crossorigin="anonymous"></script>
</head>
<body>
<div class="top_Signup_container">
<div class="top_coupon_container">
<p class="top_coupon_ptag">
Sign up to recieve our latest<b> deals </b> and get a <b>10% off coupon </b>.
</p>
<i class="fa-solid fa-angle-up" style="color: white;"></i>
</div>
<div class="top_coupon_form_div">
<form class="top_banner_form">
<input class value placeholder="enter email address">
<button type="submit">Sign up</button>
</form>
<div class="top_banner_form_terms">
<a class="top_banner_form_a">Terms & Condition</a>
<span class="top_banner_form_span">|</span>
<a class="top_banner_form_a">Privacy Policy</a>
<span class="top_banner_form_span">|</span>
<a class="top_banner_form_a">*You can unsubscribe at any time</a>
</div>
</div>
</div>
<div class = "header_navbar" id="myHeader">
<div class="header_divider"></div>
<div class="search_header">
<a class="overstock_logo" href="index.html"><img src="https://th.bing.com/th?id=OIP.ZFPmAcPcNvdDz6KUkRvVTAHaBR&w=361&h=62&c=8&rs=1&qlt=90&o=6&dpr=1.3&pid=3.1&rm=2" alt="overstock"></a>
<div id="header_searchbar" class="header_search">
<form class="nav_search">
<div class="search_div">
<input placeholder="Search... everything you find ships for free" class="input_search" >
</div>
<div class="magnifine" style="background-color: red; width: 3%; height: 105%;">
<i class="fa-solid fa-magnifying-glass" style="color: white;"></i>
</div>
</form>
</div>
<div class="user-interfrence">
<div class="user_int_logo">
<a href="signin.html"><button id="Accounts"><i class="fa-solid fa-user"></i></button></a>
<p id="accname">Account</p>
</div>
<div id="listdiv" style="display:none;" class="user_int_logo">
<button id="list"><i class="fa-solid fa-arrow-right-from-bracket"></i></button>
<p>Sign Out</p>
</div>
<div class="user_int_logo">
<a href="cart.html"> <button id="cart"><i class="fa-solid fa-cart-plus"></i></button></a>
<p>Cart</p>
</div>
</div>
</div>
<div id="top_nav" class="topnav-contain">
<div class="topnav-links">
<div>
<p>Furniture</p>
</div>
<div>
<p>Outdoor</p>
</div>
<div>
<p>Rugs</p>
</div>
<div>
<p>Decor</p>
</div>
<div>
<p>Bedding</p>
</div>
<div>
<p>Home Improvement</p>
</div>
<div>
<p>Kitchen</p>
</div>
<div>
<p>Lighting</p>
</div>
<div>
<p>Kids & Baby</p>
</div>
<div>
<p>Bath</p>
</div>
<div>
<p>More</p>
</div>
<div class="topnav_links_sign"></div>
<div>
<p>Ideas</p>
</div>
<div>
<p>Sales & Deals</p>
</div>
</div>
</div>
</div>
<div id="sort">
<select id="sort-price">
<option value="">Sort by Price</option>
<option value="asc">Price: Low to High</option>
<option value="desc">Price: High to Low</option>
</select>
</div>
<div id="body-child">
<div id="filter-parent">
<div>
<select id="filter">
<option value="">Select color</option>
<option value="grey">grey</option>
<option value="black">black</option>
<option value="beige">beige</option>
<option value="brown">brown</option>
</select>
</div>
<div>
<select id="filter-material">
<option value="">Select Material</option>
<option value="Metal">Metal</option>
<option value="Wood">Wood</option>
<option value="Cane">Cane</option>
<option value="Leather">Leather</option>
<option value="Fabric">Fabric</option>
</select>
</div>
<div>
<select id="filter-brand">
<option value="">Select Brand</option>
<option value="Christopher Knight Home">Christopher Knight Home</option>
<option value="OVIOS">OVIOS</option>
<option value="Havenside Home">Havenside Home</option>
<option value="SAFAVIEH">SAFAVIEH</option>
<option value="Eilaf">Eilaf</option>
<option value="Holme">Holme</option>
<option value="PATIO">PATIO</option>
<option value="Faux Rattan">Faux Rattan</option>
</select>
</div>
</div>
<div id="parentbox"></div>
</div>
<section>
<div class="footer">
<div class="footer-container">
<div class="footer-container-div">
<div class="footer-col">
<div>MY ACCOUNT</div>
<a href="">
<p>Orders & Returns</p>
</a>
<a href="">
<p>Email Prefernces</p>
</a>
<a href="">
<p>Account Settings</p>
</a>
</div>
</div>
<div class="footer-container-div">
<div class="footer-col">
<div>LET US HELP</div>
<a href="">
<p>Contact Customer Care</p>
</a>
<a href="">
<p>Shipping Information</p>
</a>
<a href="">
<p>Return Policy</p>
</a>
<a href="">
<p>International Help</p>
</a>
<a href="">
<p>Accessibility</p>
</a>
</div>
</div>
<div class="footer-container-div">
<div class="footer-col">
<div>COMPANY INFORMATION</div>
<a href="">
<p>About Overstock™</p>
</a>
<a href="">
<p>Contact Us</p>
</a>
<a href="">
<p>Careers</p>
</a>
<a href="">
<p>Investor Relations</p>
</a>
<a href="">
<p>Sell Your Products</p>
</a>
<a href="">
<p>Supply Chain Transparency</p>
</a>
</div>
</div>
<div class="footer-container-div">
<div class="footer-col">
<div>MORE WAYS TO SHOP</div>
<a href="">
<p>Tips & Ideas</p>
</a>
<a href="">
<p>Deals</p>
</a>
<a href="">
<p>Clearance</p>
</a>
<a href="">
<p>New Arrivals</p>
</a>
</div>
</div>
</div>
</div>
</section>
<section>
<div class="bottom-footer">
<div class="bottom-footer-div">
<div class="bottom-copy">
<p>© Copyright 2023, Overstock.com®, Inc.
<br>799 Coliseum Way Midvale, UT 84047 | 1-800-843-2446</p>
</div>
<div class="bottom-footer-link">
<a href="">
<p class="footer-p">Privacy Policy</p>
</a>
<a href="">
<p class="footer-p">Terms & Conditions</p>
</a>
<a href="">
<p class="footer-p">Promotion Terms</p>
</a>
<a href="">
<div>
<p class="footer-p">Ship to:</p>
</div>
</a>
</div>
</div>
</div>
</section>
</body>
</html>
<script>
var usersign = localStorage.getItem("user");
console.log(usersign);
if(usersign==1){
userlogin();
}
function userlogin(){
if(usersign==1){
document.getElementById("accname").textContent = "User";
}
document.getElementById("listdiv").style.display = "flex"
}
document.getElementById("list").addEventListener("click" , signout);
function signout(){
localStorage.setItem("user" , 0);
usersign = 0;
document.getElementById("accname").textContent = "Accounts"
document.getElementById("listdiv").style.display = "none"
}
var partio_furniture = [{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/14f83a53d94948bd490f952f0c2101de39339a0c/Cape-Coral-Aluminum-Outdoor-Sectional-Sofa-Set-with-Fire-Table-by-Christopher-Knight-Home.jpg?imwidth=480&impolicy=medium",
price:"Sale Starts at INR 148222.95", color:"black", Material:"Metal",Brand:"Christopher Knight Home", MRP:148222.95,
details: "Cape Coral Aluminum Outdoor Sectional Sofa Set with Fire Table by Christopher Knight Home"
},
{
image: "https://ak1.ostkcdn.com/images/products/17632570/Cape-Coral-Outdoor-Aluminum-7-piece-Sofa-Chat-Set-with-Cushions-Fire-Table-by-Christopher-Knight-Home-968e0df6-576d-4c85-b252-9cf60dfa9f1a_1000.jpg?imwidth=480&impolicy=medium",
price:"Sale Starts at INR 231045.79", color:"grey", Material:"Metal",Brand:"Christopher Knight Home", MRP:231045.79,
details: "Cape Coral Aluminum 7-piece Sofa Chat Set by Christopher Knight Home"
},
{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/a85e92d4c3854ff088d6ccbb9bba2589a732cdac/Ovios-Rattan-Wicker-5-piece-Patio-Furniture-Set.jpg?imwidth=480&impolicy=medium",
price:"Sale Starts at INR 71619.64", color:"grey", Material:"Metal",Brand:"OVIOS",MRP:71619.64,
details: "OVIOS 5-piece Patio Conversation Wicker Furniture Set"
},
{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/54efe5b3cf31c8b2d42f57a31286e42c50c45896/Santa-Rosa-Indoor--Outdoor-Solid-Cylinder-Pouf.jpg?imwidth=480&impolicy=medium",
price:"Sale Starts at INR 5640.62", color:"red", Material:"Cane",Brand:"Christopher Knight Home", MRP:5640.62,
details: "Santa Rosa Woven Jute-look Indoor/ Outdoor Solid Pouf "
},
{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/de92e2f8fc1edcc20d3c01350eb9a7bd4704c73b/Plymouth-Patio-Aluminum-30-inch-Outdoor-Wicker-Bar-Stools-%28Set-of-4%29-by-Havenside-Home.jpg?imwidth=480&impolicy=medium",
price:"Sale Starts at INR 70066.87",color:"grey", Material:"Cane",Brand:"Havenside Home", MRP:70066.87,
details: "Plymouth Patio Aluminum 30-inch Outdoor Wicker Bar Stools (Set of 4) by Havenside Home"
},
{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/d722072be198534cb7f7b80f3b32b35a61880e93/COSIEST-Outdoor-3-piece-Rocking-Chair-Bistro-Set.jpg?imwidth=480&impolicy=medium",
price:"Sale Starts at INR 19689.05", color:"beige", Material:"Leather", Brand:"COSIEST", MRP:19689.05,
details: "COSIEST 3-piece Outdoor Rocking Chair Chat Set with Side Table"
},
{
image: "https://ak1.ostkcdn.com/images/products/30027158/Carlisle-Outdoor-Acacia-Wood-Picnic-Dining-Set-by-Christopher-Knight-Home-19cc5379-6345-4ecd-982d-07bd6305a0c2_1000.jpg?imwidth=480&impolicy=medium",
price:"Sale Starts at INR 7278.50", color:"brown", Material:"Wood", Brand:"Christopher Knight Home", MRP:7278.50,
details: "Carlisle Outdoor Acacia Wood Picnic Dining Set by Christopher Knight Home"
},
{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/ec62c13441c34143cc5707e19f244c056664d51e/Ovios-3-piece-Rattan-Wicker-Rocking-Swivel-Chair-Set.jpg?imwidth=480&impolicy=medium",
price:"Sale Starts at INR 47744.86", color:"grey", Material:"Cane",Brand:"OVIOS", MRP:47744.86,
details: "OVIOS 3-piece Rattan Wicker Rocking Swivel Chair Set"
},
{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/8cdf032c2765e466d6dfc77b7087bf2dee2d9a73/Corsica-Outdoor-Round-Dining-Table-by-Christopher-Knight-Home.jpg?imwidth=480&impolicy=medium",
price:"Sale Starts at INR 21107.73", color:"brown", Material:"Cane", Brand:"Christopher Knight Home", MRP:21107.73,
details: "Corsica Outdoor Round Dining Table by Christopher Knight Home"
},
{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/6d2973557df47504e7bdc2116515b9c02c6c77f1/OVIOS-Patio-Furniture-Wicker-5-piece-Outdoor-High-back-Sectional-Set.jpg?imwidth=480&impolicy=medium",
price:"Sale Starts at INR 74364.18", color:"brown", Material:"Cane", Brand:"OVIOS", MRP:74364.18,
details: "OVIOS 5-piece Patio Furniture Wicker Outdoor High-back Sectional Set"
},
{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/32c52940db552ea5179226df0912e6ff906dde78/PHI-VILLA-15ft-Patio-Umbrella-Double-Sided-Outdoor-Market-Extra-Large-Umbrella-with-Crank%2C-Umbrella-Base-Included.jpg?imwidth=480&impolicy=medium",
price:"Starting at INR 15632.72", color:"black", Material:"Cane", Brand:"PHI VILLA", MRP:15632.72,
details: "PHI VILLA 15-foot Rectangular Crank Outdoor Market Umbrella with Base Included"
},
{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/13dcd6c7b41a5a10ab6d127f9ec17087b05afe03/6-Pieces-Patio-Furniture-Set-Outdoor-Sectional-Sofa-Conversation-Set.jpg?imwidth=480&impolicy=medium",
price:"Sale INR 57117.74",color:"black", Material:"Cane",Brand:"Faux Rattan", MRP:57117.74,
details: "6-piece Cushioned Faux Rattan Patio Sectional Sofa Conversation Set"
},
{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/c7d737328186286ef6e3b7de7003a78d3a4d4b75/PATIO-FESTIVAL-5-Piece-Outdoor-Dining-Set.jpg?imwidth=480&impolicy=medium",
price:"Sale INR 35919.99",color:"black", Material:"Metal",Brand:"PATIO", MRP:35919.99,
details: "PATIO FESTIVAL 5-Piece Outdoor Metal Dining Set"
},
{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/29d70f5ce6ddcbc88bc2fb72018973da0a1df3cf/Holme-9-foot-Steel-Market-Patio-Umbrella-with-Tilt-and-Crank.jpg?imwidth=480&impolicy=medium",
price:"Sale Starts at INR 6197.95",color:"beige", Material:"Wood",Brand:"Holme", MRP:6197.95,
details: "Holme 9-foot Steel Market Patio Umbrella with Tilt-and-Crank"
},
{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/e40142d49acca3c1fb61844e4ad594cb33c4a3ae/SAFAVIEH-Outdoor-Cadeo-Wicker-Daybed-with-Pillows-and-Cushions..jpg?imwidth=480&impolicy=medium",
price:"Sale Starts at INR 43406.30",color:"grey", Material:"Cane",Brand:"Christopher Knight Home", MRP:43406.30,
details: "Cape Coral Aluminum Outdoor Sectional Sofa Set with Fire Table by Christopher Knight Home"
},
{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/6123f547c6fc1902fb0053caaa8d302d0b879ec5/Eilaf-48-inch-Round-Eucalyptus-Folding-Table-by-Havenside-Home.jpg?imwidth=480&impolicy=medium",
price:"Sale INR 28479.64", color:"brown", Material:"Wood",Brand:"Eilaf", MRP:28479.64,
details: "Eilaf 48 Round Eucalyptus Folding Table"
},
{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/e40142d49acca3c1fb61844e4ad594cb33c4a3ae/SAFAVIEH-Outdoor-Cadeo-Wicker-Daybed-with-Pillows-and-Cushions..jpg?imwidth=480&impolicy=medium",
price:"Sale Starts at INR 43406.30", color:"grey", Material:"Fabric",Brand:"SAFAVIEH", MRP:43406.30,
details: "SAFAVIEH Outdoor Cadeo Wicker Daybed with Pillows and Cushions"
},
{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/264650cbadd0059f89ac09027159aedd84acd58f/Bossin-Patio-Furniture-Sets-Outdoor-Sectional-Sofa-All-Weather-PE-Rattan-Patio-Conversation-Set.jpg?imwidth=480&impolicy=medium",
price:"Sale Starts at INR 36940.17",color:"black", Material:"Cane",Brand:"COSIEST", MRP:36940.17,
details: "Bossin Patio Furniture Sets Outdoor Sectional Sofa All Weather PE Rattan Patio Conversation Set - 76.4inch x 50inch x 23.6 inch"
},
{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/2b9c360b6cce64ccdce9f4372c4bb3c5a03c0ab3/5-piece-Metal-Outdoor-Patio-Dining-Set-with-4-Stackable-Chairs-and-1-Slat-E-coating-Weather-resistant-SquareTable.jpg?imwidth=480&impolicy=medium",
price:"Starting at INR 37505.58", color:"black", Material:"Metal", Brand:"COSIEST", MRP:37505.58,
details: "5-piece Outdoor E-coated Patio Dining Set with Stackable Chairs"
},
{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/dc07a4022adc818388400904bec333c632f837db/Carlisle-Outdoor-3-Piece-Acacia-Picnic-Dining-Set-with-Benches-by-Christopher-Knight-Home.jpg?imwidth=480&impolicy=medium",
price:"Sale Starts at INR 51683.05", color:"brown", Material:"Wood",Brand:"Christopher Knight Home", MRP:51683.05,
details: "Carlisle Outdoor 3 Piece Acacia Picnic Dining Set with Benches by Christopher Knight Home"
},
{
image: "https://ak1.ostkcdn.com/images/products/is/images/direct/e691b824f46e706521ca4f9929d886fd78b0fcc5/Elize-Outdoor-French-Bistro-Chair-%28Set-of-2%29-by-Christopher-Knight-Home.jpg?imwidth=480&impolicy=medium",
price:"Sale Starts at INR 23034.63", color:"brown", Material:"Fabric",Brand:"Christopher Knight Home", MRP:23034.63,
details: "Elize Outdoor French Bistro Chair (Set of 2) by Christopher Knight Home"
},
];
partio_furniture.map(function(elm) {
var div1 = document.createElement("div");
div1.setAttribute("id", "product");
var image = document.createElement("img");
image.setAttribute("src", elm.image);
image.setAttribute("id", "image-product");
var imagediv = document.createElement("div");
imagediv.setAttribute("id", "image-div")
imagediv.append(image)
var div2 = document.createElement("div");
div2.setAttribute("id", "childbox")
var div3 = document.createElement("div");
div3.append(div2)
var p1 = document.createElement("p");
p1.textContent = elm.price;
p1.setAttribute("id", "price-product")
var p2 = document.createElement("p");
p2.textContent = elm.details;
p2.setAttribute("id", "product-info")
var btn = document.createElement("button");
btn.innerHTML='<i class="fas fa-cart-plus"></i> Add to Cart';
btn.setAttribute("id", "addtocart")
div2.append(p1, p2, btn);
div1.append(imagediv, div3);
document.querySelector("#parentbox").append(div1);
btn.addEventListener("click", function() {
addtocartFun(elm);
});
});
function addtocartFun(elm){
var cartArr = JSON.parse(localStorage.getItem("add-items")) || [];
cartArr.push(elm);
localStorage.setItem("add-items", JSON.stringify(cartArr));
console.log(cartArr);
}
//filter by color
var filterDropdown = document.getElementById("filter");
filterDropdown.addEventListener("change", filterProducts);
function filterProducts() {
var selectedColor = filterDropdown.value;
var filtered;
if (selectedColor !== "") {
filtered = partio_furniture.filter(function(ele) {
return ele.color === selectedColor;
});
} else {
filtered = partio_furniture;
}
var parentBox = document.getElementById("parentbox");
parentBox.innerHTML = "";
for (var i = 0; i < filtered.length; i++) {
var childBox = document.createElement("div");
childBox.id = "childbox";
var image = document.createElement("img");
image.src = filtered[i].image;
var details = document.createElement("p");
details.textContent = filtered[i].details;
var price = document.createElement("p");
price.textContent = filtered[i].price;
var button = document.createElement("button");
button.innerHTML='<i class="fas fa-cart-plus"></i> Add to Cart';
childBox.appendChild(image);
childBox.appendChild(price);
childBox.appendChild(details);
childBox.appendChild(button);
parentBox.appendChild(childBox);
}
}
//filter by material
var filterMaterial = document.getElementById("filter-material");
filterMaterial.addEventListener("change", filterMatFun);
function filterMatFun() {
var selectedMat = filterMaterial.value;
var filtered;
if (selectedMat !== "") {
filtered = partio_furniture.filter(function(ele) {
return ele.Material === selectedMat;
});
} else {
filtered = partio_furniture;
}
var parentBox = document.getElementById("parentbox");
parentBox.innerHTML = "";
for (var i = 0; i < filtered.length; i++) {
var childBox = document.createElement("div");
childBox.id = "childbox";
var image = document.createElement("img");
image.src = filtered[i].image;
var details = document.createElement("p");
details.textContent = filtered[i].details;
var price = document.createElement("p");
price.textContent = filtered[i].price;
var button = document.createElement("button");
button.innerHTML='<i class="fas fa-cart-plus"></i> Add to Cart';
childBox.appendChild(image);
childBox.appendChild(price);
childBox.appendChild(details);
childBox.appendChild(button);
parentBox.appendChild(childBox);
}
}
var filterBrand = document.getElementById("filter-brand");
filterBrand.addEventListener("change", filterBranFun);
function filterBranFun() {
var selectedBran = filterBrand.value;
var filtered;
if (selectedBran !== "") {
filtered = partio_furniture.filter(function(ele) {
return ele.Brand === selectedBran;
});
} else {
filtered = partio_furniture;
}
var parentBox = document.getElementById("parentbox");
parentBox.innerHTML = "";
for (var i = 0; i < filtered.length; i++) {
var childBox = document.createElement("div");
childBox.id = "childbox";
var image = document.createElement("img");
image.src = filtered[i].image;
var details = document.createElement("p");
details.textContent = filtered[i].details;
var price = document.createElement("p");
price.textContent = filtered[i].price;
var button = document.createElement("button");
button.innerHTML='<i class="fas fa-cart-plus"></i> Add to Cart';
childBox.appendChild(image);
childBox.appendChild(price);
childBox.appendChild(details);
childBox.appendChild(button);
parentBox.appendChild(childBox);
}
}
function sortFurnitureByPrice() {
const sortValue = document.getElementById("sort-price").value;
if (sortValue === "asc") {
partio_furniture.sort((a, b) => {
return parseFloat(a.price.replace(/[^0-9.-]+/g, "")) - parseFloat(b.price.replace(/[^0-9.-]+/g, ""));
});
} else if (sortValue === "desc") {
partio_furniture.sort((a, b) => {
return parseFloat(b.price.replace(/[^0-9.-]+/g, "")) - parseFloat(a.price.replace(/[^0-9.-]+/g, ""));
});
}
renderFurniture();
}
document.getElementById("sort-price").addEventListener("change", sortFurnitureByPrice);
function renderFurniture() {
const parentbox = document.getElementById("parentbox");
parentbox.innerHTML = "";
const filterColor = document.getElementById("filter").value;
const filterMaterial = document.getElementById("filter-material").value;
const filterBrand = document.getElementById("filter-brand").value;
partio_furniture.forEach((furniture) => {
if (
(filterColor === "" || furniture.color === filterColor) &&
(filterMaterial === "" || furniture.Material === filterMaterial) &&
(filterBrand === "" || furniture.Brand === filterBrand)
) {
const childbox = document.createElement("div");
childbox.id = "childbox";
const img = document.createElement("img");
img.src = furniture.image;
childbox.appendChild(img);
const p2 = document.createElement("p");
p2.innerHTML = furniture.price;
childbox.appendChild(p2);
const p = document.createElement("p");
p.innerHTML = furniture.details;
childbox.appendChild(p);
const button = document.createElement("button");
button.innerHTML='<i class="fas fa-cart-plus"></i> Add to Cart';
childbox.appendChild(button);
parentbox.appendChild(childbox);
}
});
}
</script>