-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
159 lines (127 loc) · 4.24 KB
/
app.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
//for hamburger menu
const bar=document.getElementById("bar");
const nav=document.getElementById("navbar");
const close=document.getElementById("close");
if(bar){
bar.addEventListener('click',()=>{
nav.classList.add('active');
})
}
if(close){
close.addEventListener('click',()=>{
nav.classList.remove('active');
})
}
//count downer for contest 1
var countDownDate = new Date("Oct 5, 2022 15:37:25").getTime();
var x = setInterval(function () {
var now = new Date().getTime();
var distance = countDownDate - now;
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
document.getElementById("countDown").innerHTML = days + "d " + hours + "h "
+ minutes + "m " + seconds + "s ";
if (distance < 0) {
clearInterval(x);
document.getElementById("countDown").innerHTML = "EXPIRED";
}
}, 1000);
//count downer for contest2
var countDownDate1 = new Date("Oct 6, 2022 15:37:25").getTime();
var x = setInterval(function () {
var now = new Date().getTime();
var distance = countDownDate1 - now;
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
document.getElementById("countDown1").innerHTML = days + "d " + hours + "h "
+ minutes + "m " + seconds + "s ";
if (distance < 0) {
clearInterval(x);
document.getElementById("countDown1").innerHTML = "EXPIRED";
}
}, 1000);
//for carousel
!(function(pic){
var itemClassName = "carouselPhoto";
items =pic.getElementsByClassName(itemClassName),
totalItems = items.length,
slide = 0,
moving = true;
function setInitialClasses() {
items[totalItems - 1].classList.add("prev");
items[0].classList.add("active");
items[1].classList.add("next");
}
function setEventListeners() {
var next = pic.getElementsByClassName('carousel__button--next')[0],
prev =pic.getElementsByClassName('carousel__button--prev')[0];
next.addEventListener('click', moveNext);
prev.addEventListener('click', movePrev);
}
function moveNext() {
if (!moving) {
if (slide === (totalItems - 1)) {
slide = 0;
} else {
slide++;
}
moveCarouselTo(slide);
}
}
function movePrev() {
if (!moving) {
if (slide === 0) {
slide = (totalItems - 1);
} else {
slide--;
}
moveCarouselTo(slide);
}
}
function disableInteraction() {
moving = true;
setTimeout(function(){
moving = false
}, 500);
}
function moveCarouselTo(slide) {
if(!moving) {
disableInteraction();
var newPrevious = slide - 1,
newNext = slide + 1,
oldPrevious = slide - 2,
oldNext = slide + 2;
if ((totalItems - 1) > 3) {
if (newPrevious <= 0) {
oldPrevious = (totalItems - 1);
} else if (newNext >= (totalItems - 1)){
oldNext = 0;
}
if (slide === 0) {
newPrevious = (totalItems - 1);
oldPrevious = (totalItems - 2);
oldNext = (slide + 1);
} else if (slide === (totalItems -1)) {
newPrevious = (slide - 1);
newNext = 0;
oldNext = 1;
}
items[oldPrevious].className = itemClassName;
items[oldNext].className = itemClassName;
items[newPrevious].className = itemClassName + " prev";
items[slide].className = itemClassName + " active";
items[newNext].className = itemClassName + " next";
}
}
}
function initCarousel() {
setInitialClasses();
setEventListeners();
moving = false;
}
initCarousel();
}(document));