-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
107 lines (95 loc) · 3.71 KB
/
script.js
File metadata and controls
107 lines (95 loc) · 3.71 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
// Common functionality for all pages
document.addEventListener('DOMContentLoaded', function() {
// Navbar scroll effect
const navbar = document.querySelector('.navbar');
window.addEventListener('scroll', function() {
if (window.scrollY > 50) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// Mobile menu toggle
const mobileMenuBtn = document.querySelector('.mobile-menu-btn');
const navLinks = document.querySelector('.nav-links');
if (mobileMenuBtn) {
mobileMenuBtn.addEventListener('click', function() {
navLinks.classList.toggle('active');
});
}
// Set active navigation link based on current page
const currentPage = window.location.pathname.split('/').pop() || 'index.html';
const navLinksAll = document.querySelectorAll('.nav-links a');
navLinksAll.forEach(link => {
const linkPage = link.getAttribute('href');
if (linkPage === currentPage) {
link.classList.add('active');
}
});
// Scroll animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
// Animate counting numbers
if (entry.target.classList.contains('stat-number')) {
const target = parseInt(entry.target.getAttribute('data-count'));
animateValue(entry.target, 0, target, 2000);
}
}
});
}, observerOptions);
// Observe elements with fade-in class
document.querySelectorAll('.fade-in').forEach(el => {
observer.observe(el);
});
// Number counting animation
function animateValue(element, start, end, duration) {
let startTimestamp = null;
const step = (timestamp) => {
if (!startTimestamp) startTimestamp = timestamp;
const progress = Math.min((timestamp - startTimestamp) / duration, 1);
element.innerHTML = Math.floor(progress * (end - start) + start);
if (progress < 1) {
window.requestAnimationFrame(step);
}
};
window.requestAnimationFrame(step);
}
// Smooth scrolling for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth'
});
}
});
});
// Form submission handling
const contactForm = document.getElementById('contactForm');
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
// Here you would typically send the form data to a server
alert('Thank you for your message! We will get back to you soon.');
contactForm.reset();
});
}
// Get Involved form handling
const involvementForm = document.getElementById('involvementForm');
if (involvementForm) {
involvementForm.addEventListener('submit', function(e) {
e.preventDefault();
const involvementType = document.getElementById('involvementType').value;
alert(`Thank you for your interest in ${involvementType}! We will contact you soon.`);
involvementForm.reset();
});
}
});