Skip to content

Commit e2ab1de

Browse files
committed
Fixed Filter bug
1 parent 05833a1 commit e2ab1de

File tree

6 files changed

+433
-20
lines changed

6 files changed

+433
-20
lines changed

app.js

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ window.onclick = function(e){
6565
let NavClass = e.target.parentElement.classList
6666
if(NavClass == "Show"){
6767
Nav.classList.toggle('Show');
68+
}else{
69+
console.log(" ");
6870
}
6971
}
7072
// give header background on scrolling
@@ -103,25 +105,34 @@ function CreateProductCard(Pimage, PName, PCompany, PMake, PCost){
103105
CardsHolder.append(newCard);
104106
}
105107

108+
109+
106110
// Displaying Products depending on the category the user wants
107-
// ProductsCategory.addEventListener('change', ()=>{
108-
// console.log(ProductsCategory.value);
109-
// let categoryChoice = ProductsCategory.value;
110-
// fetch("./products.json")
111-
// .then(response => response.json())
112-
// .then(data =>{
113-
// data.map(data=>{
114-
// if(data.category === categoryChoice){
115-
// CardsHolder.innerHTML = "";
116-
// let FilteredData = data;
117-
// console.table(FilteredData);
118-
// // FilteredData.map(FilteredData=>{
119-
// // // create card for each data
120-
// // CreateProductCard(FilteredData.image, FilteredData.name, FilteredData.company, FilteredData.make, FilteredData.cost)
121-
// // })
122-
// }
123-
// })
124-
125-
// });
111+
ProductsCategory.addEventListener('change', ()=>{
112+
CardsHolder.innerHTML = "";
113+
if((ProductsCategory.value) === "All"){
114+
GetProducts();
115+
}else{
116+
SortByCategory(ProductsCategory.value)
117+
}
118+
119+
// CardsHolder.style.height = "unset";
120+
})
121+
122+
123+
// CreateCardforArray(SortByCategory("Computer"))
124+
125+
function SortByCategory(userChoice){
126+
let source = `./${userChoice}.json`
127+
console.log(source);
128+
fetch(source)
129+
.then(response => response.json())
130+
.then(data =>{
131+
console.log(data);
132+
data.map(data=>{
133+
CreateProductCard(data.image, data.name, data.company, data.make, data.cost)
134+
})
135+
})
126136

127-
// })
137+
}
138+

camera.json

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
[
2+
{
3+
"name":"Nikon D56 Camera",
4+
"image":"Images/Camera1.png",
5+
"company": "Camera",
6+
"make": "CM001 Brand New",
7+
"cost": "20000",
8+
"category":"Camera"
9+
},
10+
{
11+
"name":"Canon ED6s ",
12+
"image":"Images/Canon Camera1.png",
13+
"company": "Canon",
14+
"make": "EDS 5500 Brand New",
15+
"cost": "60000",
16+
"category":"Camera"
17+
},
18+
{
19+
"name":"Sony 4K",
20+
"image":"Images/HdCamera1.png",
21+
"company": "Sony",
22+
"make": "HD4K Brand New",
23+
"cost": "90000",
24+
"category":"Camera"
25+
},
26+
{
27+
"name":"Canon 4K",
28+
"image":"Images/HdCamera2 Canon.png",
29+
"company": "Canon",
30+
"make": "4K Brand New",
31+
"cost": "97000",
32+
"category":"Camera"
33+
},
34+
{
35+
"name":"Nikon Camera",
36+
"image":"Images/Nikon Camera1.png",
37+
"company": "Nikon",
38+
"make": "D5600 Brand New",
39+
"cost": "45000",
40+
"category":"Camera"
41+
},
42+
{
43+
"name":"NikonD67 Camera",
44+
"image":"Images/Nikon Camera2.png",
45+
"company": "Nikon",
46+
"make": " Brand New",
47+
"cost": "37000",
48+
"category":"Camera"
49+
},
50+
{
51+
"name":"Portable Sony Camera",
52+
"image":"Images/PortableCamera1.png",
53+
"company": "Sony",
54+
"make": "4X Portable Brand New",
55+
"cost": "17000",
56+
"category":"Camera"
57+
},
58+
{
59+
"name":"Samsung Shoot",
60+
"image":"Images/Samsung Camera1.png",
61+
"company": "Samsung",
62+
"make": "35ES Brand New",
63+
"cost": "32000",
64+
"category":"Camera"
65+
},
66+
{
67+
"name":"Sony Full HD",
68+
"image":"Images/SonyCamera1.png",
69+
"company": "Sony",
70+
"make": "EY1 Full HD Brand New",
71+
"cost": "47770",
72+
"category":"Camera"
73+
},
74+
{
75+
"name":"Canon2 Camera",
76+
"image":"Images/Nikon Camera2.png",
77+
"company": "Canon",
78+
"make": " Brand New",
79+
"cost": "37000",
80+
"category":"Camera"
81+
}
82+
]

