File size: 8,910 Bytes
786b127 |
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 230 231 232 233 234 235 236 237 238 239 240 241 |
// Exemine Minecraft Server Website JavaScript
document.addEventListener('DOMContentLoaded', function() {
// Initialize feather icons
if (typeof feather !== 'undefined') {
feather.replace();
}
// Server status check
const serverStatus = {
checkStatus: async function() {
try {
// Simulate server status check (replace with actual API call)
const response = await fetch('/api/server-status');
const data = await response.json();
this.updateStatus(data);
} catch (error) {
console.log('Server status check failed, using demo data');
// Demo data for demonstration
this.updateStatus({
online: true,
players: 24,
maxPlayers: 32,
version: '1.20.1'
});
}
},
updateStatus: function(data) {
const statusElement = document.querySelector('.text-green-400');
const playersElement = document.querySelector('.text-2xl.font-bold.text-primary-500');
const versionElement = document.querySelector('.text-lg');
if (statusElement) {
statusElement.textContent = data.online ? 'Онлайн' : 'Офлайн';
}
if (playersElement) {
playersElement.textContent = `${data.players}/${data.maxPlayers}`;
}
if (versionElement) {
versionElement.textContent = data.version;
}
}
};
// Copy server IP functionality
const copyButton = document.querySelector('button');
if (copyButton && copyButton.textContent.includes('Скопировать')) {
copyButton.addEventListener('click', function() {
const serverIP = 'exemine.mc-server.ru';
navigator.clipboard.writeText(serverIP).then(() => {
const originalText = this.textContent;
this.textContent = 'Скопировано!';
this.classList.add('bg-green-600');
this.classList.remove('bg-primary-600', 'hover:bg-primary-700');
setTimeout(() => {
this.textContent = originalText;
this.classList.remove('bg-green-600');
this.classList.add('bg-primary-600', 'hover:bg-primary-700');
}, 2000);
}).catch(() => {
// Fallback for older browsers
const textArea = document.createElement('textarea');
textArea.value = serverIP;
document.body.appendChild(textArea);
textArea.select();
document.execCommand('copy');
document.body.removeChild(textArea);
const originalText = this.textContent;
this.textContent = 'Скопировано!';
this.classList.add('bg-green-600');
this.classList.remove('bg-primary-600', 'hover:bg-primary-700');
setTimeout(() => {
this.textContent = originalText;
this.classList.remove('bg-green-600');
this.classList.add('bg-primary-600', 'hover:bg-primary-700');
}, 2000);
});
});
}
// Smooth scroll for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Navbar background on scroll
window.addEventListener('scroll', function() {
const navbar = document.querySelector('nav');
if (window.scrollY > 100) {
navbar.classList.add('bg-gray-800', 'bg-opacity-95');
navbar.classList.remove('bg-gray-800');
} else {
navbar.classList.remove('bg-opacity-95');
navbar.classList.add('bg-gray-800');
}
});
// Animate elements on scroll
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('animate-fade-in');
}
});
}, observerOptions);
// Observe elements for animation
document.querySelectorAll('.bg-gray-800, .bg-gray-900').forEach(el => {
el.classList.add('opacity-0', 'transform', 'translate-y-4', 'transition', 'duration-700');
observer.observe(el);
});
// Add CSS for fade-in animation
const style = document.createElement('style');
style.textContent = `
.animate-fade-in {
opacity: 1 !important;
transform: translateY(0) !important;
}
`;
document.head.appendChild(style);
// Player counter animation
function animateCounter(element, target) {
let current = 0;
const increment = target / 50;
const timer = setInterval(() => {
current += increment;
if (current >= target) {
current = target;
clearInterval(timer);
}
element.textContent = Math.floor(current) + '/32';
}, 30);
}
// Handle main action buttons
document.querySelectorAll('button').forEach(button => {
button.addEventListener('click', function(e) {
// Add click effect
const ripple = document.createElement('span');
ripple.classList.add('absolute', 'bg-white', 'opacity-25', 'rounded-full', 'animate-ping');
const rect = this.getBoundingClientRect();
const size = Math.max(rect.width, rect.height);
ripple.style.width = size + 'px';
ripple.style.height = size + 'px';
ripple.style.left = (e.clientX - rect.left - size / 2) + 'px';
ripple.style.top = (e.clientY - rect.top - size / 2) + 'px';
this.style.position = 'relative';
this.style.overflow = 'hidden';
this.appendChild(ripple);
setTimeout(() => {
ripple.remove();
}, 600);
});
});
// Initialize server status check
serverStatus.checkStatus();
// Add typing effect to hero text
const heroTitle = document.querySelector('h1');
if (heroTitle && heroTitle.textContent.includes('Exemine')) {
const originalText = heroTitle.textContent;
heroTitle.textContent = '';
let i = 0;
const typeWriter = () => {
if (i < originalText.length) {
heroTitle.textContent += originalText.charAt(i);
i++;
setTimeout(typeWriter, 100);
}
};
setTimeout(typeWriter, 500);
}
// Add hover effects to feature cards
document.querySelectorAll('.bg-gray-800').forEach(card => {
if (card.querySelector('h3')) {
card.classList.add('card-hover', 'cursor-pointer');
card.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-5px)';
this.style.boxShadow = '0 20px 40px rgba(0, 0, 0, 0.3)';
});
card.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0)';
this.style.boxShadow = 'none';
});
}
});
// Add mobile menu toggle (if needed)
const mobileMenuButton = document.querySelector('.md\\:hidden button');
const mobileMenu = document.querySelector('.md\\:block');
if (mobileMenuButton && mobileMenu) {
mobileMenuButton.addEventListener('click', function() {
mobileMenu.classList.toggle('hidden');
});
}
// Performance monitoring
console.log('Exemine website loaded successfully');
console.log('Features loaded:', document.querySelectorAll('.bg-gray-800').length);
});
// Service Worker registration for PWA capabilities (optional)
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('/sw.js')
.then(function(registration) {
console.log('ServiceWorker registration successful');
}, function(err) {
console.log('ServiceWorker registration failed');
});
});
} |