Download script.js from ffcc9393/blockcraft-pro-ultimate-minecraft-hosting: direct link, hf CLI and curl.
- Browser
- Download file 4.36 kB
-
https://huggingface.co/spaces/ffcc9393/blockcraft-pro-ultimate-minecraft-hosting/resolve/main/script.js
- Command line
-
hf download hf://spaces/ffcc9393/blockcraft-pro-ultimate-minecraft-hosting/script.js
-
curl -L -o script.js https://huggingface.co/spaces/ffcc9393/blockcraft-pro-ultimate-minecraft-hosting/resolve/main/script.js
4.36 kB
| // Shared JavaScript across all pages | |
| console.log('BlockCraft Pro - Minecraft Hosting loaded'); | |
| // Initialize theme | |
| function initTheme() { | |
| if (localStorage.getItem('theme') === 'light') { | |
| document.documentElement.classList.remove('dark'); | |
| } else { | |
| document.documentElement.classList.add('dark'); | |
| } | |
| } | |
| // Smooth scrolling for anchor links | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Initialize theme | |
| initTheme(); | |
| // Smooth scroll for anchor 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' | |
| }); | |
| } | |
| }); | |
| }); | |
| // Add intersection observer for animations | |
| const observerOptions = { | |
| threshold: 0.1, | |
| rootMargin: '0px 0px -100px 0px' | |
| }; | |
| const observer = new IntersectionObserver(function(entries) { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| entry.target.classList.add('animate-in'); | |
| } | |
| }, observerOptions); | |
| // Observe all cards and features | |
| document.querySelectorAll('.card, .feature-item').forEach(item => { | |
| observer.observe(item); | |
| }); | |
| } | |
| // Price calculator functionality | |
| class PriceCalculator { | |
| constructor() { | |
| this.discountRates = { | |
| '1': 0, | |
| '3': 0.05, | |
| '12': 0.15, | |
| '24': 0.20, | |
| '36': 0.30 | |
| }; | |
| } | |
| calculatePrice(basePrice, duration) { | |
| const discount = this.discountRates[duration] || 0; | |
| const discountedPrice = basePrice * (1 - discount); | |
| return { | |
| original: basePrice, | |
| discounted: discountedPrice, | |
| savings: basePrice - discountedPrice | |
| }; | |
| } | |
| } | |
| // Initialize price calculator | |
| const priceCalculator = new PriceCalculator(); | |
| // Cookie consent management | |
| function handleCookieConsent() { | |
| const consent = localStorage.getItem('cookieConsent'); | |
| if (!consent) { | |
| // Show cookie consent banner | |
| console.log('Cookie consent needed'); | |
| } | |
| } | |
| // Form validation | |
| function validateForm(form) { | |
| const inputs = form.querySelectorAll('input[required], select[required], textarea[required]'); | |
| let isValid = true; | |
| inputs.forEach(input => { | |
| if (!input.value.trim()) { | |
| isValid = false; | |
| input.classList.add('border-red-500'); | |
| } else { | |
| input.classList.remove('border-red-500'); | |
| } | |
| }); | |
| return isValid; | |
| } | |
| // API integration for server status | |
| async function fetchServerStatus() { | |
| try { | |
| // This would be replaced with actual API endpoint | |
| const response = await fetch('/api/server-status'); | |
| const data = await response.json(); | |
| return data; | |
| } catch (error) { | |
| console.error('Failed to fetch server status:', error); | |
| return { status: 'unknown', uptime: 0 }; | |
| } | |
| } | |
| // Currency converter | |
| class CurrencyConverter { | |
| constructor() { | |
| this.rates = { | |
| 'EUR': 1, | |
| 'USD': 1.08, | |
| 'GBP': 0.85, | |
| 'PLN': 4.32 | |
| }; | |
| } | |
| convert(amount, fromCurrency, toCurrency) { | |
| const fromRate = this.rates[fromCurrency] || 1; | |
| const toRate = this.rates[toCurrency] || 1; | |
| return (amount / fromRate) * toRate; | |
| } | |
| } | |
| // Initialize currency converter | |
| const currencyConverter = new CurrencyConverter(); | |
| // Performance monitoring | |
| function monitorPerformance() { | |
| if ('performance' in window) { | |
| const navigationTiming = performance.getEntriesByType('navigation')[0]; | |
| console.log('Page load time:', navigationTiming.loadEventEnd - navigationTiming.navigationStart); | |
| } | |
| // Export functions for use in other modules | |
| window.BlockCraftPro = { | |
| initTheme, | |
| priceCalculator, | |
| currencyConverter, | |
| validateForm, | |
| fetchServerStatus, | |
| monitorPerformance | |
| }; | |
| // Initialize when DOM is ready | |
| if (document.readyState === 'loading') { | |
| document.addEventListener('DOMContentLoaded', initTheme); | |
| } else { | |
| initTheme(); | |
| } |