-
Notifications
You must be signed in to change notification settings - Fork 2
/
shop6.js
348 lines (248 loc) · 9.87 KB
/
shop6.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
var robinData = [
{
image_url: "https://static.thcdn.com/images/xsmall/webp/productimg/1600/1600/11588128-5464550909161491.jpg",
name: "Decorté Liposome Moisture Serum 1.3oz",
box: "30% off select Decorte + Gift",
price: "66.50",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/1600/1600/12682868-2054802894273517.jpg",
name: "Decorté Botanical Skincare Collection 6 Piece Set (Worth $161.00)",
box: "30% off select Decorte + Gift",
price: "80.50",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/1600/1600/12682870-1654802894434596.jpg",
name: "Decorté AQ Perfect Repair 7 Piece Set (Worth $250.00)",
box: "30% off select Decorte + Gift",
price: "152.00",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/1600/1600/12682869-1224802894336487.jpg",
name: "Decorté Clean and Pure Facial Cleansing Essentials Set (Worth $139.00)",
box: "30% off select Decorte + Gift",
price: "80.00",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp/productimg/1600/1600/11995336-5244635651652236.jpg",
name: "Decorté Vita De Rêve Lotion 10.1 fl. oz/300ml (Worth $90)",
box: "30% off select Decorte + Gift",
price: "75.50",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/1600/1600/12356557-7384717418093823.jpg",
name: "Decorté AQ Moisture Layering Duo (Worth $190)",
box: "30% off select Decorte + Gift",
price: "161.50",
},
{
image_url: "https://static.thcdn.com/images/large/webp/productimg/1600/1600/12019079-1204653615170799.jpg",
name: "Decorté Loose Powder 1oz (Various Shades)",
box: "30% off select Decorte + Gift",
price: "50.00",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/12441879-1974736973748029.jpg",
name: "Decorté AQ Lotion and Emulsion Duo",
box: "30% off select Decorte + Gift",
price: "190.00",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/1600/1600/11759902-6104750524487590.jpg",
name: "Decorté Prime Latte 150ml",
box: "30% off select Decorte + Gift",
price: "45.50",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp/productimg/1600/1600/12144170-1574676149225227.jpg",
name: "Decorté AQ Cleansing Cream 4.1oz",
box: "30% off select Decorte + Gift",
price: "60.00",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/12462157-1984747708061949.jpg",
name: "Decorté Lip Oil - Fuchsia Rose 04 0.15 fl. Oz.",
box: "30% off select Decorte + Gift",
price: "27.00",
},
{
image_url: "https://static.thcdn.com/images/large/webp/productimg/1600/1600/11691717-2104561042713873.jpg",
name: "Decorté Cream Blusher (Various Shades)",
box: "30% off select Decorte + Gift",
price: "35.00",
},
{
image_url: "https://static.thcdn.com/images/large/webp/productimg/1600/1600/11691687-1954561040135898.jpg",
name: "Decorté Eye Glow Gem (Various Shades)",
box: "30% off select Decorte + Gift",
price: "27.00"
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp/productimg/1600/1600/11588125-9294529913768699.jpg",
name: "Decorté Liposome Eye Cream 15ml",
box: "30% off select Decorte + Gift",
price: "62.00"
},
{
image_url: "https://static.thcdn.com/images/large/webp/productimg/1600/1600/11588133-1774529914238919.jpg",
name: "Decorté Vi-Fusion Intro Skincare Kit (Worth $262)",
box: "30% off select Decorte + Gift",
price: "200.00",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp/productimg/1600/1600/11759904-1614586382704109.jpg",
name: "Decorté Eye & Lip Makeup Remover",
box: "30% off select Decorte + Gift",
price: "18.00",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/1600/1600/12144169-1004731376886103.jpg",
name: "Decorté AQ Peel Off Lifting Mask 2.9oz",
box: "30% off select Decorte + Gift",
price: "195.00",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/original/12706871-5264918200667656.jpg",
name: "Decorté Purifying Foam Cleanser 125m",
box: "30% off select Decorte + Gift",
price: "40.00",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp/productimg/1600/1600/11588129-1454529914064634.jpg",
name: "Decorté Vi-Fusion 24/7 Eye Cream 0.53oz",
box: "30% off select Decorte + Gift",
price: "150.00",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp/productimg/1600/1600/12144171-1664676149378437.jpg",
name: "Decorté AQ Washing Cream 4.5oz",
box: "30% off select Decorte + Gift",
price: "50.00",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/1600/1600/12521563-2034762955030880.jpg",
name: "Decorté Whitelogist Brightening Correcting Serum with Kohic Acid 40ml",
box: "30% off select Decorte + Gift",
price: "140.00",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/1600/1600/12356556-8114717417767657.jpg",
name: "Decorté Prime Latte Bundle (Worth $105.00)",
box: "30% off select Decorte + Gift",
price: "99.00",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/original/13011542-7184857487015749.jpg",
name: "Decorté Kimono Yui Eau De Toilette 1.7 fl. oz",
box: "30% off select Decorte + Gift",
price: "75.00",
},
];
// var cartArray = JSON.parse(localStorage.getItem("cartItems")) || [];
// var wishArray = JSON.parse(localStorage.getItem("wishItems")) || [];
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);
}
}