-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathshop3.js
378 lines (276 loc) · 10.1 KB
/
shop3.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
var robinData = [
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13232824-1904908361586136.jpg",
name: "SkinStore Holiday Edit 2021 (Worth Over",
box: "50% off SkinStore ",
MSRP: "150",
price: "75",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13468234-5434916661811767.jpg",
name: "Decorté Liposome Advanced Repair Serum",
box: "$33 Decorté Gift",
MSRP: "100",
price: "75",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13422147-2054909926994386.jpg",
name: "VIRTUE 6-in-1 Styling Paste 150ml",
box: "VIRTUE Gift",
MSRP: "60",
price: "48",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/original/13461935-1424911141630369.jpg",
name: "Bloom and Blossom Comfort",
box: "Winter Sale- Up to 50% off",
MSRP: "345",
price: "240",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/original/13208347-1024894854814398.jpg",
name: "ghd Exclusive Starter Pack (Worth $314.00)",
box: "Winter Sale- Up to 50% off",
MSRP: "55",
price: "40",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13457158-7614909353366306.jpg",
name: "FOREO ISSA Hybrid Wave Brush Head (Various Shades)",
box: "Select your Gift",
MSRP: "45",
price: "30",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13482949-1274921017596166.jpg",
name: "Beauty ORA 360-Degree Roller",
box: "15% off use code SS15 ",
MSRP: "70",
price: "65",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/original/13225569-6864915280569197.jpg",
name: "Philip B Forever Shine Travel Set",
box: "Winter Sale 50% off ",
MSRP: "85",
price: "59",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13208345-9064895081911374.jpg",
name: "Bloom and Blossom Body and Soul ",
box: "Winter Sale 50% off ",
MSRP: "37",
price: "25",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13522035-9514924731935292.jpg",
name: "First Aid Beauty Hello Fab Coconut Water Cream ",
box: "15% off use code SS15 ",
MSRP: "47",
price: "35",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/12669032-2024870955666082.jpg",
name: "Relaxing Shower Oil 100ml ",
box: "15% off use code SS15 ",
MSRP: "47",
price: "30",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13436007-4544906227704997.jpg",
name: "ghd Thin Wand - 0.5 ",
box: "Select your Gift ",
MSRP: "147",
price: "130",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13452934-9484924197336270.jpg",
name: "Dermalogica Awaken Peptide Eye Gel 15ml ",
box: "$42 Dermalogica Gift ",
MSRP: "67",
price: "55",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13479041-1404911498472224.jpg",
name: "VIRTUE Curl Leave-in Butter 150ml ",
box: "VIRTUE Gift ",
MSRP: "50",
price: "45",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13502372-2334921017357894.jpg",
name: "Beauty ORA Facial Ice Globes Duo ",
box: "15% off use code SS15 ",
MSRP: "60",
price: "45",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13506923-2024925456566434.jpg",
name: "Bloom and Blossom Smooth Moves Stretch Mark Oil 150ml ",
box: "VIRTUE Gift ",
MSRP: "40",
price: "35",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13445706-7844918668913221.jpg",
name: "Dr. Dennis Gross Advanced Retinol ",
box: "Dr Dennis Gross Gift ",
MSRP: "80",
price: "75",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13482948-6934921017212661.jpg",
name: "Beauty ORA 360-Degree Roller ",
box: "15% off use code SS15 ",
MSRP: "70",
price: "65",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13232822-1544908361367298.jpg",
name: "SkinStore Selects Limited Edition Collection (Worth Over $350) ",
box: "winter Sale- Up to 50% ",
MSRP: "110",
price: "95",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13277669-4614905728591652.jpg",
name: "ALPHA-H Melting Moment Cleansing Balm 90g ",
box: "winter Sale- Up to 50% ",
MSRP: "80",
price: "45",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13225568-1364915280507820.jpg",
name: "Philip B Weightless Weekender Collection Set (Worth $84.00)",
box: "Winter Sale- Up to 50% ",
MSRP: "60",
price: "43",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13485839-1944912987170825.jpg",
name: "The Ordinary Natural Moisturizing Factors and HA 100ml (Three Pack)",
box: "Winter Sale- Up to 50% ",
MSRP: "23",
price: "18",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/original/13485834-1744912989374277.jpg",
name: "The Ordinary Hyaluronic Acid 2% and B5 30ml (Three Pack)",
box: "Select your Gift ",
MSRP: "30",
price: "28",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/original/12902306-1244904188292712.jpg",
name: "Miriam Quevedo Platinum and Diamonds Luxurious Shampoo 250ml",
box: "Select your Gift ",
MSRP: "60",
price: "52",
},
];
reLoadM(robinData);
function reLoadM(robinData){
// DATA
displayDatas(robinData);
function displayDatas(robinData){
document.querySelector("#container").textContent="";
robinData.map(function (data) {
var div = document.createElement("div")
document.querySelector("#container").append(div)
// inside div creating image and image_url
var image = document.createElement("img");
image.setAttribute("src", data.image_url);
div.append(image);
var name = document.createElement("p");
name.style.height = "35px"
name.textContent = data.name;
name.style.marginTop = "3%"
div.append(name);
var box = document.createElement("div")
box.textContent = data.box
box.setAttribute("id", "boxer")
div.append(box)
var p2 = document.createElement("p")
p2.textContent = `$${data.price}`;
p2.style.marginTop = "3%"
p2.style.fontSize = "24px"
p2.style.fontWeight = "bold"
div.append(p2)
var btn1 = document.createElement("button")
btn1.setAttribute("id", "btnwish")
btn1.textContent = "Wish"
btn1.style.display = "block"
btn1.addEventListener("click", function () {
wishlistAdd(data);
})
div.append(btn1)
var btn2 = document.createElement("button")
btn2.setAttribute("id", "btnbuy");
btn2.textContent = "QUICK BUY"
btn2.addEventListener("click", function () {
cartAdd(data);
})
div.append(btn2);
})
}
var cartThings = JSON.parse(localStorage.getItem("cartthings")) || [];
var cartArray = JSON.parse(localStorage.getItem("quickbuy1")) || [];
function wishlistAdd(data) {
cartArray.push(data);
cartThings.push(data);
localStorage.setItem("quickbuy1", JSON.stringify(cartArray));
localStorage.setItem("cartthings", JSON.stringify(cartThings));
alert("Item Added");
reLoadM(robinData);
}
function cartAdd(data) {
cartThings.push(data);
localStorage.setItem("cartthings", JSON.stringify(cartThings));
alert("added to cart");
reLoadM(robinData);
}
// console.log(cartArray);
// console.log(cartArray);
// Read More Drop Down Function
// ==============================================================================================================================================
var cartLength =JSON.parse(localStorage.getItem("cartthings"))
document.querySelector("#cardAval").innerHTML=`There are currently ${cartLength.length} items in your cart.`;
document.querySelector("#cartLen").innerHTML=`${cartLength.length}`;
}
function navSlideOut(){
document.querySelector("#nav-link").style.left="-16px"
}
function navSlideIn(){
document.querySelector("#nav-link").style.left="-2000px"
}
function myFunction() {
var dots = document.getElementById("dots");
var moreText = document.getElementById("more");
var btnText = document.getElementById("myBtn");
if (dots.style.display === "none") {
dots.style.display = "inline";
btnText.innerHTML = "Read more";
moreText.style.display = "none";
} else {
dots.style.display = "none";
btnText.innerHTML = "Read less";
moreText.style.display = "inline";
}
}
function Tsort(){
var valT=document.querySelector("#sortT").value
console.log(valT)
if(valT==""){
reLoadM(robinData);
}else if(valT=="high"){
robinData.sort(function(a,b){
return (Number(b.price)-Number(a.price))
})
reLoadM(robinData);
}else{
robinData.sort(function(a,b){
return (Number(a.price)-Number(b.price))
})
reLoadM(robinData);
}
}