-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
434 lines (370 loc) · 13.7 KB
/
script.js
File metadata and controls
434 lines (370 loc) · 13.7 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
// Initialize AOS (Animate On Scroll)
document.addEventListener('DOMContentLoaded', function() {
if (window.AOS && typeof window.AOS.init === 'function') {
AOS.init({
duration: 800,
easing: 'ease-in-out',
once: true,
offset: 100
});
}
});
// Mobile menu 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-link').forEach(n => n.addEventListener('click', () => {
hamburger.classList.remove('active');
navMenu.classList.remove('active');
}));
// 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',
block: 'start'
});
}
});
});
// Navbar background 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 4px 6px -1px rgb(0 0 0 / 0.1)';
} else {
navbar.style.background = 'rgba(255, 255, 255, 0.95)';
navbar.style.boxShadow = 'none';
}
});
// Animated counter for stats
const animateCounters = () => {
const counters = document.querySelectorAll('.stat-number');
const speed = 200;
counters.forEach(counter => {
const updateCount = () => {
const target = parseInt(counter.getAttribute('data-target'));
const count = parseInt(counter.innerText.replace(/[^0-9]/g, ''));
const inc = target / speed;
if (count < target) {
const newCount = Math.ceil(count + inc);
if (counter.innerText.includes('%')) {
counter.innerText = newCount + '%';
} else if (counter.innerText.includes('+')) {
counter.innerText = newCount + '+';
} else {
counter.innerText = newCount;
}
setTimeout(updateCount, 1);
} else {
counter.innerText = counter.getAttribute('data-target') +
(counter.innerText.includes('%') ? '%' : '+');
}
};
updateCount();
});
};
// Set data-target attributes for counters
document.addEventListener('DOMContentLoaded', () => {
const statNumbers = document.querySelectorAll('.stat-number');
statNumbers.forEach(stat => {
const text = stat.innerText;
const number = text.replace(/[^0-9]/g, '');
stat.setAttribute('data-target', number);
stat.innerText = '0' + (text.includes('%') ? '%' : '+');
});
});
// Intersection Observer for counter animation
const observerOptions = {
threshold: 0.7
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
animateCounters();
observer.unobserve(entry.target);
}
});
}, observerOptions);
const statsSection = document.querySelector('.stats-grid');
if (statsSection) {
observer.observe(statsSection);
}
// Form handling
const contactForm = document.querySelector('.contact-form');
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
// Get form data
const formData = new FormData(this);
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const message = document.getElementById('message').value;
// Simple validation
if (!name || !email || !message) {
showNotification('Por favor, preencha todos os campos.', 'error');
return;
}
if (!isValidEmail(email)) {
showNotification('Por favor, insira um e-mail válido.', 'error');
return;
}
// Simulate form submission
const submitBtn = this.querySelector('button[type="submit"]');
const originalText = submitBtn.innerHTML;
submitBtn.innerHTML = '<span>Enviando...</span>';
submitBtn.disabled = true;
setTimeout(() => {
showNotification('Mensagem enviada com sucesso! Entraremos em contato em breve.', 'success');
this.reset();
submitBtn.innerHTML = originalText;
submitBtn.disabled = false;
}, 2000);
});
}
// Email validation
function isValidEmail(email) {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return emailRegex.test(email);
}
// Notification system
function showNotification(message, type = 'info') {
// Remove existing notifications
const existingNotifications = document.querySelectorAll('.notification');
existingNotifications.forEach(notification => notification.remove());
// Create notification element
const notification = document.createElement('div');
notification.className = `notification notification-${type}`;
notification.innerHTML = `
<div class="notification-content">
<span class="notification-message">${message}</span>
<button class="notification-close">×</button>
</div>
`;
// Add to body
document.body.appendChild(notification);
// Add styles
const style = document.createElement('style');
style.textContent = `
.notification {
position: fixed;
top: 100px;
right: 20px;
background: white;
border-radius: 12px;
box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
z-index: 10000;
transform: translateX(400px);
transition: transform 0.3s ease-in-out;
max-width: 400px;
}
.notification.show {
transform: translateX(0);
}
.notification-content {
padding: 1rem 1.5rem;
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
}
.notification-success {
border-left: 4px solid var(--primary-color);
}
.notification-error {
border-left: 4px solid #ef4444;
}
.notification-message {
color: var(--gray-700);
font-weight: 500;
}
.notification-close {
background: none;
border: none;
font-size: 1.5rem;
cursor: pointer;
color: var(--gray-400);
padding: 0;
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
}
.notification-close:hover {
color: var(--gray-600);
}
`;
if (!document.querySelector('#notification-styles')) {
style.id = 'notification-styles';
document.head.appendChild(style);
}
// Show notification
setTimeout(() => notification.classList.add('show'), 100);
// Auto hide after 5 seconds
setTimeout(() => hideNotification(notification), 5000);
// Close button functionality
notification.querySelector('.notification-close').addEventListener('click', () => {
hideNotification(notification);
});
}
function hideNotification(notification) {
notification.classList.remove('show');
setTimeout(() => notification.remove(), 300);
}
// Parallax effect for hero section
window.addEventListener('scroll', () => {
const scrolled = window.pageYOffset;
const hero = document.querySelector('.hero');
const shapes = document.querySelectorAll('.shape');
// Only apply parallax on homepage (hero without margin-top)
if (hero && !hero.style.marginTop) {
hero.style.transform = `translateY(${scrolled * 0.5}px)`;
}
shapes.forEach((shape, index) => {
const speed = 0.2 + (index * 0.1);
shape.style.transform = `translateY(${scrolled * speed}px) rotate(${scrolled * 0.1}deg)`;
});
});
// Tech stack items hover effect
document.querySelectorAll('.tech-item').forEach(item => {
item.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-8px) scale(1.05)';
});
item.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(-2px) scale(1)';
});
});
// Service cards tilt effect
document.querySelectorAll('.service-card').forEach(card => {
card.addEventListener('mousemove', function(e) {
const rect = this.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
const centerX = rect.width / 2;
const centerY = rect.height / 2;
const rotateX = (y - centerY) / centerY * -10;
const rotateY = (x - centerX) / centerX * 10;
this.style.transform = `perspective(1000px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) translateY(-10px)`;
});
card.addEventListener('mouseleave', function() {
this.style.transform = 'perspective(1000px) rotateX(0deg) rotateY(0deg) translateY(0px)';
});
});
// Typing effect for hero title
function typeWriter(element, text, speed = 50) {
let i = 0;
element.innerHTML = '';
function type() {
if (i < text.length) {
element.innerHTML += text.charAt(i);
i++;
setTimeout(type, speed);
}
}
type();
}
// Initialize typing effect when page loads
window.addEventListener('load', () => {
const heroTitle = document.querySelector('.hero-title');
if (heroTitle) {
const originalText = heroTitle.innerHTML;
setTimeout(() => {
typeWriter(heroTitle, originalText.replace(/<[^>]*>/g, ''), 30);
}, 1000);
}
});
// Smooth reveal animations
const revealElements = document.querySelectorAll('.service-card, .tech-item, .stat-item');
const revealObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, {
threshold: 0.1
});
revealElements.forEach(el => {
el.style.opacity = '0';
el.style.transform = 'translateY(30px)';
el.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
revealObserver.observe(el);
});
// Add loading animation
window.addEventListener('load', () => {
document.body.classList.add('loaded');
// Add loading styles
const loadingStyle = document.createElement('style');
loadingStyle.textContent = `
body:not(.loaded) {
overflow: hidden;
}
body:not(.loaded)::before {
content: '';
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
z-index: 10000;
display: flex;
align-items: center;
justify-content: center;
}
body:not(.loaded)::after {
content: 'GreenToast';
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
font-size: 2rem;
font-weight: 700;
z-index: 10001;
animation: pulse 1.5s infinite;
}
body.loaded::before,
body.loaded::after {
opacity: 0;
pointer-events: none;
transition: opacity 0.5s ease;
}
`;
document.head.appendChild(loadingStyle);
});
// Learn: busca e filtro de categorias
document.addEventListener('DOMContentLoaded', () => {
const searchInput = document.getElementById('learnSearch');
const cards = document.querySelectorAll('.learn-card');
const chips = document.querySelectorAll('.chip');
if (!searchInput || cards.length === 0) return;
const applyFilter = () => {
const q = searchInput.value.toLowerCase().trim();
const activeChip = document.querySelector('.chip.active');
const activeCat = activeChip ? activeChip.dataset.category : 'all';
cards.forEach(card => {
const matchesText = card.textContent.toLowerCase().includes(q);
const matchesCat = activeCat === 'all' || card.dataset.category === activeCat;
card.style.display = (matchesText && matchesCat) ? '' : 'none';
});
};
searchInput.addEventListener('input', applyFilter);
chips.forEach(chip => {
chip.addEventListener('click', () => {
chips.forEach(c => c.classList.remove('active'));
chip.classList.add('active');
applyFilter();
});
});
});