-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
51 lines (44 loc) · 1.62 KB
/
script.js
File metadata and controls
51 lines (44 loc) · 1.62 KB
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
// Get elements
const consentCheckbox = document.getElementById('consent-checkbox');
const startButton = document.getElementById('start-assessment');
// Function to enable or disable the Start Assessment button
function toggleStartButton() {
if (consentCheckbox.checked) {
startButton.disabled = false;
startButton.classList.remove('disabled');
} else {
startButton.disabled = true;
startButton.classList.add('disabled');
}
}
// Event listener for checkbox change
consentCheckbox.addEventListener('change', toggleStartButton);
document.addEventListener('DOMContentLoaded', () => {
const carousel = document.querySelector('.carousel-content');
const nextBtn = document.querySelector('.next-btn');
const prevBtn = document.querySelector('.prev-btn');
const videoWidth = 580; // width + gap
nextBtn.addEventListener('click', () => {
carousel.scrollBy({
left: videoWidth,
behavior: 'smooth'
});
});
prevBtn.addEventListener('click', () => {
carousel.scrollBy({
left: -videoWidth,
behavior: 'smooth'
});
});
// Hide/show buttons based on scroll position
carousel.addEventListener('scroll', () => {
const maxScroll = carousel.scrollWidth - carousel.clientWidth;
prevBtn.style.display = carousel.scrollLeft === 0 ? 'none' : 'block';
nextBtn.style.display = carousel.scrollLeft === maxScroll ? 'none' : 'block';
});
});
function changeVideo(direction) {
videos[currentIndex].classList.remove('active');
currentIndex = (currentIndex + direction + videos.length) % videos.length;
videos[currentIndex].classList.add('active');
}