-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
379 lines (321 loc) · 13.4 KB
/
script.js
File metadata and controls
379 lines (321 loc) · 13.4 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
// Mobile menu toggle
const mobileMenuToggle = document.querySelector('.mobile-menu-toggle');
const navLinks = document.querySelector('.nav-links');
const header = document.querySelector('.site-header');
const stickyCta = document.querySelector('.sticky-cta');
// Toggle mobile menu
if (mobileMenuToggle && navLinks) {
mobileMenuToggle.addEventListener('click', () => {
navLinks.classList.toggle('active');
mobileMenuToggle.setAttribute('aria-expanded',
mobileMenuToggle.getAttribute('aria-expanded') === 'true' ? 'false' : 'true'
);
});
}
// Close mobile menu when clicking outside
document.addEventListener('click', (e) => {
if (header && navLinks && !header.contains(e.target) && navLinks.classList.contains('active')) {
navLinks.classList.remove('active');
mobileMenuToggle.setAttribute('aria-expanded', 'false');
}
});
// Close mobile menu when clicking a link
if (navLinks) {
navLinks.querySelectorAll('a').forEach(link => {
link.addEventListener('click', () => {
navLinks.classList.remove('active');
mobileMenuToggle.setAttribute('aria-expanded', 'false');
});
});
}
// Handle sticky CTA visibility
let lastScrollTop = 0;
const scrollThreshold = 100;
const stickyCTA = document.querySelector('.sticky-cta');
if (stickyCTA) {
window.addEventListener('scroll', () => {
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
const scrollDirection = scrollTop > lastScrollTop ? 'down' : 'up';
// Show CTA after scrolling past threshold
if (scrollTop > scrollThreshold) {
stickyCTA.classList.add('visible');
} else {
stickyCTA.classList.remove('visible');
}
// Hide CTA when scrolling down, show when scrolling up
if (scrollDirection === 'down' && scrollTop > scrollThreshold) {
stickyCTA.classList.remove('visible');
} else if (scrollDirection === 'up') {
stickyCTA.classList.add('visible');
}
lastScrollTop = scrollTop;
});
}
// 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'
});
}
});
});
// Form validation
const validateField = (field, errorElement, rules) => {
const value = field.value.trim();
let isValid = true;
let errorMessage = '';
if (rules.required && !value) {
isValid = false;
errorMessage = 'This field is required';
}
if (rules.email && value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
isValid = false;
errorMessage = 'Please enter a valid email address';
}
if (rules.minLength && value.length < rules.minLength) {
isValid = false;
errorMessage = `Must be at least ${rules.minLength} characters`;
}
if (isValid) {
errorElement.style.display = 'none';
field.classList.remove('error');
} else {
errorElement.textContent = errorMessage;
errorElement.style.display = 'block';
field.classList.add('error');
}
return isValid;
};
// Form submission handling
const waitlistForm = document.getElementById('waitlistForm');
const formSuccess = document.getElementById('formSuccess');
if (waitlistForm) {
const formFields = {
name: { required: true, minLength: 2 },
email: { required: true, email: true },
company: { required: true, minLength: 2 },
role: { required: true },
team_size: { required: true }
};
waitlistForm.addEventListener('submit', (e) => {
e.preventDefault();
let isValid = true;
// Validate all fields
Object.keys(formFields).forEach(fieldName => {
const field = document.getElementById(fieldName);
const errorElement = document.getElementById(`${fieldName}Error`);
if (!validateField(field, errorElement, formFields[fieldName])) {
isValid = false;
}
});
if (isValid) {
// Show success message
waitlistForm.style.display = 'none';
formSuccess.classList.add('visible');
// Reset form
waitlistForm.reset();
}
});
// Real-time validation
Object.keys(formFields).forEach(fieldName => {
const field = document.getElementById(fieldName);
const errorElement = document.getElementById(`${fieldName}Error`);
field.addEventListener('input', () => {
validateField(field, errorElement, formFields[fieldName]);
});
field.addEventListener('blur', () => {
validateField(field, errorElement, formFields[fieldName]);
});
});
}
// Intersection Observer for fade-in animations
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.1
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('fade-in');
observer.unobserve(entry.target);
}
});
}, observerOptions);
// Observe all sections
document.querySelectorAll('section').forEach(section => {
section.classList.add('fade-in');
observer.observe(section);
});
// Initialize tooltips
const tooltips = document.querySelectorAll('[data-tooltip]');
tooltips.forEach(tooltip => {
tooltip.addEventListener('mouseenter', (e) => {
const tooltipText = e.target.getAttribute('data-tooltip');
const tooltipElement = document.createElement('div');
tooltipElement.className = 'tooltip';
tooltipElement.textContent = tooltipText;
document.body.appendChild(tooltipElement);
const rect = e.target.getBoundingClientRect();
tooltipElement.style.top = `${rect.top - tooltipElement.offsetHeight - 10}px`;
tooltipElement.style.left = `${rect.left + (rect.width - tooltipElement.offsetWidth) / 2}px`;
});
tooltip.addEventListener('mouseleave', () => {
const tooltipElement = document.querySelector('.tooltip');
if (tooltipElement) {
tooltipElement.remove();
}
});
});
// Quote rotation functionality
const vibeQuotes = {
planning: [
"This task is radiating strong 'ask me again tomorrow' vibes.",
"Feels like a 'we'll cross that bridge when Mercury exits retrograde' type of task.",
"The backlog just whispered it wants a long weekend.",
"Sprint mood check: Feels more like a sprint nap.",
"This feature is definitely more of a 'second coffee' project."
],
coding: [
"Warning: The servers just joined a meditation retreat—expect slow responses.",
"Code freeze initiated because Jupiter looked stressed this morning.",
"The codebase confessed it's having an identity crisis—recommending therapy.",
"Urgency detected, but honestly, it's probably just low blood sugar.",
"High levels of technical debt vibes detected—time for a spiritual refactoring."
],
review: [
"This PR is giving strong 'I wrote this at 2 AM' vibes—proceed with compassion.",
"Merge conflicts spotted—but let's approach them with gentle encouragement.",
"This code review needs less Monday and more Friday energy.",
"Backend API chakra alignment complete—proceed to merge.",
"The pull request feels emotionally balanced but slightly caffeinated."
],
features: [
"The database just texted: 'Feeling drained, send help.'",
"High procrastination energy alert—time to brew more coffee.",
"Deployment pipeline experiencing existential dread—consider emotional healing.",
"Chakra imbalance in authentication flow detected—recommend sage smudging.",
"Team anxiety spike detected—initiating group meditation before deployment."
]
};
function rotateQuotes() {
// Rotate planning quotes
const planningQuotes = document.querySelectorAll('.vibe-process-step:nth-child(1) .vibe-example p');
planningQuotes.forEach(quote => {
quote.textContent = vibeQuotes.planning[Math.floor(Math.random() * vibeQuotes.planning.length)];
});
// Rotate coding quotes
const codingQuotes = document.querySelectorAll('.vibe-process-step:nth-child(2) .vibe-example p');
codingQuotes.forEach(quote => {
quote.textContent = vibeQuotes.coding[Math.floor(Math.random() * vibeQuotes.coding.length)];
});
// Rotate review quotes
const reviewQuotes = document.querySelectorAll('.vibe-process-step:nth-child(3) .vibe-example p');
reviewQuotes.forEach(quote => {
quote.textContent = vibeQuotes.review[Math.floor(Math.random() * vibeQuotes.review.length)];
});
// Rotate feature quotes
const featureQuotes = document.querySelectorAll('.vibe-feature .vibe-example p');
featureQuotes.forEach(quote => {
quote.textContent = vibeQuotes.features[Math.floor(Math.random() * vibeQuotes.features.length)];
});
}
// Initialize quote rotation
document.addEventListener('DOMContentLoaded', () => {
// Initial rotation
rotateQuotes();
// Rotate quotes every 5 seconds
setInterval(rotateQuotes, 5000);
});
// Mobile menu toggle
document.addEventListener('DOMContentLoaded', () => {
const mobileMenuToggle = document.querySelector('.mobile-menu-toggle');
const navLinks = document.querySelector('.nav-links');
if (mobileMenuToggle && navLinks) {
mobileMenuToggle.addEventListener('click', () => {
navLinks.classList.toggle('active');
});
}
});
// Sticky CTA bar
document.addEventListener('DOMContentLoaded', () => {
const stickyCTA = document.querySelector('.sticky-cta');
let lastScroll = 0;
window.addEventListener('scroll', () => {
const currentScroll = window.pageYOffset;
if (currentScroll > lastScroll && currentScroll > 300) {
stickyCTA.classList.add('visible');
} else {
stickyCTA.classList.remove('visible');
}
lastScroll = currentScroll;
});
});
// Vibe Mode Toggle Functionality
document.addEventListener('DOMContentLoaded', function() {
// Track if this is the first toggle
let isFirstToggle = true;
const toggleButton = document.querySelector('.vibe-mode-toggle');
const humorousMode = document.querySelector('.humorous-mode');
const seriousMode = document.querySelector('.serious-mode');
const toggleText = toggleButton.querySelector('.toggle-text');
const humorousDisclaimer = document.querySelector('.humorous-disclaimer');
const seriousDisclaimer = document.querySelector('.serious-disclaimer');
const vibeBadge = document.querySelector('.vibe-badge');
// Hide serious mode by default
seriousMode.style.display = 'none';
seriousDisclaimer.style.display = 'none';
const seriousDisclaimers = [
"10x your output. Deadlines become checkpoints—not pressure points.",
"Pilotic helps you ship faster, without chasing deadlines or burning out.",
"Consistent delivery without deadline anxiety. Work flows. Output scales.",
"Fueled by clarity, not caffeine. And no, deadlines were not harmed."
];
function getRandomDisclaimer() {
return seriousDisclaimers[Math.floor(Math.random() * seriousDisclaimers.length)];
}
// Check for saved preference
const savedMode = localStorage.getItem('vibeMode');
if (savedMode === 'serious') {
toggleMode();
}
toggleButton.addEventListener('click', toggleMode);
function toggleMode() {
const isSerious = humorousMode.style.display === 'none';
// Toggle display
humorousMode.style.display = isSerious ? 'block' : 'none';
seriousMode.style.display = isSerious ? 'none' : 'block';
// Update button state
toggleButton.classList.toggle('serious-mode');
toggleText.textContent = isSerious ? '😂 Joke aside, let\'s be serious' : '😊 Back to fun mode';
// Update badge text
vibeBadge.textContent = isSerious ? 'April Fool\'s 2025' : 'New Feature';
// Update disclaimers
humorousDisclaimer.style.display = isSerious ? 'block' : 'none';
seriousDisclaimer.style.display = isSerious ? 'none' : 'block';
// Show April Fool's message on first toggle to serious mode, then random messages
if (!isSerious) {
if (isFirstToggle) {
seriousDisclaimer.textContent = "Happy April Fool's Day! While we love a good joke, our real product is much more powerful. 🎉";
isFirstToggle = false;
} else {
seriousDisclaimer.textContent = getRandomDisclaimer();
}
}
// Save preference
localStorage.setItem('vibeMode', isSerious ? 'humorous' : 'serious');
// Smooth scroll to the top of the vibe-promo section
const vibePromoSection = document.getElementById('vibe-promo');
if (vibePromoSection) {
vibePromoSection.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
}
});