-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbestseller.html
489 lines (398 loc) · 14.1 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
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
<!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">
<link rel="stylesheet" href="./styles/new.css">
<link rel="stylesheet" href="./styles/navbar.css">
<link rel="stylesheet" href="./styles/footer.css">
<title>Bestsellers</title>
<link rel="shortcut icon" href="./images/Geekbuying_title_logo.png" type="image/x-icon">
</head>
<body>
<div id="navbar"></div>
<div id="main_content">
<div id="heading"><h1>Bestselling</h1></div>
<div id="master_content">
<div id="categories">
<div id="categories_item">
<h3 id="catg">All Categories</h3>
<details class="drop">
<summary>Smart Home & Garden</summary>
<uL>
<li>Robot Vacuum Cleaner</li>
<li>Cordless Vacuum Cleaners</li>
<li>Ceiling Lights</li>
<li>Hair Care & Salon</li>
<li>Clocks</li>
<li>Bakeware</li>
<li>Furniture</li>
<li>Tableware</li>
<li>Kitchen Appliances</li>
<li>Personal Care</li>
<li>LED Outdoor Lights</li>
<li>Robot Vacuum Cleaner Accessories</li>
<li>Cordless Vacuum Cleaner Accessories</li>
<li>Others</li>
<li>Night Light</li>
<li>Cosmetics</li>
<li>Light Gadgets</li>
<li>Dog Supplies</li>
<li>Cat Supplies</li>
<li>Other Pet Supplies</li>
</uL>
</details >
<details class="drop">
<summary>Consumer Electronics</summary>
<uL>
<li>Earbud Headphones</li>
<li>FDM 3D Printers</li>
<li>Laser Engraved & Cutters</li>
<li>3D Printer Accessories</li>
<li>Projectors</li>
<li>Accessories</li>
<li>Measurement and Analysis Instrument</li>
<li>Power Banks</li>
<li>Camera & Camrecorder</li>
<li>Other Accessories</li>
</uL>
</details>
<details class="drop">
<summary>Sports & Outdoors</summary>
<uL>
<li>Outdoor Generator & Portable Power</li>
<li>Water Sports</li>
<li>Survival & Emergency Gear</li>
<li>Tent & Hammock</li>
<li>Sports & Action Cameras</li>
<li>Other Outdoor Gears</li>
<li>Bikes</li>
<li>travel Supplies</li>
<li>Bike Bags</li>
<li>Other Accessories</li>
<li>Basketball</li>
<li>Soccer</li>
</uL>
</details>
<details class="drop">
<summary>Toy & Hobbies</summary>
<uL>
<li>RC Quadcopters</li>
<li>RC Boats</li>
<li>RC cars</li>
<li>FPV System</li>
<li>RC Helicopter</li>
<li>RC Boat Parts</li>
<li>Building Sets & Blocks</li>
<li>Trampoline</li>
</uL>
</details>
<details class="drop">
<summary>Automobiles & Motorcycles</summary>
<uL>
<li>Other Gadgets</li>
<li>Car Repairs & Maintenance</li>
<li>Garage Equipment & Tools</li>
</uL>
</details>
<details class="drop">
<summary>Wearable Devices</summary>
<uL>
<li>Smart Watches</li>
<li>Smart Bracelets</li>
</uL>
</details>
<details class="drop">
<summary>TV Boxes & Mini PCs</summary>
<uL>
<li>Android TV Boxes</li>
<li>Window Mini PCs</li>
</uL>
</details>
<details class="drop">
<summary>Security System</summary>
<uL>
<li>IP Cameras</li>
<li>Video Door Phones</li>
</uL>
</details>
<details class="drop">
<summary>Phones & Accessories</summary>
<uL>
<li>5G Smartphones</li>
<li>iPhones Accessories</li>
</uL>
</details>
<details class="drop">
<summary>Computers, Tablet & Accessories</summary>
<uL>
<li>Android Tablet</li>
<li>Gaming Laptop</li>
<li>Monitors</li>
</uL>
</details>
</div>
</div>
<div id="filter_item">
<div id="filter">
<div id="days"><p class="filtr">New Arrived:</p><button onclick="arrived()">7 days</button><button onclick="arrived2()">15 Days</button><button onclick="arrived3()">30 Days</button></div>
<div id="filter1"><p class="filtr">Filter:</p><select name="" id="country" onchange="filcountry()">
<option value="Default">Ship From</option>
<option value="Europe">Europe</option>
<option value="Poland">Poland</option>
<option value="Germany">Germany</option>
<option value="Spain">Spain</option>
<option value="United_States">United States</option>
<option value="United_Kingdom">United Kingdom</option>
<option value="Netherland">Netherland</option>
<option value="China">China</option>
</select>
<input type="checkbox" id="sale" onchange="funsale()"><label for="" >On sale</label>
<input type="checkbox" id="ship" onchange="funship()"><label for="">Free Shipping</label>
<p class="filtr">Price</p>
<input type="number" id="min" placeholder="Min" oninput="showfun()">
<h5>-</h5>
<input type="number" id="max" placeholder="Max" oninput="showfun()">
<div id="btn"></div>
</div>
<div id="sort"><p class="filtr">Sort:</p><button onclick="bstmtch()">Best Match</button><button onclick="nwarvl()">New Arrival</button><button onclick="prc()">Price</button></div>
</div>
<div id="item">
</div>
</div>
</div>
</div>
<div id="footer_part1"></div>
<div id="footer_part2"></div>
</body>
</html>
<script type="module" src="./scripts/bestseller.js"></script>
<script src="./scripts/backend.js"></script>
<script>
let data = JSON.parse(localStorage.getItem("BestSeller"))
append(data)
function append(data){
let parent = document.querySelector("#item");
console.log(data)
parent.innerHTML="";
data.forEach((el)=>{
let div = document.createElement('div');
div.addEventListener("click",function(){
detail(el);
})
let img = document.createElement('img');
img.src = el.imgURL;
let name = document.createElement('p');
name.innerText = el.name;
let price = document.createElement('h3');
price.innerText = el.price;
let discount = document.createElement('h6');
if(el.off==undefined){
discount.innerText="";
}
else{
let text = el.cutoff+" "+el.off;
discount.innerText = text;
}
let div2 = document.createElement("div");
div2.setAttribute("class","logo")
let img2 = document.createElement('img');
img2.setAttribute("id","logoimg")
img2.src = "https://as2.ftcdn.net/v2/jpg/01/25/83/03/1000_F_125830316_m9Grtzjlt2I5Gp4qpDQq5G5BSXR5d9ZF.jpg"
let wish = document.createElement('p');
wish.innerText = el.wishlist;
div2.append(img2, wish)
div.append(img,name,price,discount,div2);
parent.append(div)
})
}
function detail(data){
let bag = "";
for(let i=1;i<data.price.length;i++){
bag+=data.price[i]
}
let x = Number(bag)
let bag2 = "";
for(let i=0;i<data.name.length;i++){
if(data.name[i]==" "){
break;
}
bag2+=data.name[i];
}
let obj ={
title: data.name,
description:data.description,
price:x,
rating:data.ratings,
image:data.imgURL,
quantity:1,
item_code:Math.floor((Math.random() * 999999) + 1),
brand: bag2,
country:data.country
}
console.log(obj)
localStorage.setItem("Item_Details",JSON.stringify(obj))
window.location.href="product_detail.html"
}
function filcountry(){
console.log("hi")
let query = document.querySelector("#country").value;
console.log(query)
if(query=="Default"){
let newdata = data;
append(newdata)
}
else{
let newdata = data.filter(function(el){
if(el.country==query){
return el;
}
})
append(newdata)
}
}
function showfun(){
let btn = document.querySelector("#btn")
btn.innerHTML=`<button onclick="minmax()">OK</button>`
}
let ar7=0;
function arrived(){
ar7++;
if(ar7%2!=0){
let newdata = data.filter(function(el){
if(el.arrived=="7"){
return el;
}
})
append(newdata)
}
else{
let newdata=data;
append(newdata)
}
}
let ar15=0;
function arrived2(){
ar15++;
if(ar15%2!=0){
let newdata = data.filter(function(el){
if(el.arrived=="15"){
return el;
}
})
append(newdata)
}
else{
let newdata=data;
append(newdata)
}
}
let ar30=0;
function arrived3(){
ar30++;
if(ar30%2!=0){
let newdata = data.filter(function(el){
if(el.arrived=="30"){
return el;
}
})
append(newdata)
}
else{
let newdata=data;
append(newdata)
}
}
function funsale(){
let sale = document.querySelector("#sale");
if(sale.checked){
newdata = data.filter(function(el){
if(el.sale=="yes"){
return el;
}
})
append(newdata)
}
else{
let newdata=data;
append(newdata)
}
}
function funship(){
let ship = document.querySelector("#ship");
if(ship.checked){
let newdata = data.filter(function(el){
if(el.shipping=="yes"){
return el;
}
})
append(newdata)
}
else{
newdata=data;
append(newdata)
}
}
function minmax(){
let min = document.getElementById('min').value;
let max = document.getElementById('max').value;
console.log(min,max)
if(min=="" || max==""){
alert("Enter the correct Min and Max values")
}
else{
let newdata = data.filter(function(el){
let bag = "";
for(let i=1;i<el.price.length;i++){
bag+=el.price[i]
}
let x = Number(bag);
if(x>=min && x<=max){
return el;
}
})
append(newdata)
}
}
function bstmtch(){
console.log("hi")
let newdata = data.sort(function(a,b){
let x = Number(a.wishlist)
let y = Number(b.wishlist)
return y-x;
})
append(newdata)
}
function nwarvl(){
let newdata = data.sort(function(a,b){
let x = Number(a.ratings)
let y = Number(b.ratings)
return x-y;
})
append(newdata)
}
let prccnt=0;
function prc(){
prccnt++;
let newdata = data.sort(function(a,b){
let bag = "";
for(let i=1;i<a.price.length;i++){
bag+=a.price[i]
}
let x = Number(bag)
let bag2 = "";
for(let i=1;i<b.price.length;i++){
bag2+=b.price[i]
}
let y = Number(bag2)
if(prccnt%2!==0){
return x-y;
}
else{
return y-x;
}
})
append(newdata)
}
</script>