-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
169 lines (144 loc) · 5.06 KB
/
script.js
File metadata and controls
169 lines (144 loc) · 5.06 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
// Mobile navigation toggle
const hamburger = document.querySelector('.hamburger');
const navMenu = document.querySelector('.nav-menu');
hamburger.addEventListener('click', () => {
hamburger.classList.toggle('active');
navMenu.classList.toggle('active');
});
// Close mobile menu when clicking on a link
document.querySelectorAll('.nav-menu a').forEach(link => {
link.addEventListener('click', () => {
hamburger.classList.remove('active');
navMenu.classList.remove('active');
});
});
// Copy to clipboard functionality
function copyToClipboard(text) {
navigator.clipboard.writeText(text).then(function() {
const button = event.target.closest('.copy-btn');
if (button) {
const originalIcon = button.innerHTML;
button.innerHTML = '<i class="fas fa-check"></i>';
button.style.color = '#7ad151';
setTimeout(() => {
button.innerHTML = originalIcon;
button.style.color = '';
}, 2000);
}
}).catch(function(err) {
console.error('Could not copy text: ', err);
});
}
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
const navbarHeight = document.querySelector('.navbar').offsetHeight;
const targetPosition = target.offsetTop - navbarHeight;
window.scrollTo({
top: targetPosition,
behavior: 'smooth'
});
}
});
});
// Navbar background change on scroll
window.addEventListener('scroll', () => {
const navbar = document.querySelector('.navbar');
if (window.scrollY > 50) {
navbar.style.background = 'rgba(255, 255, 255, 0.98)';
navbar.style.boxShadow = '0 2px 20px rgba(0, 0, 0, 0.1)';
} else {
navbar.style.background = 'rgba(255, 255, 255, 0.95)';
navbar.style.boxShadow = '0 1px 3px rgba(0, 0, 0, 0.1)';
}
});
// Intersection Observer for animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate-in');
}
});
}, observerOptions);
// Observe elements for animation
document.querySelectorAll('.feature-card, .quick-link-card, .doc-card, .community-card').forEach(el => {
observer.observe(el);
});
// Rotating Gallery functionality
class RotatingGallery {
constructor() {
this.slides = document.querySelectorAll('.gallery-slide');
this.indicators = document.querySelectorAll('.indicator');
this.currentSlide = 0;
this.interval = null;
this.autoPlayDelay = 10000; // 10 seconds
this.init();
}
init() {
if (this.slides.length === 0) return;
// Set up indicator click events
this.indicators.forEach((indicator, index) => {
indicator.addEventListener('click', () => {
this.goToSlide(index);
});
});
// Start auto-play
this.startAutoPlay();
// Pause auto-play on hover
const galleryContainer = document.querySelector('.gallery-container');
if (galleryContainer) {
galleryContainer.addEventListener('mouseenter', () => {
this.stopAutoPlay();
});
galleryContainer.addEventListener('mouseleave', () => {
this.startAutoPlay();
});
}
}
goToSlide(index) {
// Remove active class from current slide and indicator
this.slides[this.currentSlide].classList.remove('active');
this.indicators[this.currentSlide].classList.remove('active');
// Update current slide
this.currentSlide = index;
// Add active class to new slide and indicator
this.slides[this.currentSlide].classList.add('active');
this.indicators[this.currentSlide].classList.add('active');
}
nextSlide() {
const nextIndex = (this.currentSlide + 1) % this.slides.length;
this.goToSlide(nextIndex);
}
startAutoPlay() {
this.stopAutoPlay(); // Clear any existing interval
this.interval = setInterval(() => {
this.nextSlide();
}, this.autoPlayDelay);
}
stopAutoPlay() {
if (this.interval) {
clearInterval(this.interval);
this.interval = null;
}
}
}
// Initialize the rotating gallery when DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
new RotatingGallery();
});
// Loading animation
window.addEventListener('load', () => {
document.body.classList.add('loaded');
});
// Form validation utilities (placeholder)
function validateForm(form) {
// Add form validation logic here
return true;
}