-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
474 lines (406 loc) · 16.9 KB
/
script.js
File metadata and controls
474 lines (406 loc) · 16.9 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
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
// Timeless Landing Page JavaScript
// Interactive features and animations
document.addEventListener('DOMContentLoaded', function() {
// Mobile Navigation Toggle
const hamburger = document.getElementById('hamburger');
const navMenu = document.getElementById('nav-menu');
if (hamburger && navMenu) {
hamburger.addEventListener('click', function() {
hamburger.classList.toggle('active');
navMenu.classList.toggle('active');
});
}
// Close mobile menu when clicking on a link
const navLinks = document.querySelectorAll('.nav-link');
navLinks.forEach(link => {
link.addEventListener('click', () => {
hamburger.classList.remove('active');
navMenu.classList.remove('active');
});
});
// Smooth scrolling for anchor links - ONLY for internal page anchors
const anchors = document.querySelectorAll('a[href^="#"]:not([href="#"])');
anchors.forEach(anchor => {
anchor.addEventListener('click', function(e) {
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
e.preventDefault(); // Only prevent default if we have a target
const offsetTop = targetElement.offsetTop - 80; // Account for fixed navbar
window.scrollTo({
top: offsetTop,
behavior: 'smooth'
});
}
});
});
// Navbar background on scroll
const navbar = document.querySelector('.navbar');
window.addEventListener('scroll', function() {
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 = 'none';
}
});
// Intersection Observer for 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('animate');
}
});
}, observerOptions);
// Observe elements for animation
const animatedElements = document.querySelectorAll('.feature-card, .step, .about-text, .about-visual');
animatedElements.forEach(element => {
observer.observe(element);
});
// Counter animation for hero stats
function animateCounters() {
const counters = document.querySelectorAll('.stat-number');
const speed = 200; // Animation speed
counters.forEach(counter => {
const target = parseInt(counter.getAttribute('data-target')) || parseInt(counter.innerText.replace(/[^\d]/g, ''));
// Skip animation for text-only elements (no numbers)
if (isNaN(target) || target === 0) {
return;
}
const increment = target / speed;
let current = 0;
const timer = setInterval(() => {
current += increment;
if (current >= target) {
current = target;
clearInterval(timer);
}
// Format the number based on original text
const originalText = counter.innerText;
if (originalText.includes('K')) {
counter.innerText = Math.floor(current / 1000) + 'K+';
} else if (originalText.includes('%')) {
counter.innerText = Math.floor(current) + '%';
} else {
counter.innerText = Math.floor(current) + '+';
}
}, 1);
});
}
// Trigger counter animation when hero section is visible
const heroObserver = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
setTimeout(animateCounters, 500); // Delay for better effect
heroObserver.unobserve(entry.target);
}
});
}, { threshold: 0.5 });
const heroStats = document.querySelector('.hero-stats');
if (heroStats) {
heroObserver.observe(heroStats);
}
// Parallax effect for hero background shapes
window.addEventListener('scroll', function() {
const scrolled = window.pageYOffset;
const parallaxElements = document.querySelectorAll('.bg-shape');
parallaxElements.forEach(element => {
const speed = element.dataset.speed || 0.5;
const yPos = -(scrolled * speed);
element.style.transform = `translateY(${yPos}px)`;
});
});
// Form submission 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 = this.querySelector('input[type="text"]').value;
const email = this.querySelector('input[type="email"]').value;
const message = this.querySelector('textarea').value;
// Simple validation
if (!name || !email || !message) {
showNotification('Please fill in all fields', 'error');
return;
}
if (!isValidEmail(email)) {
showNotification('Please enter a valid email address', 'error');
return;
}
// Simulate form submission
showNotification('Thank you for your message! We\'ll get back to you soon.', 'success');
// Reset form
this.reset();
});
}
// Email validation function
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 styles
notification.style.cssText = `
position: fixed;
top: 100px;
right: 20px;
background: ${type === 'success' ? '#16A34A' : type === 'error' ? '#DC2626' : '#1E2A78'};
color: white;
padding: 1rem 1.5rem;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
z-index: 1001;
transform: translateX(100%);
transition: transform 0.3s ease;
max-width: 400px;
`;
// Add to document
document.body.appendChild(notification);
// Animate in
setTimeout(() => {
notification.style.transform = 'translateX(0)';
}, 100);
// Close button functionality
const closeBtn = notification.querySelector('.notification-close');
closeBtn.addEventListener('click', () => {
hideNotification(notification);
});
// Auto hide after 5 seconds
setTimeout(() => {
hideNotification(notification);
}, 5000);
}
function hideNotification(notification) {
notification.style.transform = 'translateX(100%)';
setTimeout(() => {
if (notification.parentNode) {
notification.parentNode.removeChild(notification);
}
}, 300);
}
// Download button tracking
const downloadButtons = document.querySelectorAll('.download-btn');
downloadButtons.forEach(button => {
button.addEventListener('click', function(e) {
e.preventDefault();
const platform = this.querySelector('img').alt.includes('App Store') ? 'iOS' : 'Android';
showNotification(`${platform} download will be available soon!`, 'info');
// Track download attempt (you can integrate with analytics here)
console.log(`Download attempted for ${platform}`);
});
});
// Feature card hover effects and click functionality
const featureCards = document.querySelectorAll('.feature-card');
featureCards.forEach(card => {
card.addEventListener('mouseenter', function() {
if (!this.classList.contains('clickable-card')) {
this.style.transform = 'translateY(-10px) scale(1.02)';
}
});
card.addEventListener('mouseleave', function() {
if (!this.classList.contains('clickable-card')) {
this.style.transform = 'translateY(0) scale(1)';
}
});
});
// Screenshot modal functionality
const modal = document.getElementById('screenshotModal');
const modalImage = document.getElementById('modalImage');
const modalCaption = document.getElementById('modalCaption');
const modalClose = document.querySelector('.modal-close');
// Clickable cards functionality
const clickableCards = document.querySelectorAll('.clickable-card');
clickableCards.forEach(card => {
card.addEventListener('click', function() {
const screenshotPath = this.getAttribute('data-screenshot');
const cardTitle = this.querySelector('.feature-title').textContent;
const cardDescription = this.querySelector('.feature-description').textContent;
if (screenshotPath) {
modalImage.src = screenshotPath;
modalImage.alt = `${cardTitle} screenshot`;
modalCaption.textContent = `${cardTitle} - ${cardDescription}`;
modal.classList.add('active');
document.body.style.overflow = 'hidden'; // Prevent background scrolling
}
});
// Add visual feedback for clickable cards
card.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-8px) scale(1.02)';
});
card.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0) scale(1)';
});
});
// Modal close functionality
function closeModal() {
modal.classList.remove('active');
document.body.style.overflow = 'auto'; // Restore scrolling
}
modalClose.addEventListener('click', closeModal);
// Close modal when clicking outside the image
modal.addEventListener('click', function(e) {
if (e.target === modal) {
closeModal();
}
});
// Close modal with Escape key
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape' && modal.classList.contains('active')) {
closeModal();
}
});
// Floating animation for job cards in hero section
const jobCards = document.querySelectorAll('.job-card');
jobCards.forEach((card, index) => {
// Add random floating movement
setInterval(() => {
const randomX = (Math.random() - 0.5) * 20;
const randomY = (Math.random() - 0.5) * 20;
card.style.transform = `translate(${randomX}px, ${randomY}px)`;
}, 3000 + (index * 1000));
});
// Lazy loading for images
const images = document.querySelectorAll('img[data-src]');
const imageObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const img = entry.target;
img.src = img.dataset.src;
img.classList.remove('lazy');
imageObserver.unobserve(img);
}
});
});
images.forEach(img => imageObserver.observe(img));
// Add loading state to buttons
const buttons = document.querySelectorAll('.btn');
buttons.forEach(button => {
button.addEventListener('click', function() {
const originalText = this.innerHTML;
// Don't add loading to download buttons or navigation
if (this.href && (this.href.includes('#') || this.href === '#')) {
return;
}
this.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Loading...';
this.disabled = true;
// Restore original state after 2 seconds (simulate loading)
setTimeout(() => {
this.innerHTML = originalText;
this.disabled = false;
}, 2000);
});
});
// Add typing effect to 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 for hero title
const heroTitle = document.querySelector('.hero-title');
if (heroTitle) {
const originalText = heroTitle.textContent;
// Delay the typing effect slightly
setTimeout(() => {
typeWriter(heroTitle, originalText, 30);
}, 500);
}
// Add scroll progress indicator
function createScrollProgress() {
const progressBar = document.createElement('div');
progressBar.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 0%;
height: 3px;
background: linear-gradient(90deg, #1E2A78, #FFD700);
z-index: 1002;
transition: width 0.1s ease;
`;
document.body.appendChild(progressBar);
window.addEventListener('scroll', () => {
const scrolled = (window.scrollY / (document.documentElement.scrollHeight - window.innerHeight)) * 100;
progressBar.style.width = scrolled + '%';
});
}
createScrollProgress();
});
// Utility functions
function debounce(func, wait, immediate) {
let timeout;
return function executedFunction() {
const context = this;
const args = arguments;
const later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
const callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
}
// Optimized scroll handling
const optimizedScroll = debounce(function() {
// Scroll-related optimizations can be added here
}, 10);
window.addEventListener('scroll', optimizedScroll);
// Add custom cursor effect for interactive elements
document.addEventListener('mousemove', function(e) {
const interactiveElements = document.querySelectorAll('a, button, .feature-card, .job-card');
const cursor = document.querySelector('.custom-cursor');
if (!cursor) {
const customCursor = document.createElement('div');
customCursor.className = 'custom-cursor';
customCursor.style.cssText = `
position: fixed;
width: 20px;
height: 20px;
background: #FFD700;
border-radius: 50%;
pointer-events: none;
z-index: 9999;
transition: transform 0.1s ease;
opacity: 0;
`;
document.body.appendChild(customCursor);
}
});
// Performance monitoring
if ('performance' in window) {
window.addEventListener('load', function() {
const loadTime = performance.timing.loadEventEnd - performance.timing.navigationStart;
console.log(`Page loaded in ${loadTime}ms`);
});
}