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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Year in footer
|
| 2 |
+
document.getElementById('year').textContent = new Date().getFullYear();
|
| 3 |
+
|
| 4 |
+
// 3D Tilt Card
|
| 5 |
+
const tiltCard = document.getElementById('tiltCard');
|
| 6 |
+
if (tiltCard) {
|
| 7 |
+
let isHovering = false;
|
| 8 |
+
|
| 9 |
+
tiltCard.addEventListener('mouseenter', () => {
|
| 10 |
+
isHovering = true;
|
| 11 |
+
});
|
| 12 |
+
|
| 13 |
+
tiltCard.addEventListener('mouseleave', () => {
|
| 14 |
+
isHovering = false;
|
| 15 |
+
tiltCard.style.transform = 'perspective(800px) rotateX(0deg) rotateY(0deg)';
|
| 16 |
+
});
|
| 17 |
+
|
| 18 |
+
tiltCard.addEventListener('mousemove', (e) => {
|
| 19 |
+
if (!isHovering) return;
|
| 20 |
+
|
| 21 |
+
const rect = tiltCard.getBoundingClientRect();
|
| 22 |
+
const x = e.clientX - rect.left;
|
| 23 |
+
const y = e.clientY - rect.top;
|
| 24 |
+
|
| 25 |
+
const centerX = rect.width / 2;
|
| 26 |
+
const centerY = rect.height / 2;
|
| 27 |
+
|
| 28 |
+
const rotateX = (y - centerY) / 10;
|
| 29 |
+
const rotateY = (centerX - x) / 10;
|
| 30 |
+
|
| 31 |
+
tiltCard.style.transform = `perspective(800px) rotateX(${rotateX}deg) rotateY(${rotateY}deg)`;
|
| 32 |
+
|
| 33 |
+
// Update CSS custom properties for the gradient effect
|
| 34 |
+
const xPercent = (x / rect.width) * 100;
|
| 35 |
+
const yPercent = (y / rect.height) * 100;
|
| 36 |
+
tiltCard.style.setProperty('--mx', `${xPercent}%`);
|
| 37 |
+
tiltCard.style.setProperty('--my', `${yPercent}%`);
|
| 38 |
+
});
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
// Magnetic Button Effect
|
| 42 |
+
const magneticButtons = document.querySelectorAll('.magnetic-button');
|
| 43 |
+
magneticButtons.forEach(button => {
|
| 44 |
+
let mousePosition = { x: 0, y: 0 };
|
| 45 |
+
let buttonPosition = { x: 0, y: 0 };
|
| 46 |
+
|
| 47 |
+
button.addEventListener('mousemove', (e) => {
|
| 48 |
+
const rect = button.getBoundingClientRect();
|
| 49 |
+
mousePosition = { x: e.clientX - rect.left, y: e.clientY - rect.top };
|
| 50 |
+
|
| 51 |
+
// Calculate distance from center
|
| 52 |
+
const centerX = rect.width / 2;
|
| 53 |
+
const centerY = rect.height / 2;
|
| 54 |
+
const deltaX = (mousePosition.x - centerX) * 0.3;
|
| 55 |
+
const deltaY = (mousePosition.y - centerY) * 0.3;
|
| 56 |
+
|
| 57 |
+
button.style.transform = `translate(${deltaX}px, ${deltaY}px)`;
|
| 58 |
+
});
|
| 59 |
+
|
| 60 |
+
button.addEventListener('mouseleave', () => {
|
| 61 |
+
button.style.transform = 'translate(0px, 0px)';
|
| 62 |
+
});
|
| 63 |
+
});
|
| 64 |
+
|
| 65 |
+
// Ripple Effect
|
| 66 |
+
const rippleButtons = document.querySelectorAll('.ripple-button');
|
| 67 |
+
rippleButtons.forEach(button => {
|
| 68 |
+
button.addEventListener('click', function(e) {
|
| 69 |
+
// Remove existing ripple
|
| 70 |
+
const existingRipple = this.querySelector('.ripple');
|
| 71 |
+
if (existingRipple) {
|
| 72 |
+
existingRipple.remove();
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
// Create new ripple
|
| 76 |
+
const ripple = document.createElement('span');
|
| 77 |
+
ripple.classList.add('ripple');
|
| 78 |
+
this.appendChild(ripple);
|
| 79 |
+
|
| 80 |
+
// Position the ripple
|
| 81 |
+
const rect = this.getBoundingClientRect();
|
| 82 |
+
const x = e.clientX - rect.left;
|
| 83 |
+
const y = e.clientY - rect.top;
|
| 84 |
+
|
| 85 |
+
ripple.style.setProperty('--x', `${x}px`);
|
| 86 |
+
ripple.style.setProperty('--y', `${y}px`);
|
| 87 |
+
|
| 88 |
+
// Remove ripple after animation
|
| 89 |
+
setTimeout(() => {
|
| 90 |
+
ripple.remove();
|
| 91 |
+
}, 800);
|
| 92 |
+
});
|
| 93 |
+
});
|
| 94 |
+
|
| 95 |
+
// Activity Ring Progress
|
| 96 |
+
const ringInput = document.getElementById('ringInput');
|
| 97 |
+
const ringProgress = document.getElementById('ringProgress');
|
| 98 |
+
const ringPercent = document.getElementById('ringPercent');
|
| 99 |
+
|
| 100 |
+
if (ringInput && ringProgress) {
|
| 101 |
+
const updateRing = (value) => {
|
| 102 |
+
const num = Math.max(0, Math.min(100, parseInt(value) || 0));
|
| 103 |
+
ringProgress.style.setProperty('--progress', num);
|
| 104 |
+
ringPercent.textContent = `${num}%`;
|
| 105 |
+
};
|
| 106 |
+
|
| 107 |
+
ringInput.addEventListener('input', (e) => {
|
| 108 |
+
const value = e.target.value;
|
| 109 |
+
if (value === '' || /^\d+$/.test(value)) {
|
| 110 |
+
updateRing(value);
|
| 111 |
+
}
|
| 112 |
+
});
|
| 113 |
+
|
| 114 |
+
// Handle Enter key
|
| 115 |
+
ringInput.addEventListener('keypress', (e) => {
|
| 116 |
+
if (e.key === 'Enter') {
|
| 117 |
+
e.preventDefault();
|
| 118 |
+
updateRing(ringInput.value);
|
| 119 |
+
}
|
| 120 |
+
});
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
// Ring Reset Button
|
| 124 |
+
const ringReset = document.getElementById('ringReset');
|
| 125 |
+
if (ringReset && ringInput) {
|
| 126 |
+
ringReset.addEventListener('click', () => {
|
| 127 |
+
ringInput.value = '';
|
| 128 |
+
if (ringProgress) {
|
| 129 |
+
ringProgress.style.setProperty('--progress', 0);
|
| 130 |
+
}
|
| 131 |
+
if (ringPercent) {
|
| 132 |
+
ringPercent.textContent = '0%';
|
| 133 |
+
}
|
| 134 |
+
ringInput.focus();
|
| 135 |
+
});
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
// Magnetic Button in Header
|
| 139 |
+
const magneticBtn = document.getElementById('magneticBtn');
|
| 140 |
+
if (magneticBtn) {
|
| 141 |
+
magneticBtn.addEventListener('click', () => {
|
| 142 |
+
// Smooth scroll to demo section
|
| 143 |
+
const demoSection = document.getElementById('demo');
|
| 144 |
+
if (demoSection) {
|
| 145 |
+
demoSection.scrollIntoView({ behavior: 'smooth' });
|
| 146 |
+
}
|
| 147 |
+
});
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
// Form Progress and Validation
|
| 151 |
+
const form = document.getElementById('notifyForm');
|
| 152 |
+
const nameInput = document.getElementById('name');
|
| 153 |
+
const emailInput = document.getElementById('email');
|
| 154 |
+
const messageInput = document.getElementById('message');
|
| 155 |
+
const formProgress = document.getElementById('formProgress');
|
| 156 |
+
const charCount = document.getElementById('charCount');
|
| 157 |
+
|
| 158 |
+
if (form && nameInput && emailInput) {
|
| 159 |
+
const updateFormProgress = () => {
|
| 160 |
+
let progress = 0;
|
| 161 |
+
const maxLength = 200;
|
| 162 |
+
|
| 163 |
+
// Name progress (0-33%)
|
| 164 |
+
if (nameInput.value.trim().length > 0) progress += 33;
|
| 165 |
+
|
| 166 |
+
// Email progress (33-66%)
|
| 167 |
+
if (emailInput.value.trim().length > 0) {
|
| 168 |
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
| 169 |
+
if (emailRegex.test(emailInput.value)) {
|
| 170 |
+
progress += 33;
|
| 171 |
+
} else {
|
| 172 |
+
progress += 16; // Partial progress for invalid email
|
| 173 |
+
}
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
// Message progress (66-100%)
|
| 177 |
+
if (messageInput && messageInput.value.trim().length > 0) {
|
| 178 |
+
const messageProgress = Math.min(34, (messageInput.value.length / maxLength) * 34);
|
| 179 |
+
progress += messageProgress;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
// Update progress bar
|
| 183 |
+
if (formProgress) {
|
| 184 |
+
formProgress.style.width = `${Math.round(progress)}%`;
|
| 185 |
+
formProgress.nextElementSibling.textContent = `${Math.round(progress)}%`;
|
| 186 |
+
}
|
| 187 |
+
};
|
| 188 |
+
|
| 189 |
+
// Character count for message
|
| 190 |
+
if (messageInput && charCount) {
|
| 191 |
+
messageInput.addEventListener('input', () => {
|
| 192 |
+
const length = messageInput.value.length;
|
| 193 |
+
charCount.textContent = `${length} / 200`;
|
| 194 |
+
|
| 195 |
+
if (length > 200) {
|
| 196 |
+
messageInput.value = messageInput.value.substring(0, 200);
|
| 197 |
+
charCount.textContent = `200 / 200`;
|
| 198 |
+
}
|
| 199 |
+
});
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
// Update progress on input
|
| 203 |
+
[nameInput, emailInput, messageInput].forEach(input => {
|
| 204 |
+
if (input) {
|
| 205 |
+
input.addEventListener('input', updateFormProgress);
|
| 206 |
+
}
|
| 207 |
+
});
|
| 208 |
+
|
| 209 |
+
// Form submission
|
| 210 |
+
form.addEventListener('submit', (e) => {
|
| 211 |
+
e.preventDefault();
|
| 212 |
+
|
| 213 |
+
const name = nameInput.value.trim();
|
| 214 |
+
const email = emailInput.value.trim();
|
| 215 |
+
const message = messageInput ? messageInput.value.trim() : '';
|
| 216 |
+
|
| 217 |
+
// Basic validation
|
| 218 |
+
if (!name) {
|
| 219 |
+
alert('Please enter your name');
|
| 220 |
+
nameInput.focus();
|
| 221 |
+
return;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
if (!email) {
|
| 225 |
+
alert('Please enter your email');
|
| 226 |
+
emailInput.focus();
|
| 227 |
+
return;
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
| 231 |
+
if (!emailRegex.test(email)) {
|
| 232 |
+
alert('Please enter a valid email address');
|
| 233 |
+
emailInput.focus();
|
| 234 |
+
return;
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
// Simulate form submission
|
| 238 |
+
const submitBtn = form.querySelector('button[type="submit"]');
|
| 239 |
+
const originalText = submitBtn.textContent;
|
| 240 |
+
|
| 241 |
+
submitBtn.textContent = 'Submitting...';
|
| 242 |
+
submitBtn.disabled = true;
|
| 243 |
+
|
| 244 |
+
setTimeout(() => {
|
| 245 |
+
alert('Thank you! We\'ll keep you updated.');
|
| 246 |
+
form.reset();
|
| 247 |
+
if (formProgress) {
|
| 248 |
+
formProgress.style.width = '0%';
|
| 249 |
+
formProgress.nextElementSibling.textContent = '0%';
|
| 250 |
+
}
|
| 251 |
+
if (charCount) {
|
| 252 |
+
charCount.textContent = '0 / 200';
|
| 253 |
+
}
|
| 254 |
+
submitBtn.textContent = originalText;
|
| 255 |
+
submitBtn.disabled = false;
|
| 256 |
+
}, 1500);
|
| 257 |
+
});
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
// Initialize progress on page load
|
| 261 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 262 |
+
updateFormProgress();
|
| 263 |
+
|
| 264 |
+
// Smooth scrolling for anchor links
|
| 265 |
+
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
|
| 266 |
+
anchor.addEventListener('click', function (e) {
|
| 267 |
+
e.preventDefault();
|
| 268 |
+
const target = document.querySelector(this.getAttribute('href'));
|
| 269 |
+
if (target) {
|
| 270 |
+
target.scrollIntoView({
|
| 271 |
+
behavior: 'smooth',
|
| 272 |
+
block: 'start'
|
| 273 |
+
});
|
| 274 |
+
}
|
| 275 |
+
});
|
| 276 |
+
});
|
| 277 |
+
});
|
| 278 |
+
|
| 279 |
+
// Add some additional interactive touches
|
| 280 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 281 |
+
// Add loading animation to tilt card
|
| 282 |
+
const tiltCard = document.getElementById('tiltCard');
|
| 283 |
+
if (tiltCard) {
|
| 284 |
+
setTimeout(() => {
|
| 285 |
+
tiltCard.style.opacity = '1';
|
| 286 |
+
tiltCard.style.transform = 'perspective(800px) translateY(0px)';
|
| 287 |
+
}, 100);
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
// Add entrance animation to other elements
|
| 291 |
+
const animatedElements = document.querySelectorAll('.rounded-2xl');
|
| 292 |
+
animatedElements.forEach((el, index) => {
|
| 293 |
+
el.style.opacity = '0';
|
| 294 |
+
el.style.transform = 'translateY(20px)';
|
| 295 |
+
el.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
|
| 296 |
+
|
| 297 |
+
setTimeout(() => {
|
| 298 |
+
el.style.opacity = '1';
|
| 299 |
+
el.style.transform = 'translateY(0px)';
|
| 300 |
+
}, 200 + (index * 100));
|
| 301 |
+
});
|
| 302 |
+
});
|