Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
188 lines (156 loc) · 5.1 KB
/
Copy pathscript.js
File metadata and controls
188 lines (156 loc) · 5.1 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
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
//nav bar
window.addEventListener("scroll", function() {
var navbar = document.getElementById("navbar");
if (window.scrollY > 50) {
navbar.style.background = "black";
} else {
navbar.style.background = "transparent";
}
});
// Video Controls
const video = document.getElementById('hero-video');
const playPauseBtn = document.getElementById('play-pause-btn');
const muteBtn = document.getElementById('mute-btn');
const volumeSlider = document.getElementById('volume-slider');
const fullscreenBtn = document.getElementById('fullscreen-btn');
const videoControls = document.getElementById('video-controls');
// Play/Pause functionality
playPauseBtn.addEventListener('click', () => {
if (video.paused) {
video.play();
playPauseBtn.innerHTML = '<i class="fas fa-pause"></i>';
} else {
video.pause();
playPauseBtn.innerHTML = '<i class="fas fa-play"></i>';
}
});
// Mute/Unmute functionality
muteBtn.addEventListener('click', () => {
if (video.muted) {
video.muted = false;
muteBtn.innerHTML = '<i class="fas fa-volume-up"></i>';
volumeSlider.value = video.volume;
} else {
video.muted = true;
muteBtn.innerHTML = '<i class="fas fa-volume-mute"></i>';
volumeSlider.value = 0;
}
});
// Volume slider functionality
volumeSlider.addEventListener('input', () => {
video.volume = volumeSlider.value;
if (video.volume === 0) {
muteBtn.innerHTML = '<i class="fas fa-volume-mute"></i>';
} else {
muteBtn.innerHTML = '<i class="fas fa-volume-up"></i>';
}
video.muted = false;
});
// Fullscreen functionality
fullscreenBtn.addEventListener('click', () => {
if (!document.fullscreenElement) {
video.requestFullscreen().catch(err => {
console.log(`Error attempting to enable fullscreen: ${err.message}`);
});
} else {
document.exitFullscreen();
}
});
// Show controls on video interaction (for mobile)
video.addEventListener('touchstart', () => {
videoControls.style.opacity = '1';
setTimeout(() => {
videoControls.style.opacity = '0';
}, 3000);
});
// Hide controls when video is playing and mouse is not hovering
let hideControlsTimeout;
function hideControls() {
if (!video.paused) {
hideControlsTimeout = setTimeout(() => {
videoControls.style.opacity = '0';
}, 3000);
}
}
video.addEventListener('play', hideControls);
video.addEventListener('pause', () => {
clearTimeout(hideControlsTimeout);
videoControls.style.opacity = '1';
});
video.addEventListener('mouseenter', () => {
clearTimeout(hideControlsTimeout);
videoControls.style.opacity = '1';
});
video.addEventListener('mouseleave', hideControls);
//carousel
function setupCarousel(container) {
const carousel = container.querySelector('.movie-carousel');
const leftArrow = container.querySelector('.nav-left');
const rightArrow = container.querySelector('.nav-right');
if (carousel && leftArrow && rightArrow) {
const scrollAmount = 500;
rightArrow.onclick = () => carousel.scrollBy({ left: scrollAmount, behavior: 'smooth' });
leftArrow.onclick = () => carousel.scrollBy({ left: -scrollAmount, behavior: 'smooth' });
}
}
// Apply carousel setup to all carousels
document.querySelectorAll('.carousel-container').forEach(setupCarousel);
//new
const images2 = document.querySelectorAll('.image2');
const prevBtn2 = document.getElementById('prevBtn2');
const nextBtn2 = document.getElementById('nextBtn2');
let position2 = 0;
const positions2 = [
{x: -400, rotate: 30},
{x: -200, rotate: 20},
{x: 0, rotate: 0},
{x: 200, rotate: -20},
{x: 400, rotate: -30}
];
updateCarousel2();
nextBtn2.addEventListener('click', function() {
position2++;
if (position2 >= images2.length) position2 = 0;
updateCarousel2();
});
prevBtn2.addEventListener('click', function() {
position2--;
if (position2 < 0) position2 = images2.length - 1;
updateCarousel2();
});
function updateCarousel2() {
images2.forEach(img => img.classList.remove('center2'));
images2.forEach((img, index) => {
let pos = (index - position2) % images2.length;
if (pos < 0) pos += images2.length;
if (pos >= 0 && pos <= 4) {
img.style.display = 'block';
img.style.transform = `translateX(${positions2[pos].x}px) rotateY(${positions2[pos].rotate}deg)`;
if (pos === 2) {
img.classList.add('center2');
}
} else {
img.style.display = 'none';
}
});
}
const toggleBtn = document.getElementById("theme-toggle");
const icon = toggleBtn.querySelector("i");
const savedTheme = localStorage.getItem("theme");
if (savedTheme === "dark") {
document.body.classList.add("dark-theme");
icon.classList.replace("fa-moon", "fa-sun");
toggleBtn.setAttribute("aria-pressed", "true");
}
toggleBtn.addEventListener("click", () => {
const isDark = document.body.classList.toggle("dark-theme");
if (isDark) {
icon.classList.replace("fa-moon", "fa-sun");
localStorage.setItem("theme", "dark");
toggleBtn.setAttribute("aria-pressed", "true");
} else {
icon.classList.replace("fa-sun", "fa-moon");
localStorage.setItem("theme", "light");
toggleBtn.setAttribute("aria-pressed", "false");
}
});