-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathhome.js
490 lines (441 loc) · 16.6 KB
/
home.js
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
var home = [
{
img:
"https://img.shop.com/Image/280000/281800/281821/products/1837884244.jpg?plain&size=400x400",
name: "Delta Select 69335-SN Bathroom Robe Hook 2.5",
soldBy: "Sold by Sim Supply",
strikedprice: "$80.00",
price: "40.00",
ratio: "+ up to $3.00 / 8% Cashback",
shipping: "Free shipping with $50.00 orders",
category:"bathroom"
},
{
img:
"https://img.shop.com/Image/280000/285500/285517/products/1879890567.jpg?plain&size=400x400",
name: "Tub Organizer Holder for Tablet, Book, Phone, Wine Glass, Candles, and Soap",
soldBy: "Sold by Sim Supply",
strikedprice: "35.00",
price: "15.00",
ratio: "+ $2.40 / 3% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"bathroom"
},
{
img:
"https://img.shop.com/Image/260000/263300/263383/products/1937735702.jpg?plain&size=400x400",
name: "Moen Rinza Brushed Nickel Wall Mount Toilet Paper Holder Y1108BN",
soldBy: "Sold by Sim Supply",
strikedprice: "35.00",
price: "30.00",
ratio: "+ up to $1.22 / 2% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"bathroom"
},
{
img:
"https://img.shop.com/Image/240000/243400/243406/products/1823606830.jpg?plain&size=400x400",
name: "Roselli Trading Company Suites 3-Pc. Bath Accessory Set Bedding",
soldBy: "Sold by Sim Supply",
strikedprice: "35.00",
price: "30.00",
ratio: "+ up to $1.22 / 2% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"bathroom"
},
{
img:
"https://img.shop.com/Image/240000/243400/243406/products/1899425202.jpg?plain&size=400x400",
name: "Riztex Usa Vivian Rae Quilt, Queen",
soldBy: " Sold by Bed Bath Fashions",
strikedprice: "45.00",
price: "40.00",
ratio: "+ up to $1.22 / 2% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"bed"
},
{
img:
"https://img.shop.com/Image/260000/262600/262642/products/1862410493.jpg?plain&size=400x400",
name: "Intelligent Design Microlight Plush Oversized Blanket Full/Queen",
soldBy: " Sold by Bed Bath Fashions",
strikedprice: "89",
price: "20",
ratio: "+ $0.63 / 3% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"bed"
},
{
img:
"https://img.shop.com/Image/290000/292000/292069/products/1949582478.jpg?plain&size=400x400",
name: "Bibb Home 2000 Count 6-Piece Rayon from Rayon from Bamboo Sheet Set",
soldBy: " Sold by Bed Bath Fashions",
strikedprice: "89",
price: "53",
ratio: "+ $0.63 / 6% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"bed"
},
{
img:
"https://img.shop.com/Image/260000/262600/262642/products/1854539461.jpg?plain&size=400x400",
name: "Madison Park Breanna 6 Piece Cotton Daybed Cover Set Daybed",
soldBy: " Sold by Bed Bath Fashions",
strikedprice: "89",
price: "53",
ratio: "+ $0.63 / 6% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"bed"
},
{
img:
"https://img.shop.com/Image/250000/251800/251872/products/1885786155.jpg?plain&size=400x400",
name: "Blue Wave BG5036 LED Cornhole Set with Target Boards & 8 Bean Toss Bags - Blue & White",
soldBy: " Sold by UnbeatableSale",
strikedprice: "189",
price: "53",
ratio: "+ $0.63 / 3% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"furniture"
},
{
img:
"https://img.shop.com/Image/280000/284400/284458/products/1862904603.jpg?plain&size=400x400",
name: "Costway 8PCS Rattan Patio Furniture Set Cushioned Sofa Chair Coffee Table Red\Brown\Turquoise",
soldBy: " Sold by UnbeatableSale",
strikedprice: "77",
price: "33",
ratio: "+ $0.63 / 3% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"furniture"
},
{
img:
"https://img.shop.com/Image/280000/287200/287278/products/1890508921.jpg?plain&size=400x400",
name: "Portable Foldable Comfortable TV Tray Table - Adjustable Tray - Sliding Adjustable Cup Holder",
soldBy: " Sold by UnbeatableSale",
strikedprice: "177",
price: "39",
ratio: "+ $0.63 / 3% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"furniture"
},
{
img:
"https://img.shop.com/Image/280000/284400/284458/products/1865309680.jpg?plain&size=400x400",
name: "Costway Set of 4 Style Metal Dining Side Chair Wood Seat Stackable Bistro Cafe",
soldBy: " Sold by UnbeatableSale",
strikedprice: "177",
price: "39",
ratio: "+ $0.63 / 3% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"furniture"
},
{
img:
"https://img.shop.com/Image/270000/273400/273475/products/1738504360.jpg?plain&size=400x400",
name: "Jonathan Green & Sons 802135 5 m Weed & Feed Lawn Fertilizer",
soldBy: " Sold by AllGourmetFood",
strikedprice: "57",
price: "55",
ratio: "+ $0.63 / 3% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"garden"
},
{
img:
"https://img.shop.com/Image/270000/273400/273475/products/1825049466.jpg?plain&size=400x400",
name: "Repurpose KHFM00317858 100 Percent Compostable Plant-Based Straws, 2.4 oz - 50 Count",
soldBy: " Sold by AllGourmetFood",
strikedprice: "57",
price: "27",
ratio: "+ $0.63 / 3% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"garden"
},
{
img:
"https://img.shop.com/Image/270000/273400/273475/products/1712347052.jpg?plain&size=400x400",
name: "Western 61644 2 lb. Wood Chip Smoking Apple",
soldBy: " Sold by AllGourmetFood",
strikedprice: "57",
price: "25",
ratio: "+ $0.63 / 3% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"garden"
},
{
img:
"https://img.shop.com/Image/270000/273400/273475/products/1712340166.jpg?plain&size=400x400",
name: "Seeds BG18000 Seeds Pumpkin Seeds Raw - 1x5LB",
soldBy: " Sold by AllGourmetFood",
strikedprice: "57",
price: "25",
ratio: "+ $0.63 / 3% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"garden"
},
{
img:
"https://img.shop.com/Image/270000/273400/273475/products/1927382148.jpg?plain&size=400x400",
name: "Fitbit Versa 2 Black Elastomer Strap Touchscreen Smart Watch 39mm",
soldBy: "Sold by AllGourmetFood",
strikedprice: "80",
price: "40",
ratio: "+ up to $3.00 / 8% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"kitchen"
},
{
img:
"https://img.shop.com/Image/270000/273400/273475/products/1712353115.jpg?plain&size=400x400",
name: "Pivot Direct PD-GLD-BBSK-BH-RD Glad Baking Basics, Blush & Red",
soldBy: "Sold by AllGourmetFood",
strikedprice: "109",
price: "79",
ratio: "+ $2.40 / 3% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"kitchen"
},
{
img:
"https://img.shop.com/Image/270000/273400/273475/products/1712344643.jpg?plain&size=400x400",
name: "Sun Luck BG18631 Sun Luck Stirfry Straw Mushrooms - 12x15OZ",
soldBy: "Sold by AllGourmetFood",
strikedprice: "60",
price: "45",
ratio: "+ up to $1.22 / 2% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"kitchen"
},
{
img:
"https://img.shop.com/Image/250000/251800/251872/products/1881260590.jpg?plain&size=400x400",
name: "Lorren Home Trends LH524 16 Piece Stoneware Scroll Dinnerware Set, White",
soldBy: "Sold by AllGourmetFood",
strikedprice: "60",
price: "45",
ratio: "+ up to $1.22 / 2% Cashback",
shipping: "Free shipping with $40.00 orders",
category:"kitchen"
},
];
displayfun(home);
document.getElementById("filter").addEventListener("change", changed);
function displayfun(q) {
document.querySelector("#product-container").innerHTML = "";
q.map(function (elem, i) {
var box = document.createElement("div");
var im = document.createElement("img");
im.setAttribute("src", elem.img);
var na = document.createElement("h3");
na.innerText = elem.name;
var sbp = document.createElement("p");
var logo = document.createElement("img");
logo.setAttribute("src", "https://img.shop.com/Image/resources/images/onecart-icon.svg");
// logo.setAttribute("class", "cartlogo");
logo.style.height = "15px"
logo.style.width = "15px";
var sb = document.createElement("span");
sb.innerText = elem.soldBy;
sb.setAttribute("class", "sold");
sbp.append(logo, sb);
sbp.style.marginTop = "-15px";
var pr = document.createElement("p");
var sp1 = document.createElement("span");
sp1.innerText = "$"+elem.strikedprice;
sp1.style.fontSize = ".75rem";
sp1.style.textDecoration = "line-through";
var sp2 = document.createElement("span");
sp2.innerText = "$"+elem.price;
sp2.setAttribute("class", "oprice");
pr.append(sp1, sp2);
pr.style.marginTop = "-6px";
var cbp = document.createElement("p");
var rato = document.createElement("span");
rato.innerText = elem.ratio;
rato.style.marginRight = "5px";
var logo2 = document.createElement("img");
logo2.setAttribute("src", "https://img.shop.com/Image/resources/images/cashback-icon.svg");
//logo2.setAttribute("class", "dollar");
logo2.style.height = "13px";
logo2.style.width = "13px";
var cb = document.createElement("span");
cb.innerText = "Cashback";
cbp.append(rato, logo2, cb);
cbp.style.fontSize = ".75rem";
cbp.style.marginTop = "-8px";
var sp = document.createElement("span");
sp.innerText = elem.shipping;
sp.style.color = "#007e97";
sp.style.fontSize = ".75rem";
sp.style.marginBottom = "15px";
var bdiv = document.createElement("div");
bdiv.setAttribute("class", "buttons")
var sd = document.createElement("div");
var anchor=document.createElement("a");
anchor.innerText="See Details";
sd.append(anchor);
anchor.setAttribute("href","details.html");
anchor.setAttribute("class","anch");
anchor.addEventListener("click",function(){
det(elem);
});
//sd.setAttribute("class", "details");
var atc = document.createElement("button");
atc.innerText = "Add to Cart";
atc.addEventListener("click", function () {
cart(elem, i);
});
// atc.setAttribute("class", "addtocart");
bdiv.append(sd, atc)
box.append(im, na, sbp, pr, cbp, sp, bdiv);
document.getElementById("product-container").append(box);
});
}
function det(elem){
var arr=[];
arr.push(elem);
localStorage.setItem("detail",JSON.stringify(arr));
//location.replace("details.html");
}
var cartArr = JSON.parse(localStorage.getItem("cart-list")) || [];
var count = localStorage.getItem("cartcount") || 0;
document.querySelector(".cart-count").innerText = count;
function cart(elem, i) {
cartArr.push(elem);
count++;
document.querySelector(".cart-count").innerText = count;
localStorage.setItem("cart-list", JSON.stringify(cartArr));
localStorage.setItem("cartcount", count);
}
function changed() {
var catt = document.querySelector("#filter").value;
if (catt == "") {
displayfun(home);
} else {
var p = home.filter(function (item) {
if (item.category == catt) {
return item;
}
});
displayfun(p);
}
}
document.querySelector("#filtergame").addEventListener("click", filterfun1);
document.querySelector("#filterhome").addEventListener("click", filterfun2);
document.querySelector("#filterapparel").addEventListener("click", filterfun3);
document.querySelector("#filterfootball").addEventListener("click", filterfun4);
document.querySelector("#filterbath").addEventListener("click", filterfun5);
function filterfun1() {
let q =home.filter(function (item) {
if (item.category == "bathroom") {
return item;
}
});
displayfun(q);
}
function filterfun2() {
let q = home.filter(function (item) {
if (item.category == "bed") {
return item;
}
});
displayfun(q);
}
function filterfun3() {
let q = home.filter(function (item) {
if (item.category == "furniture") {
return item;
}
});
displayfun(q);
}
function filterfun4() {
let q = home.filter(function (item) {
if (item.category == "garden") {
return item;
}
});
displayfun(q);
}
function filterfun5() {
let q = home.filter(function (item) {
if (item.category == "kitchen") {
return item;
}
});
displayfun(q);
}
/* <!-- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= --> */
function onClickMenu() {
document.getElementById("menu").classList.toggle("icon");
document.getElementById("nav").classList.toggle("change");
}
/* <!-- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= --> */
document.querySelector(".logo").addEventListener("click",function(){
window.open("project.html");
});
// search functionality
document.querySelector(".btn1").addEventListener("click",funsearch);
function funsearch(){
event.preventDefault();
var key=document.querySelector("#search").value;
key=key.toUpperCase();
if(key.includes("BEAUTY")){
window.open("beauty.html","_self");
document.querySelector("#search").value="";
}else if(key.includes("CLOTH")){
window.open("clothe.html","_self");
document.querySelector("#search").value="";
}else if(key.includes("FOOD")){
window.open("food.html","_self");
document.querySelector("#search").value="";
}else if(key.includes("HEALTH")){
window.open("health.html","_self");
document.querySelector("#search").value="";
}else if(key.includes("HOME")){
window.open("home.html","_self");
document.querySelector("#search").value="";
}else if(key.includes("JWELLERY")){
window.open("jwellery.html","_self");
document.querySelector("#search").value="";
}else if(key.includes("KIDS")){
window.open("kids.html","_self");
document.querySelector("#search").value="";
}else if(key.includes("PET")){
window.open("pet.html","_self");
document.querySelector("#search").value="";
}else if(key.includes("SHOES")){
window.open("shoes.html","_self");
document.querySelector("#search").value="";
}
else if (key.includes("ELECTRONICS")) {
window.open("electronic.html", "_self");
document.querySelector("#search").value = "";
}else if(key.includes("SPORTS")){
window.open("sports.html","_self");
document.querySelector("#search").value="";
}else{
alert("item not found");
}
}
//feedback
document.getElementById("submitfeedback").addEventListener("click",function(){
let val=document.getElementById("feedbacktext").value;
if(val.length>0){
alert("Thank you for your valuable feedback!!!");
}
});
//username
document.querySelector("#user-name").textContent=JSON.parse(localStorage.getItem("userName"))||"Sign In"
// microphone
const button = document.querySelector('#mic');
const textInput = document.querySelector('#search');
button.addEventListener('click', () => {
const recognition = new webkitSpeechRecognition();
recognition.onresult = event => {
textInput.value = event.results[0][0].transcript;
};
recognition.start();
});