ghostchat / script.js
sohaibajaj's picture
اريد برنامج دردشة بي شكل عصري واستخدام مميز وبدون تسجيل
fefe669 verified
// Invite code validation
function validateInviteCode(code) {
// This is a placeholder - in a real app, you'd validate against a database
return code.length === 6 && /^[A-Z0-9]+$/.test(code);
}
// Phone number validation for Saudi numbers
function validateSaudiPhoneNumber(phone) {
return /^05\d{8}$/.test(phone);
}
// Password strength validation
function validatePasswordStrength(password) {
return password.length >= 8 && /[A-Z]/.test(password) && /[0-9]/.test(password);
}
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Generate random username
function generateUsername() {
const adjectives = ['شبح', 'سري', 'مجهول', 'خفيف', 'ظل', 'ليل', 'غامض'];
const nouns = ['محارب', 'قناص', 'شخص', 'زائر', 'مستكشف', 'راوي'];
return `${adjectives[Math.floor(Math.random() * adjectives.length)]}-${nouns[Math.floor(Math.random() * nouns.length)]}`;
}
// Animation on scroll
const animateOnScroll = () => {
const elements = document.querySelectorAll('.feature-card, .testimonial');
elements.forEach(element => {
const elementPosition = element.getBoundingClientRect().top;
const screenPosition = window.innerHeight / 1.3;
if (elementPosition < screenPosition) {
element.style.opacity = '1';
element.style.transform = 'translateY(0)';
}
});
};
// Set initial state for animation
document.querySelectorAll('.feature-card, .testimonial').forEach(element => {
element.style.opacity = '0';
element.style.transform = 'translateY(20px)';
element.style.transition = 'all 0.5s ease';
});
window.addEventListener('scroll', animateOnScroll);
window.addEventListener('load', animateOnScroll);