computer.json

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
[
2+
{
3+
"name":"Apple Desktop",
4+
"image":"Images/ComputerA1.png",
5+
"company": "Apple",
6+
"make": "Desktop Monitor",
7+
"cost": "66900",
8+
"category":"Computer"
9+
},
10+
{
11+
"name":"Apple MiniDesktop",
12+
"image":"Images/ComputerA2.png",
13+
"company": "Apple",
14+
"make": "Desktop Monitor",
15+
"cost": "60900",
16+
"category":"Computer"
17+
},
18+
{
19+
"name":"Mackbook",
20+
"image":"Images/ComputerA3.png",
21+
"company": "Apple",
22+
"make": "Mackbook AZ1",
23+
"cost": "89900",
24+
"category":"Computer"
25+
},
26+
{
27+
"name":"Abus Gaming Computer",
28+
"image":"Images/ComputerG1.png",
29+
"company": "Abus",
30+
"make": "8th Gen Blue Brand",
31+
"cost": "55500",
32+
"category":"Computer"
33+
},
34+
{
35+
"name":"IGG Gaming Computer",
36+
"image":"Images/ComputerG2.png",
37+
"company": "IGG",
38+
"make": "8th Gen Red Brand",
39+
"cost": "56900",
40+
"category":"Computer"
41+
},
42+
{
43+
"name":"RichTonics Gaming Computer",
44+
"image":"Images/ComputerG3.png",
45+
"company": "Richtonics",
46+
"make": "6th Gen Gaming Computer",
47+
"cost": "44999",
48+
"category":"Computer"
49+
},
50+
{
51+
"name":"RichTonicsHC Gaming Computer",
52+
"image":"Images/ComputerG4.png",
53+
"company": "Richtonics",
54+
"make": "6th Gen GamingHC Computer",
55+
"cost": "47999",
56+
"category":"Computer"
57+
},
58+
{
59+
"name":"RichTonicsRD Gaming Computer",
60+
"image":"Images/ComputerG5.png",
61+
"company": "Richtonics",
62+
"make": "6th Gen Red Gaming Computer",
63+
"cost": "41999",
64+
"category":"Computer"
65+
},
66+
{
67+
"name":"RichTonics Water Cooled Computer",
68+
"image":"Images/ComputerG6.png",
69+
"company": "Richtonics",
70+
"make": "9th Gen UltraGaming Computer",
71+
"cost": "74999",
72+
"category":"Computer"
73+
}
74+
]

