// Casibom 907 Website JavaScript
document.addEventListener('DOMContentLoaded', function() {
// Smooth scrolling for navigation links
const navLinks = document.querySelectorAll('nav a[href^="#"]');
navLinks.forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetSection = document.querySelector(targetId);
if (targetSection) {
targetSection.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Header scroll effect
const header = document.querySelector('.header');
let lastScrollTop = 0;
window.addEventListener('scroll', function() {
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
if (scrollTop > lastScrollTop && scrollTop > 100) {
// Scrolling down
header.style.transform = 'translateY(-100%)';
} else {
// Scrolling up
header.style.transform = 'translateY(0)';
}
lastScrollTop = scrollTop;
});
// Add fade-in animation to elements
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('fade-in-up');
}
});
}, observerOptions);
// Observe elements for animation
const animateElements = document.querySelectorAll('.feature-card, .game-card, .hero-content, .hero-image');
animateElements.forEach(el => {
observer.observe(el);
});
// Form validation for login/register forms
const forms = document.querySelectorAll('form');
forms.forEach(form => {
form.addEventListener('submit', function(e) {
e.preventDefault();
const formData = new FormData(form);
const data = Object.fromEntries(formData);
// Basic validation
if (validateForm(data)) {
showLoading(form);
// Simulate form submission
setTimeout(() => {
hideLoading(form);
showSuccess('İşlem başarıyla tamamlandı!');
}, 2000);
}
});
});
// Loading animation functions
function showLoading(form) {
const submitBtn = form.querySelector('button[type="submit"]');
if (submitBtn) {
submitBtn.innerHTML = ' Gönderiliyor...';
submitBtn.disabled = true;
}
}
function hideLoading(form) {
const submitBtn = form.querySelector('button[type="submit"]');
if (submitBtn) {
submitBtn.innerHTML = 'Gönder';
submitBtn.disabled = false;
}
}
// Form validation
function validateForm(data) {
let isValid = true;
if (data.email && !isValidEmail(data.email)) {
showError('Geçerli bir e-posta adresi giriniz.');
isValid = false;
}
if (data.password && data.password.length < 6) {
showError('Şifre en az 6 karakter olmalıdır.');
isValid = false;
}
return isValid;
}
// Email validation
function isValidEmail(email) {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return emailRegex.test(email);
}
// Notification functions
function showSuccess(message) {
showNotification(message, 'success');
}
function showError(message) {
showNotification(message, 'error');
}
function showNotification(message, type) {
const notification = document.createElement('div');
notification.className = `notification notification-${type}`;
notification.innerHTML = `
${message}
`;
document.body.appendChild(notification);
// Auto remove after 5 seconds
setTimeout(() => {
notification.remove();
}, 5000);
// Close button functionality
const closeBtn = notification.querySelector('.notification-close');
closeBtn.addEventListener('click', () => {
notification.remove();
});
}
// Add notification styles
const notificationStyles = `
.notification {
position: fixed;
top: 20px;
right: 20px;
z-index: 10000;
max-width: 400px;
animation: slideInRight 0.3s ease-out;
}
.notification-content {
background: white;
border-radius: 8px;
padding: 15px 20px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
display: flex;
align-items: center;
justify-content: space-between;
}
.notification-success {
border-left: 4px solid #27ae60;
}
.notification-error {
border-left: 4px solid #e74c3c;
}
.notification-message {
color: #333;
font-weight: 500;
}
.notification-close {
background: none;
border: none;
font-size: 20px;
cursor: pointer;
color: #999;
margin-left: 15px;
}
.notification-close:hover {
color: #333;
}
@keyframes slideInRight {
from {
transform: translateX(100%);
opacity: 0;
}
to {
transform: translateX(0);
opacity: 1;
}
}
`;
const styleSheet = document.createElement('style');
styleSheet.textContent = notificationStyles;
document.head.appendChild(styleSheet);
// Lazy loading for images
const images = document.querySelectorAll('img[data-src]');
const imageObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const img = entry.target;
img.src = img.dataset.src;
img.classList.remove('lazy');
imageObserver.unobserve(img);
}
});
});
images.forEach(img => {
imageObserver.observe(img);
});
// Mobile menu toggle
const mobileMenuBtn = document.querySelector('.mobile-menu-btn');
const nav = document.querySelector('.nav');
if (mobileMenuBtn) {
mobileMenuBtn.addEventListener('click', function() {
nav.classList.toggle('nav-open');
this.classList.toggle('active');
});
}
// Search functionality
const searchForm = document.querySelector('.search-form');
if (searchForm) {
searchForm.addEventListener('submit', function(e) {
e.preventDefault();
const searchInput = this.querySelector('input[type="search"]');
const query = searchInput.value.trim();
if (query) {
// Simulate search
console.log('Searching for:', query);
showSuccess(`"${query}" için arama yapılıyor...`);
}
});
}
// Game card hover effects
const gameCards = document.querySelectorAll('.game-card');
gameCards.forEach(card => {
card.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-10px) scale(1.02)';
});
card.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0) scale(1)';
});
});
// Counter animation for statistics
const counters = document.querySelectorAll('.counter');
const counterObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const counter = entry.target;
const target = parseInt(counter.getAttribute('data-target'));
const duration = 2000; // 2 seconds
const increment = target / (duration / 16); // 60fps
let current = 0;
const updateCounter = () => {
current += increment;
if (current < target) {
counter.textContent = Math.floor(current);
requestAnimationFrame(updateCounter);
} else {
counter.textContent = target;
}
};
updateCounter();
counterObserver.unobserve(counter);
}
});
});
counters.forEach(counter => {
counterObserver.observe(counter);
});
// Smooth reveal for sections
const sections = document.querySelectorAll('section');
const sectionObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, { threshold: 0.1 });
sections.forEach(section => {
section.style.opacity = '0';
section.style.transform = 'translateY(30px)';
section.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
sectionObserver.observe(section);
});
// Console welcome message
console.log(`
🎰 Casibom 907 - Güvenilir Online Casino ve Bahis Sitesi 🎰
Hoş geldiniz! Bu site SEO odaklı olarak tasarlanmıştır.
Özellikler:
✅ Responsive tasarım
✅ SEO optimizasyonu
✅ Rich snippets
✅ AMP desteği
✅ Modern UI/UX
İyi eğlenceler! 🎲
`);
});
// Performance optimization: Debounce function
function debounce(func, wait) {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
// Throttle function for scroll events
function throttle(func, limit) {
let inThrottle;
return function() {
const args = arguments;
const context = this;
if (!inThrottle) {
func.apply(context, args);
inThrottle = true;
setTimeout(() => inThrottle = false, limit);
}
};
}