Initial AI-generated site

This commit is contained in:
2026-09-15 09:25:52 +00:00
parent e00e89a849
commit 4db9c01180
3 changed files with 1253 additions and 0 deletions
+169
View File
@@ -0,0 +1,169 @@
(function() {
'use strict';
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
// Reveal on scroll
if (!prefersReducedMotion) {
const revealElements = document.querySelectorAll('.reveal');
const revealObserver = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add('revealed');
revealObserver.unobserve(entry.target);
}
});
}, {
threshold: 0.1,
rootMargin: '0px 0px -30px 0px'
});
revealElements.forEach(el => revealObserver.observe(el));
} else {
document.querySelectorAll('.reveal').forEach(el => {
el.classList.add('revealed');
});
}
// Smooth scroll for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
const targetId = this.getAttribute('href');
if (targetId === '#') return;
const target = document.querySelector(targetId);
if (target) {
e.preventDefault();
const nav = document.querySelector('.nav');
const navHeight = nav ? nav.offsetHeight : 0;
const targetPosition = target.getBoundingClientRect().top + window.pageYOffset - navHeight;
window.scrollTo({
top: targetPosition,
behavior: prefersReducedMotion ? 'auto' : 'smooth'
});
}
});
});
// Form handling
const form = document.querySelector('.contact__form');
if (form) {
form.addEventListener('submit', function(e) {
e.preventDefault();
const formData = new FormData(form);
const data = Object.fromEntries(formData);
// Clear previous errors
clearFormErrors();
// Basic validation
let hasErrors = false;
if (!data.name || data.name.trim().length < 2) {
showFieldError('name', 'אנא הזינו שם מלא');
hasErrors = true;
}
// Phone validation (Israeli format)
const phoneRegex = /^0[0-9]{8,9}$/;
const cleanPhone = data.phone ? data.phone.replace(/[-\s]/g, '') : '';
if (!phoneRegex.test(cleanPhone)) {
showFieldError('phone', 'אנא הזינו מספר טלפון תקין');
hasErrors = true;
}
if (hasErrors) return;
// Simulate form submission
const submitBtn = form.querySelector('button[type="submit"]');
const originalText = submitBtn.textContent;
submitBtn.textContent = 'שולח...';
submitBtn.disabled = true;
setTimeout(() => {
showFormMessage('תודה! קיבלתי את הפנייה ואחזור אליכם בהקדם.', 'success');
form.reset();
submitBtn.textContent = originalText;
submitBtn.disabled = false;
}, 800);
});
}
function showFieldError(fieldId, message) {
const field = document.getElementById(fieldId);
if (!field) return;
field.style.borderColor = '#e57373';
const errorEl = document.createElement('span');
errorEl.className = 'field-error';
errorEl.textContent = message;
errorEl.style.cssText = `
display: block;
color: #e57373;
font-size: 0.8rem;
margin-top: 0.25rem;
`;
field.parentNode.appendChild(errorEl);
}
function clearFormErrors() {
const errors = form.querySelectorAll('.field-error');
errors.forEach(el => el.remove());
const inputs = form.querySelectorAll('.form-input');
inputs.forEach(input => {
input.style.borderColor = '';
});
const msg = form.querySelector('.form-message');
if (msg) msg.remove();
}
function showFormMessage(message, type) {
const existingMsg = document.querySelector('.form-message');
if (existingMsg) existingMsg.remove();
const msgEl = document.createElement('div');
msgEl.className = `form-message form-message--${type}`;
msgEl.textContent = message;
msgEl.setAttribute('role', 'alert');
msgEl.style.cssText = `
padding: 1rem;
margin-bottom: 1rem;
border-radius: 8px;
font-size: 0.9rem;
text-align: center;
background: ${type === 'success' ? 'rgba(129, 199, 132, 0.1)' : 'rgba(229, 115, 115, 0.1)'};
color: ${type === 'success' ? '#81c784' : '#e57373'};
border: 1px solid ${type === 'success' ? '#81c784' : '#e57373'};
`;
form.insertBefore(msgEl, form.firstChild);
if (type === 'success') {
setTimeout(() => {
if (msgEl.parentNode) msgEl.remove();
}, 6000);
}
}
// Nav background on scroll
const nav = document.querySelector('.nav');
if (nav) {
window.addEventListener('scroll', () => {
const currentScroll = window.pageYOffset;
if (currentScroll > 50) {
nav.style.background = 'rgba(15, 15, 15, 0.98)';
} else {
nav.style.background = 'rgba(15, 15, 15, 0.9)';
}
}, { passive: true });
}
})();