-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
247 lines (209 loc) · 7.78 KB
/
index.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
document.addEventListener('DOMContentLoaded', () => {
// Mobile Menu Toggle
const menuIcon = document.querySelector('.menu-icon');
const navLinks = document.querySelector('.nav-links');
if (menuIcon && navLinks) {
// Toggle menu when menu icon is clicked
menuIcon.addEventListener('click', () => {
navLinks.classList.toggle('active');
menuIcon.classList.toggle('active');
});
// Close menu when a nav item is clicked on mobile
const navItems = document.querySelectorAll('.nav-links a');
navItems.forEach(item => {
item.addEventListener('click', () => {
if (window.innerWidth <= 768) {
navLinks.classList.remove('active');
menuIcon.classList.remove('active');
}
});
});
// Close menu if clicking outside nav on mobile
document.addEventListener('click', (e) => {
if (window.innerWidth <= 768 &&
!e.target.closest('nav') &&
!e.target.closest('.menu-icon')) {
navLinks.classList.remove('active');
menuIcon.classList.remove('active');
}
});
}
// FAQ Dropdown Functionality
const faqItems = document.querySelectorAll('.faq-item');
faqItems.forEach(item => {
const question = item.querySelector('h3');
const answer = item.querySelector('.faq-answer');
if (question && answer) {
question.addEventListener('click', () => {
// Close all other open answers first
faqItems.forEach(otherItem => {
if (otherItem !== item) {
const otherAnswer = otherItem.querySelector('.faq-answer');
if (otherAnswer) {
otherAnswer.classList.remove('active');
}
}
});
// Toggle the current answer
answer.classList.toggle('active');
});
}
});
});
document.addEventListener('DOMContentLoaded', () => {
const explanationCarousel = document.querySelector('.explanation-carousel');
const slides = explanationCarousel.querySelectorAll('.explanation-slide');
const prevButton = explanationCarousel.querySelector('.prev-slide');
const nextButton = explanationCarousel.querySelector('.next-slide');
const progressBar = explanationCarousel.querySelector('.progress-bar');
let currentSlide = 0;
const totalSlides = slides.length;
let autoSlideInterval;
const slideDuration = 5000; // 5 seconds per slide
function showSlide(index) {
// Remove active class from all slides
slides.forEach(slide => {
slide.classList.remove('active');
});
// Add active class to current slide
slides[index].classList.add('active');
// Update progress bar based on slide position
const progressPercentage = (currentSlide / (totalSlides - 1)) * 100;
progressBar.style.width = `${progressPercentage}%`;
}
function nextSlide() {
currentSlide = (currentSlide + 1) % totalSlides;
showSlide(currentSlide);
startAutoSlide();
}
function prevSlide() {
currentSlide = (currentSlide - 1 + totalSlides) % totalSlides;
showSlide(currentSlide);
startAutoSlide();
}
function startAutoSlide() {
// Clear any existing interval
clearInterval(autoSlideInterval);
// Start new auto-slide interval
autoSlideInterval = setInterval(nextSlide, slideDuration);
}
// Add event listeners to navigation buttons
nextButton.addEventListener('click', () => {
nextSlide();
});
prevButton.addEventListener('click', () => {
prevSlide();
});
// Initialize the first slide and progress bar
showSlide(currentSlide);
// Start auto-sliding
startAutoSlide();
});
document.addEventListener('DOMContentLoaded', () => {
const gamesCarousel = document.querySelector('.games-carousel');
const gamesInner = document.querySelector('.games-inner');
const prevBtn = document.querySelector('.games-prev-btn');
const nextBtn = document.querySelector('.games-next-btn');
const gameCards = document.querySelectorAll('.game-card');
let currentIndex = 0;
const totalCards = gameCards.length - 1;
// Function to get visible cards based on screen width
function getVisibleCards() {
const screenWidth = window.innerWidth;
if (screenWidth <= 768) return 1; // Mobile
if (screenWidth <= 1024) return 2; // Tablet
return 3; // Desktop
}
function updateCarousel() {
const visibleCards = getVisibleCards();
const cardWidth = gameCards[0].offsetWidth + 20; // card width + margin
gamesInner.style.transform = `translateX(-${currentIndex * cardWidth}px)`;
}
nextBtn.addEventListener('click', () => {
const visibleCards = getVisibleCards();
if (currentIndex < totalCards - visibleCards) {
currentIndex++;
updateCarousel();
}
});
prevBtn.addEventListener('click', () => {
if (currentIndex > 0) {
currentIndex--;
updateCarousel();
}
});
// Initial setup and responsive handling
function setupCarousel() {
updateCarousel();
}
// Initial setup
setupCarousel();
// Responsive adjustments
window.addEventListener('resize', setupCarousel);
});
document.addEventListener('DOMContentLoaded', () => {
const teamsData = {
"red-raccoons": Array(5).fill({
name: "TBA",
avatar: "/images/teams/red.png",
link: ""
}),
"orange-otters": Array(5).fill({
name: "TBA",
avatar: "/images/teams/orange.png",
link: ""
}),
"fire-foxes": Array(5).fill({
name: "TBA",
avatar: "/images/teams/yellow.png",
link: ""
}),
"green-goats": Array(5).fill({
name: "TBA",
avatar: "/images/teams/green.png",
link: ""
}),
"cyan-crabs": Array(5).fill({
name: "TBA",
avatar: "/images/teams/cyan.png",
link: ""
}),
"blue-belugas": Array(5).fill({
name: "TBA",
avatar: "/images/teams/blue.png",
link: ""
}),
"purple-puffins": Array(5).fill({
name: "TBA",
avatar: "/images/teams/purple.png",
link: ""
}),
"pink-panthers": Array(5).fill({
name: "TBA",
avatar: "/images/teams/pink.png",
link: ""
})
};
function populateTeams() {
for (const [teamId, players] of Object.entries(teamsData)) {
const teamList = document.getElementById(teamId);
if (!teamList) continue;
teamList.innerHTML = ""; // Clear existing content
players.forEach(player => {
const playerElement = document.createElement('li');
playerElement.classList.add('player');
const avatar = document.createElement('img');
avatar.src = player.avatar;
avatar.alt = `${player.name}'s Avatar`;
avatar.classList.add('player-head');
const playerName = document.createElement('span');
playerName.textContent = player.name;
playerName.classList.add('player-name');
playerElement.appendChild(avatar);
playerElement.appendChild(playerName);
teamList.appendChild(playerElement);
});
}
}
populateTeams();
});