-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
98 lines (76 loc) · 3 KB
/
Copy pathscript.js
File metadata and controls
98 lines (76 loc) · 3 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
document.addEventListener("DOMContentLoaded", function() {
// Check if elements exist
const slider = document.querySelector('.slider');
const slides = document.querySelectorAll('.slide');
const indicatorsContainer = document.querySelector('.indicators');
const prevBtn = document.querySelector('.prev');
const nextBtn = document.querySelector('.next');
let currentIndex = 0;
// Add indicators
slides.forEach((_, index) => {
const indicator = document.createElement('div');
indicator.classList.add('indicator');
indicator.addEventListener('click', () => goToSlide(index));
indicatorsContainer.appendChild(indicator);
});
const indicators = document.querySelectorAll('.indicator');
function updateIndicators() {
indicators.forEach((indicator, index) => {
if (index === currentIndex) {
indicator.classList.add('active');
} else {
indicator.classList.remove('active');
}
});
}
function goToSlide(index) {
currentIndex = index;
const translateX = -currentIndex * 100 + '%';
slider.style.transform = `translateX(${translateX})`;
updateIndicators();
}
prevBtn.addEventListener('click', () => {
if (currentIndex > 0) {
goToSlide(currentIndex - 1);
}
});
nextBtn.addEventListener('click', () => {
if (currentIndex < slides.length - 1) {
goToSlide(currentIndex + 1);
}
});
// Initialize the slider
goToSlide(currentIndex);
// Function to check if the user is on a desktop device
function isDesktop() {
return window.innerWidth > 768; // Adjust the width based on your design
}
// Function to redirect to another page
function redirectToAnotherPage() {
window.location.href = '404.html';
}
// Check if the user is on a desktop and redirect if true
window.addEventListener('DOMContentLoaded', function () {
if (isDesktop()) {
redirectToAnotherPage();
}
});
// Function to disable right-click context menu
function disableRightClick(event) {
event.preventDefault();
}
// Attach the disableRightClick function to the contextmenu event
window.addEventListener('contextmenu', disableRightClick);
});
// Glowing 🌟 effect for Subscribe button
// Function to add glowing effect to the subscribe button
function glowSubscribeButton() {
const subscribeButton = document.querySelector('.bg-red-600');
// Add glowing effect by toggling the 'glow' class
subscribeButton.classList.add('glow');
setTimeout(() => {
subscribeButton.classList.remove('glow');
}, 2000);
}
// Trigger the glowing effect every 10 seconds
setInterval(glowSubscribeButton, 6000);