-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
277 lines (237 loc) · 9.21 KB
/
Copy pathscript.js
File metadata and controls
277 lines (237 loc) · 9.21 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
// Email signup functionality
document.addEventListener('DOMContentLoaded', function() {
const signupForm = document.getElementById('signupForm');
const emailInput = document.getElementById('emailInput');
const signupMessage = document.getElementById('signupMessage');
// Handle form submission
signupForm.addEventListener('submit', async function(e) {
e.preventDefault();
const email = emailInput.value.trim();
if (!validateEmail(email)) {
showMessage('Please enter a valid email address.', 'error');
return;
}
// Disable form during submission
emailInput.disabled = true;
const submitButton = signupForm.querySelector('.cta-button');
const originalButtonText = submitButton.querySelector('.button-text').textContent;
submitButton.querySelector('.button-text').textContent = 'Signing up...';
submitButton.disabled = true;
try {
// Simulate API call (replace with actual endpoint when ready)
await simulateSignup(email);
// Success
showMessage('Thanks for signing up! We\'ll notify you when LingLang launches.', 'success');
emailInput.value = '';
// Store in localStorage (for demo purposes)
const signups = JSON.parse(localStorage.getItem('linglang_signups') || '[]');
signups.push({ email, date: new Date().toISOString() });
localStorage.setItem('linglang_signups', JSON.stringify(signups));
} catch (error) {
showMessage('Something went wrong. Please try again later.', 'error');
} finally {
// Re-enable form
emailInput.disabled = false;
submitButton.querySelector('.button-text').textContent = originalButtonText;
submitButton.disabled = false;
}
});
// Email validation
function validateEmail(email) {
const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return regex.test(email);
}
// Show message
function showMessage(text, type) {
signupMessage.textContent = text;
signupMessage.className = `signup-message ${type}`;
// Auto-hide message after 5 seconds
setTimeout(() => {
signupMessage.className = 'signup-message';
}, 5000);
}
// Simulate API call (replace with actual implementation)
function simulateSignup(email) {
return new Promise((resolve) => {
setTimeout(() => {
console.log('Email signup:', email);
resolve();
}, 1000);
});
}
// Intersection Observer for animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -100px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.animationPlayState = 'running';
observer.unobserve(entry.target);
}
});
}, observerOptions);
// Observe feature cards
document.querySelectorAll('.feature-card').forEach(card => {
card.style.animationPlayState = 'paused';
observer.observe(card);
});
// Smooth scroll 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) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Add parallax effect to graph nodes
let ticking = false;
function updateParallax() {
const scrollY = window.pageYOffset;
const nodes = document.querySelectorAll('.graph-node');
nodes.forEach((node, index) => {
const speed = 0.5 + (index * 0.1);
const yPos = -(scrollY * speed);
node.style.transform = `translateY(${yPos}px)`;
});
ticking = false;
}
function requestTick() {
if (!ticking) {
window.requestAnimationFrame(updateParallax);
ticking = true;
}
}
// Check if user prefers reduced motion
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
if (!prefersReducedMotion) {
window.addEventListener('scroll', requestTick);
}
// Add keyboard navigation for accessibility
emailInput.addEventListener('keydown', function(e) {
if (e.key === 'Enter') {
e.preventDefault();
signupForm.dispatchEvent(new Event('submit'));
}
});
// Dynamic copyright year
const currentYear = new Date().getFullYear();
const copyrightText = document.querySelector('.footer-text');
if (copyrightText) {
copyrightText.textContent = `© ${currentYear} LingLang. All rights reserved.`;
}
// Chat Animation - Simulate typing and messages
function simulateChatAnimation() {
const messages = document.querySelectorAll('.chat-messages .message');
const typingIndicator = document.querySelector('.typing-indicator');
// Hide all messages initially
messages.forEach(message => {
message.style.opacity = '0';
message.style.transform = 'translateY(10px)';
});
// Hide typing indicator initially
if (typingIndicator) {
typingIndicator.style.opacity = '0';
}
// Animate messages appearing one by one
let delay = 0;
messages.forEach((message, index) => {
setTimeout(() => {
message.style.transition = 'all 0.5s ease-out';
message.style.opacity = '1';
message.style.transform = 'translateY(0)';
// Show typing indicator before last message
if (index === messages.length - 2 && typingIndicator) {
setTimeout(() => {
typingIndicator.style.opacity = '1';
// Hide typing indicator after 2 seconds and show last message
setTimeout(() => {
typingIndicator.style.opacity = '0';
}, 2000);
}, 1000);
}
}, delay);
delay += 1500;
});
}
// Phone mockup interaction
const phoneMockup = document.querySelector('.phone-mockup');
if (phoneMockup) {
// Add subtle floating animation
phoneMockup.style.animation = 'phoneFloat 6s ease-in-out infinite';
// Start chat animation when phone is visible
const phoneObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
setTimeout(simulateChatAnimation, 1000);
phoneObserver.unobserve(entry.target);
}
});
}, { threshold: 0.3 });
phoneObserver.observe(phoneMockup);
}
// Add click effect to feature cards
document.querySelectorAll('.feature-card').forEach(card => {
card.addEventListener('click', function() {
this.style.transform = 'translateY(-5px) scale(1.02)';
setTimeout(() => {
this.style.transform = '';
}, 200);
});
});
// Update button text based on form state
function updateButtonText() {
const button = document.querySelector('.cta-button .button-text');
const emailInput = document.getElementById('emailInput');
if (emailInput && button) {
emailInput.addEventListener('input', function() {
if (this.value.trim()) {
button.textContent = 'Join Waitlist';
} else {
button.textContent = 'Join Waitlist';
}
});
}
}
updateButtonText();
// Enhanced success message
const originalShowMessage = showMessage;
function showMessage(text, type) {
if (type === 'success') {
// Add celebration effect
createCelebrationEffect();
}
originalShowMessage(text, type);
}
function createCelebrationEffect() {
// Simple celebration animation
const button = document.querySelector('.cta-button');
if (button) {
button.style.transform = 'scale(1.1)';
button.style.background = 'linear-gradient(135deg, #26a69a, #00897b)';
setTimeout(() => {
button.style.transform = '';
button.style.background = '';
}, 300);
}
}
// Log page view (for analytics when implemented)
console.log('LingLang Coming Soon Page Loaded');
// Optional: Add some interactivity to the logo
const logo = document.querySelector('.logo');
if (logo) {
logo.addEventListener('click', () => {
const logoIcon = logo.querySelector('.logo-icon');
logoIcon.style.animation = 'none';
setTimeout(() => {
logoIcon.style.animation = '';
}, 10);
});
}
});