-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
200 lines (168 loc) · 6.3 KB
/
script.js
File metadata and controls
200 lines (168 loc) · 6.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
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
// Mobile Menu Toggle
const mobileMenuToggle = document.getElementById('mobileMenuToggle');
const mobileMenu = document.getElementById('mobileMenu');
const menuIcon = document.getElementById('menuIcon');
mobileMenuToggle.addEventListener('click', () => {
mobileMenu.classList.toggle('active');
if (mobileMenu.classList.contains('active')) {
menuIcon.classList.remove('fa-bars');
menuIcon.classList.add('fa-times');
} else {
menuIcon.classList.remove('fa-times');
menuIcon.classList.add('fa-bars');
}
});
// Close mobile menu when clicking on a link
function closeMobileMenu() {
mobileMenu.classList.remove('active');
menuIcon.classList.remove('fa-times');
menuIcon.classList.add('fa-bars');
}
// Smooth scrolling for navigation links
function scrollToSection(sectionId) {
const element = document.getElementById(sectionId);
if (element) {
const headerHeight = 64;
const elementPosition = element.getBoundingClientRect().top;
const offsetPosition = elementPosition + window.pageYOffset - headerHeight;
window.scrollTo({
top: offsetPosition,
behavior: 'smooth'
});
}
}
// Add smooth scrolling to all anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href').substring(1);
scrollToSection(targetId);
});
});
// Header scroll effect
const header = document.getElementById('header');
let lastScroll = 0;
window.addEventListener('scroll', () => {
const currentScroll = window.pageYOffset;
if (currentScroll > 20) {
header.style.boxShadow = '0 4px 6px rgba(0, 0, 0, 0.1)';
} else {
header.style.boxShadow = '0 1px 3px rgba(0, 0, 0, 0.1)';
}
lastScroll = currentScroll;
}, { passive: true });
// Toast notification system
function showToast(title, description) {
const toast = document.getElementById('toast');
toast.innerHTML = `
<div class="toast-title">${title}</div>
<div class="toast-description">${description}</div>
`;
toast.classList.add('show');
setTimeout(() => {
toast.classList.remove('show');
}, 3000);
}
// Country select styling
const countrySelect = document.getElementById('country');
if (countrySelect) {
function updateCountrySelectStyle() {
if (countrySelect.value === '') {
countrySelect.classList.add('empty');
} else {
countrySelect.classList.remove('empty');
}
}
updateCountrySelectStyle();
countrySelect.addEventListener('change', updateCountrySelectStyle);
}
// Contact Form Submission
const contactForm = document.getElementById('contactForm');
contactForm.addEventListener('submit', async (e) => {
e.preventDefault();
// Disable submit button to prevent double submission
const submitButton = contactForm.querySelector('button[type="submit"]');
const originalButtonText = submitButton.innerHTML;
submitButton.disabled = true;
submitButton.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Sending...';
try {
// Get form data
const formData = new FormData(contactForm);
// Submit to Web3Forms
const response = await fetch('https://api.web3forms.com/submit', {
method: 'POST',
body: formData
});
const result = await response.json();
if (result.success) {
// Show success toast
showToast(
'Message Sent!',
"Thank you for contacting us. We'll get back to you within 24 hours."
);
// Reset form
contactForm.reset();
} else {
// Show error toast
showToast(
'Error',
result.message || 'Something went wrong. Please try again later.'
);
}
} catch (error) {
// Show error toast
showToast(
'Error',
'Failed to send message. Please check your connection and try again.'
);
console.error('Form submission error:', error);
} finally {
// Re-enable submit button
submitButton.disabled = false;
submitButton.innerHTML = originalButtonText;
}
});
// Intersection Observer for fade-in animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
// Apply fade-in animation to cards
document.addEventListener('DOMContentLoaded', () => {
const cards = document.querySelectorAll('.service-card, .portfolio-card, .team-card, .testimonial-card');
cards.forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(card);
});
});
// Add active state to navigation based on scroll position
window.addEventListener('scroll', () => {
const sections = document.querySelectorAll('section[id]');
const scrollY = window.pageYOffset;
sections.forEach(section => {
const sectionHeight = section.offsetHeight;
const sectionTop = section.offsetTop - 100;
const sectionId = section.getAttribute('id');
const navLink = document.querySelector(`.nav-desktop a[href="#${sectionId}"]`);
if (navLink && scrollY > sectionTop && scrollY <= sectionTop + sectionHeight) {
document.querySelectorAll('.nav-desktop a').forEach(link => {
link.style.color = '#374151';
});
navLink.style.color = '#1d4ed8';
}
});
}, { passive: true });
// Console log for developers
console.log('%c🚀 Augment Lab', 'color: #1d4ed8; font-size: 24px; font-weight: bold;');
console.log('%cExpert Next.js & Flutter Development', 'color: #6b7280; font-size: 14px;');
console.log('%cInterested in working with us? Contact us at hello@augmentlab.com', 'color: #374151; font-size: 12px;');