headphone.json

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
[
2+
{
3+
"name":"RichTonics White",
4+
"image":"Images/Headphone1.png",
5+
"company": "RichTonics",
6+
"make": " White E1 ",
7+
"cost": "1500",
8+
"category":"Headphone"
9+
},
10+
{
11+
"name":"RichTonics black with Mic",
12+
"image":"Images/Headphone2.png",
13+
"company": "RichTonics",
14+
"make": " Black 001 Brand New",
15+
"cost": "1700",
16+
"category":"Headphone"
17+
},
18+
{
19+
"name":"Bull Reds",
20+
"image":"Images/Headphone3.png",
21+
"company": "Bull",
22+
"make": "Red,Brand New",
23+
"cost": "2000",
24+
"category":"Headphone"
25+
},
26+
{
27+
"name":"Bull Yellows",
28+
"image":"Images/Headphone4.png",
29+
"company": "Bull",
30+
"make": "Yellow Brand New",
31+
"cost": "2000",
32+
"category":"Headphone"
33+
},
34+
{
35+
"name":"Bull White Super",
36+
"image":"Images/Headphone5.png",
37+
"company": "Bull",
38+
"make": "White Brand",
39+
"cost": "2100",
40+
"category":"Headphone"
41+
},
42+
{
43+
"name":"Rich Blues",
44+
"image":"Images/Headphone6.png",
45+
"company": "Bull",
46+
"make": "Blue 03S Brand New",
47+
"cost": "900",
48+
"category":"Headphone"
49+
},
50+
{
51+
"name":"Black Fire ",
52+
"image":"Images/Headphone7.png",
53+
"company": "Bull",
54+
"make": "Black Brand New",
55+
"cost": "2900",
56+
"category":"Headphone"
57+
},
58+
{
59+
"name":"Girly Cherrys",
60+
"image":"Images/Headphone8.png",
61+
"company": "Bull",
62+
"make": "Pink Brand New",
63+
"cost": "2000",
64+
"category":"Headphone"
65+
},
66+
{
67+
"name":"Fer Racers Headphones",
68+
"image":"Images/Headphone9.png",
69+
"company": "Bull",
70+
"make": "Red Brand New",
71+
"cost": "5000",
72+
"category":"Headphone"
73+
},
74+
{
75+
"name":"OrangeRiches with Mic",
76+
"image":"Images/Headphone10.png",
77+
"company": "Bull",
78+
"make": "Orange Brand New",
79+
"cost": "7000",
80+
"category":"Headphone"
81+
}
82+
]

phone.json

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
[
2+
{
3+
"name":"Samsung S10 2019",
4+
"image":"Images/Phone1.png",
5+
"company": "Samsung",
6+
"make": "S10 Black Brand New",
7+
"cost": "20000",
8+
"category":"Phone"
9+
},
10+
{
11+
"name":"Iphane5 mini",
12+
"image":"Images/Phone2.png",
13+
"company": "Apple",
14+
"make": "i5 mini Black Brand New",
15+
"cost": "15000",
16+
"category":"Phone"
17+
},
18+
{
19+
"name":"Iphane 5",
20+
"image":"Images/Phone3.png",
21+
"company": "Apple",
22+
"make": "i5 Black Brand New",
23+
"cost": "20000",
24+
"category":"Phone"
25+
},
26+
{
27+
"name":"Iphane 6",
28+
"image":"Images/Phone4.png",
29+
"company": "Apple",
30+
"make": "i6 Black Brand New",
31+
"cost": "23000",
32+
"category":"Phone"
33+
},
34+
{
35+
"name":"iphane 5 Silk",
36+
"image":"Images/Phone5.png",
37+
"company": "Apple",
38+
"make": "Silver Grey Brand New",
39+
"cost": "25000",
40+
"category":"Phone"
41+
},
42+
{
43+
"name":"iphane 5 White",
44+
"image":"Images/Phone6.png",
45+
"company": "Apple",
46+
"make": "White-black Brand New",
47+
"cost": "25000",
48+
"category":"Phone"
49+
},
50+
{
51+
"name":"iphane 7",
52+
"image":"Images/Phone7.png",
53+
"company": "Apple",
54+
"make": "Pink-White Brand New",
55+
"cost": "27000",
56+
"category":"Phone"
57+
},
58+
{
59+
"name":"iphane8 mini",
60+
"image":"Images/Phone8.png",
61+
"company": "Apple",
62+
"make": "red, blue,white Brands",
63+
"cost": "25000",
64+
"category":"Phone"
65+
},
66+
{
67+
"name":"iphoneX",
68+
"image":"Images/Phone9.png",
69+
"company": "Apple",
70+
"make": "Black,Blue,Grey White Brands",
71+
"cost": "35000",
72+
"category":"Phone"
73+
},
74+
{
75+
"name":"iphone9 mini",
76+
"image":"Images/Phone10.png",
77+
"company": "Apple",
78+
"make": "White Brand New",
79+
"cost": "35000",
80+
"category":"Phone"
81+
}
82+
]

0 commit comments

Comments
 (0)