Spaces:
Running
Running
File size: 6,961 Bytes
ae22db8 301e48e ae22db8 301e48e ae22db8 301e48e ae22db8 301e48e ae22db8 301e48e ae22db8 301e48e ae22db8 301e48e ae22db8 301e48e ae22db8 301e48e ae22db8 301e48e ae22db8 301e48e ae22db8 301e48e ae22db8 301e48e ae22db8 | 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 |
// Modern JavaScript for Webrain IT Consulting LLC
document.addEventListener('DOMContentLoaded', function() {
console.log('Webrain IT Consulting - Modern Website Loaded');
// Initialize particles background
initParticles();
// Enhanced smooth scrolling with offset
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
const offset = 100;
const targetPosition = target.getBoundingClientRect().top + window.pageYOffset - offset;
window.scrollTo({
top: targetPosition,
behavior: 'smooth'
});
}
});
});
// Advanced Intersection Observer with staggered animations
const observerOptions = {
threshold: 0.15,
rootMargin: '0px 0px -100px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry, index) => {
if (entry.isIntersecting) {
// Stagger animation with delay based on index
setTimeout(() => {
entry.target.classList.add('animate-in');
}, index * 150);
}
});
}, observerOptions);
// Observe all sections and cards for animation
document.querySelectorAll('section, .modern-card, .gradient-border').forEach(element => {
observer.observe(element);
});
// Modern form handling with validation
const contactForm = document.querySelector('#contact form');
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
// Add modern form submission with animation
const submitBtn = contactForm.querySelector('button[type="submit"]');
const originalText = submitBtn.textContent;
// Show loading state
submitBtn.innerHTML = '<div class="loading-spinner mx-auto"></div>';
setTimeout(() => {
// Success animation
contactForm.classList.add('fade-in-scale');
alert('Thank you for your message! Our team will contact you within 24 hours.');
contactForm.reset();
submitBtn.textContent = originalText;
}, 2000);
});
}
// Add custom cursor effect
initCustomCursor();
// Add scroll progress indicator
initScrollProgress();
// Add dynamic gradient background
initDynamicBackground();
});
// Particle Background System
function initParticles() {
const container = document.getElementById('particles');
if (!container) return;
for (let i = 0; i < 50; i++) {
const particle = document.createElement('div');
particle.className = 'particle';
// Random position
const left = Math.random() * 100;
const top = Math.random() * 100;
// Random size
const size = Math.random() * 4 + 1;
// Random animation delay
const delay = Math.random() * 5;
particle.style.cssText = `
left: ${left}%;
top: ${top}%;
width: ${size}px;
height: ${size}px;
animation-delay: ${delay}s;
`;
container.appendChild(particle);
}
}
// Custom Cursor Effect
function initCustomCursor() {
const cursor = document.createElement('div');
cursor.className = 'custom-cursor';
document.body.appendChild(cursor);
document.addEventListener('mousemove', (e) => {
cursor.style.left = e.clientX + 'px';
cursor.style.top = e.clientY + 'px';
});
// Hide cursor on mouse out
document.addEventListener('mouseout', () => {
cursor.style.opacity = '0';
});
document.addEventListener('mouseover', () => {
cursor.style.opacity = '1';
});
}
// Scroll Progress Indicator
function initScrollProgress() {
const progressBar = document.createElement('div');
progressBar.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 0%;
height: 3px;
background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
z-index: 9998;
transition: width 0.1s ease;
`;
document.body.appendChild(progressBar);
window.addEventListener('scroll', () => {
const windowHeight = document.documentElement.scrollHeight - window.innerHeight;
const scrolled = (window.pageYOffset / windowHeight) * 100;
progressBar.style.width = scrolled + '%';
});
}
// Dynamic Background Gradient
function initDynamicBackground() {
const hero = document.getElementById('hero');
if (!hero) return;
let mouseX = 0;
let mouseY = 0;
document.addEventListener('mousemove', (e) => {
mouseX = e.clientX / window.innerWidth;
mouseY = e.clientY / window.innerHeight;
const gradient = `
radial-gradient(
circle at ${mouseX * 100}% ${mouseY * 100}%,
rgba(59, 130, 246, 0.3),
rgba(139, 92, 246, 0.2),
rgba(236, 72, 153, 0.1)
)
`;
hero.style.background = gradient + ', linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%)';
});
}
// Enhanced Utility Functions
function debounce(func, wait, immediate) {
let timeout;
return function executedFunction(...args) {
const later = () => {
timeout = null;
if (!immediate) func(...args);
};
const callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func(...args);
};
}
// Modern Typewriter Effect (if needed for future features)
function typewriter(element, text, speed = 50) {
let i = 0;
element.innerHTML = '';
function type() {
if (i < text.length) {
element.innerHTML += text.charAt(i);
i++;
setTimeout(type, speed);
}
}
type();
}
// Dynamic Content Loading
async function loadDynamicContent(url, containerId) {
try {
const response = await fetch(url);
const data = await response.json();
const container = document.getElementById(containerId);
if (container) {
container.innerHTML = data.map(item => `
<div class="modern-card p-6">
<h3>${item.title}</h3>
<p>${item.description}</p>
).join('');
}
} catch (error) {
console.error('Error loading dynamic content:', error);
}
}
|