-
Notifications
You must be signed in to change notification settings - Fork 2
/
shop1.js
315 lines (240 loc) · 9.89 KB
/
shop1.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
var robinData = [
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/original/13547805-1174926019137063.jpg",
name: "SkinCeuticals Replenishing Anti-Aging Regimen Worth $332.00",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "292.16",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/original/13547804-2124926019007688.jpg",
name: "SkinCeuticals Anti-Aging Radiance Duo Worth $296.00",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "260.48",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/original/13279307-1044898790795072.jpg",
name: "SkinCeuticals Post-Injectable System",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "190",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/original/13547807-5554926019432371.jpg",
name: "SkinCeuticals AM/PM Replenishing Antioxidant Regimen Worth $449",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "395",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/original/13279308-1124898791328007.jpg",
name: "SkinCeuticals Post-Chemical Peel System",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "205",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13196078-1324889940505536.jpg",
name: "SkinCeuticals Advanced Scar Control 1.7 fl. oz",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "110",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13278621-1584891260833553.jpg",
name: "Corrective Anti-Aging Luxe Night Kit",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "380",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13278622-2304891261064421.jpg",
name: "SkinCeuticals x Slip: Vitamin C & Sunscreen Luxe Day Kit",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "280",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/original/13278623-1114891261385910.jpg",
name: "SkinCeuticals x Slip Eye Duo",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "148",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/13036144-1644892769995985.jpg",
name: "SkinCeuticals Daily Brightening UV Defense Sunscreen SPF30 1 fl. oz",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "54",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/12941160-7374871557827456.jpg",
name: "SkinCeuticals Physical Fusion UV Defense SPF50 Sunscreen",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "34",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/12771530-3164918929282606.jpg",
name: "SkinCeuticals Silymarin CF Serum 1 fl. oz",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "166",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/12639082-1284892769599187.jpg",
name: "SkinCeuticals Tripeptide-R Neck Repair 1.7oz",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "120",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/12611195-6384778701534407.jpg",
name: "SkinCeuticals Tripeptide-R Neck Repair 1.7oz",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "120",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/1600/1600/12546098-1674764018462201.jpg",
name: "SkinCeuticals Acne Skin System (Worth $173.00)",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "130",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/12309426-1464892769568764.jpg",
name: "SkinCeuticals Glycolic Renewal Cleanser 5 fl.oz",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "30",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/1600/1600/12339500-6574717359524826.jpg",
name: "SkinCeuticals Phyto+ and Serum 20 AOX Duo",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "230",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/12103843-1444870995724380.jpg",
name: "SkinCeuticals Simply Clean Cleanser 11.8 fl. oz",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "45",
},
{
image_url: "https://static.thcdn.com/images/large/webp//productimg/1600/1600/12103844-1634870985978103.jpg",
name: "SkinCeuticals Gentle Cleanser 11.8 fl. oz",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "45",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/original/12031613-2054892769485889.jpg",
name: "SkinCeuticals Glycolic 10 Overnight Treatment 50ml",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "85",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp//productimg/original/12024247-1024892769416454.jpg",
name: "SkinCeuticals Brightening Skin System Set (Worth $368.00)",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "285",
},
{
image_url: "https://static.thcdn.com/images/xsmall/webp/productimg/1600/1600/11976680-1624632279939375.jpg",
name: "SkinCeuticals Refill and Nourish Regimen",
box: "SkinCeuticals Triple Lipid Restore 2:4:2 4ml Gift",
price: "385",
},
];
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);
}
}