-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbestseller.html
223 lines (207 loc) · 7.07 KB
/
bestseller.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
<!DOCTYPE html>
<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>Best-seller</title>
<!-- <link rel="stylesheet" href="bestseller.css"> -->
<link rel="stylesheet" href="./css/index.css">
</head>
<body>
<h3>Best Seller</h3>
<div class="filter">
<h3>FILTER BY</h3>
<div class="filter-option">
<select id="filter-price" onclick="filterPrice()">
<option value="">PRICE</option>
<option value="htl">High To Low </option>
<option value="lth">Low To High</option>
</select>
<select id="filter-category" onclick="filterCat()">
<option value="">BY CATEGORY</option>
<option value="Ring">RINGS</option>
<option value="Earrings">EARINGS</option>
<option value="Pendant">PENDANTS</option>
</select>
<select id="filter-material" onclick="filterMat()">
<option value="">BY MATERIAL</option>
<option value="Diamond">DIAMONDS</option>
<option value="Gold">GOLD</option>
</select>
<select id="filter-gender">
<option value="">BY GENDER</option>
<option value="men">MEN</option>
<option value="women">WOMEN</option>
</select>
</div>
</div>
<div id="container">
</div>
</body>
</html>
<script>
var bestSellerData = [
// rings
{
img_url: "https://cf-cdn.pcjeweller.com/public/uploads/catalog/product/large/l/LR02642-6_897.jpg",
name: "The Cathi Diamond Ring",
price: 19927,
act_price: 26569,
offer: "You Save ₹" + this.act_price - this.price + "[25% off]",
nature: "Metal 14KT Yellow Gold",
specification: "Diamond IJ-SI (0.12 ct)",
},
{
img_url: "https://cf-cdn.pcjeweller.com/public/uploads/catalog/product/large/l/LR02642-6_897.jpg",
name: "The Eddie Diamond Ring",
price: 18927,
act_price: 26569,
nature: "Metal 14KT Yellow Gold",
specification: "Diamond IJ-SI (0.12 ct)",
},
{
img_url: "https://cf-cdn.pcjeweller.com/public/uploads/catalog/product/large/l/LR02642-6_897.jpg",
name: "The Zrimat Gold Ring",
price: 22927,
act_price: 26569,
nature: "Metal 14KT Yellow Gold",
specification: "Diamond IJ-SI (0.12 ct)",
},
{
img_url: "https://cf-cdn.pcjeweller.com/public/uploads/catalog/product/large/l/LR02642-6_897.jpg",
name: "The Helaine Diamond Ring",
price: 17927,
act_price: 26569,
nature: "Metal 14KT Yellow Gold",
specification: "Diamond IJ-SI (0.12 ct)",
},
//earings
{
img_url: "https://cf-cdn.pcjeweller.com/public/uploads/catalog/product/preview/e/ER01501-1_555.jpg",
name: "The Keaghan Diamond Earrings",
price: 13927,
act_price: 26569,
nature: "Metal 14KT Yellow Gold",
specification: "Diamond IJ-SI (0.12 ct)",
},
{
img_url: "https://cf-cdn.pcjeweller.com/public/uploads/catalog/product/preview/e/ER01443AS-1_987.jpg",
name: "The Chahna Diamond Earrings",
price: 16327,
act_price: 26569,
nature: "Metal 14KT Yellow Gold",
specification: "Diamond IJ-SI (0.12 ct)",
},
{
img_url: "https://cf-cdn.pcjeweller.com/public/uploads/catalog/product/preview/e/ER01739-1_474.jpg",
name: "The Acasha Diamond Earrings",
price: 14927,
act_price: 26569,
nature: "Metal 14KT Yellow Gold",
specification: "Diamond IJ-SI (0.12 ct)",
},
{
img_url: "https://cf-cdn.pcjeweller.com/public/uploads/catalog/product/preview/e/ER01041-1_856.jpg",
name: "The Davia Diamond Earrings",
price: 29927,
act_price: 36569,
nature: "Metal 14KT Yellow Gold",
specification: "Diamond IJ-SI (0.12 ct)",
},
//pedariant
{
img_url: "https://cf-cdn.pcjeweller.com/public/uploads/catalog/product/preview/p/PS00005PG-5_956.jpg",
name: "The Frida Diamond & Gemstone Pendant",
price: 49927,
act_price: 56569,
nature: "Metal 14KT Yellow Gold",
specification: "Diamond IJ-SI (0.12 ct)",
},
{
img_url: "https://cf-cdn.pcjeweller.com/public/uploads/catalog/product/preview/p/PS00932P-5_338.jpg",
name: "The Landon Diamond Pendant",
price: 14527,
act_price: 26569,
nature: "Metal 14KT Yellow Gold",
specification: "Diamond IJ-SI (0.12 ct)",
},
{
img_url: "https://cf-cdn.pcjeweller.com/public/uploads/catalog/product/preview/p/PS00936P-5_398.jpg",
name: "The Vineeta Diamond Pendant",
price: 15627,
act_price: 26569,
nature: "Metal 14KT Yellow Gold",
specification: "Diamond IJ-SI (0.12 ct)",
},
{
img_url: "https://cf-cdn.pcjeweller.com/public/uploads/catalog/product/preview/p/PS00953P-5_548.jpg",
name: "The Nearra Diamond Pendant",
price: 16327,
act_price: 26569,
nature: "Metal 14KT Yellow Gold",
specification: "Diamond IJ-SI (0.12 ct)",
},
];
window.addEventListener("load", function () {
displayData(bestSellerData);
});
function filterPrice() {
var selected = document.querySelector("#filter-price").value;
console.log(selected);
if (selected == "htl") {
bestSellerData.sort(function (a, b) {
return b.price - a.price;
});
displayData(bestSellerData);
};
if (selected == "lth") {
bestSellerData.sort(function (a, b) {
return a.price - b.price;
});
displayData(bestSellerData);
}
};
function filterCat() {
var selected = document.querySelector("#filter-category").value;
// console.log(typeof(selected));
var filterData = bestSellerData.filter(function (e) {
return e.name.includes(selected);
});
displayData(filterData);
}
function filterMat(){
var selected=document.querySelector("#filter-material").value;
console.log(selected);
var filterData=bestSellerData.filter(function(e){
return e.name.includes(selected);
});
displayData(filterData);
}
function displayData(bestSellerData) {
document.querySelector("#container").innerText = "";
bestSellerData.map(function (e) {
var div = document.createElement("div");
var img = document.createElement("img");
img.src = e.img_url;
var p1 = document.createElement("p");
p1.innerText = e.name;
var p2 = document.createElement("p");
p2.setAttribute("id", "bestpricepara")
p2.innerText = "₹" + e.price;
var span = document.createElement("span");
var mark = document.createElement("del");
mark.innerText = "₹" + e.act_price;
span.append(mark);
p2.append(span);
var p3 = document.createElement("p3");
p3.innerText = "You Save ₹" + [e.act_price - e.price] + " [" + Math.round(100 - (e.price / e.act_price) * 100) + "% off]";
var p4 = document.createElement("p");
p4.innerText = e.nature;
var p5 = document.createElement("p");
p5.innerText = e.specification;
div.append(img, p1, p2, p3, p4, p5);
document.querySelector("#container").append(div);
});
};
</script>