-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurve+plus.js
237 lines (208 loc) · 6.05 KB
/
curve+plus.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
// countdown
var countdown = () => {
var countDate = new Date("November 18, 2021 00:00:00").getTime();
var now = new Date().getTime();
var gap = countDate - now;
// console.log(countDate);
//how the time work?
var now = new Date().getTime();
var second = 1000;
var minute = second * 60;
var hour = minute * 60;
var day = hour * 24;
//calculate how many days is there
var textDay = Math.floor(gap / day);
// console.log(textDay)
var textHour = Math.floor((gap % day) / hour);
var textMinute = Math.floor((gap % hour) / minute);
var textSecond = Math.floor((gap % minute) / second);
document.querySelector(".day").innerHTML = textDay;
document.querySelector(".hour").innerHTML = textHour;
document.querySelector(".minute").innerHTML = textMinute;
document.querySelector(".second").innerHTML = textSecond;
};
// console.log(15%2); divided by hour
// countdown();
setInterval(countdown, 1000);
// slider one
var responsiveSlider = function () {
var slider = document.getElementById("slider");
var sliderWidth = slider.offsetWidth;
var slideList = document.getElementById("slideWrap");
var count = 1;
var items = slideList.querySelectorAll("li").length;
window.addEventListener("resize", function () {
sliderWidth = slider.offsetWidth;
});
var nextSlide = function () {
if (count < items) {
slideList.style.left = "-" + count * sliderWidth + "px";
count++;
} else if ((count = items)) {
slideList.style.left = "0px";
count = 1;
}
};
setInterval(function () {
nextSlide();
}, 2000);
};
// shop-by-category
var category = [
{
title: "Dresses",
img: "images/dressesIcon.png",
},
{
title: "Tops",
img: "images/topIcon.png",
},
{
title: "Sweatshirts",
img: "images/sweatshirtIcon.png",
},
{
title: "Knitwear",
img: "images/knitwearIcon.png",
},
{
title: "Outerwear",
img: "images/outer_wear.png",
},
{
title: "Activewear",
img: "images/activeWearIcon.png",
},
{
title: "Lingerie & Loungewear",
img: "images/LingeriIcon.png",
},
{
title: "Bottoms",
img: "images/BottomsIcon.png",
},
{
title: "Denim",
img: "images/denimIcon.png",
},
{
title: "Jumpsuits & Two-pieces",
img: "images/JumpSuits.png",
},
];
var flashs = [
{ img: "flashSale/saleImage1.jpg", price: "US$12.90", discount: "US$22.21" },
{ img: "flashSale/saleImage2.jpg", price: "US$18.21", discount: "US$42.00" },
{ img: "flashSale/saleImage4.jpg", price: "US$12.21", discount: "US$28.00" },
{ img: "flashSale/saleImage5.jpg", price: "US$21.20", discount: "US$50.00" },
{ img: "flashSale/saleImage6.jpg", price: "US$28.00", discount: "US$75.00" },
];
flash();
function flash() {
flashs.map(function (item) {
var imgContainer = document.createElement("div");
imgContainer.setAttribute("id", "imgContainer");
var img = document.createElement("img");
img.setAttribute("src", item.img);
var para = document.createElement("p");
para.setAttribute("id", "pricePara");
para.textContent = item.discount;
imgContainer.append(img, item.price, para);
var flashDiv = document.getElementById("flash");
flashDiv.append(imgContainer);
});
}
showCategory();
function showCategory() {
category.map(function (item) {
var box = document.createElement("div");
box.setAttribute("id", "boxes");
var imageBox = document.createElement("div");
imageBox.setAttribute("id", "imageBox");
var image = document.createElement("img");
image.setAttribute("src", item.img);
var name = document.createElement("p");
name.setAttribute("id", "shopCatText");
name.textContent = item.title;
imageBox.appendChild(image);
box.append(imageBox, name);
document.getElementById("categoryBox").append(box);
});
}
var myIndex = 0;
carousel();
function carousel() {
var i;
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
myIndex++;
if (myIndex > x.length) {
myIndex = 1;
}
x[myIndex - 1].style.display = "block";
setTimeout(carousel, 2000); // Change image every 2 seconds
}
// user tab
document.getElementById("user").addEventListener("click", signInAndSignup);
function signInAndSignup() {
window.location.href = "signInAndSignup.html";
}
// home tab
document.getElementById("home").addEventListener("click", function () {
window.location.href = "index.html";
});
// kids tab
document.getElementById("kids").addEventListener("click", function () {
window.location.href = "kids.html";
});
// logo
document.getElementById("logo").addEventListener("click", function () {
window.location.href = "index.html";
});
// user tab
document.getElementById("user").addEventListener("click", signInAndSignup);
function signInAndSignup() {
window.location.href = "signInAndSignup.html";
}
// home tab
document.getElementById("home").addEventListener("click", function () {
window.location.href = "index.html";
});
// kids tab
document.getElementById("kids").addEventListener("click", function () {
window.location.href = "kids.html";
});
// logo
document.getElementById("logo").addEventListener("click", function () {
window.location.href = "index.html";
});
// men tab
document.getElementById("men").addEventListener("click", function () {
window.location.href = "men.html";
});
// curve+plus tab
document.getElementById("curve+plus").addEventListener("click", function () {
window.location.href = "curve+plus.html";
});
// beauty tab
document.getElementById("beauty").addEventListener("click", function () {
window.location.href = "beauty.html";
});
// cart icon
document.getElementById("bags").addEventListener("click", function () {
window.location.href = "cart.html";
});
// fav icon
document.getElementById("favs").addEventListener("click", function () {
window.location.href = "fav.html";
});
var cartData = JSON.parse(localStorage.getItem("cartData"));
var favProductsData = JSON.parse(localStorage.getItem("favProductsData"));
// no. of cart items show when page is loading
// no. of fav cart items show when page is loading
window.onload = function () {
document.getElementById("bagItemsCount").textContent = cartData.length;
document.getElementById("favItemsCount").textContent = favProductsData.length;
};