document.addEventListener('DOMContentLoaded', function() { // Initialize crosshair preview const crosshairPreview = document.getElementById('crosshair-preview'); function renderCrosshair() { // Clear previous crosshair crosshairPreview.innerHTML = ''; // Create crosshair elements based on current settings // This is a simplified version - actual implementation would use the settings from the form // Center dot const dot = document.createElement('div'); dot.className = 'crosshair-dot'; dot.style.width = '6px'; dot.style.height = '6px'; dot.style.backgroundColor = '#ff0000'; dot.style.borderRadius = '50%'; dot.style.position = 'absolute'; dot.style.top = '50%'; dot.style.left = '50%'; dot.style.transform = 'translate(-50%, -50%)'; crosshairPreview.appendChild(dot); // Horizontal line const horizontal = document.createElement('div'); horizontal.className = 'crosshair-line'; horizontal.style.width = '30px'; horizontal.style.height = '2px'; horizontal.style.backgroundColor = '#ff0000'; horizontal.style.position = 'absolute'; horizontal.style.top = '50%'; horizontal.style.left = '50%'; horizontal.style.transform = 'translate(-50%, -50%)'; crosshairPreview.appendChild(horizontal); // Vertical line const vertical = document.createElement('div'); vertical.className = 'crosshair-line'; vertical.style.width = '2px'; vertical.style.height = '30px'; vertical.style.backgroundColor = '#ff0000'; vertical.style.position = 'absolute'; vertical.style.top = '50%'; vertical.style.left = '50%'; vertical.style.transform = 'translate(-50%, -50%)'; crosshairPreview.appendChild(vertical); } // Initial render renderCrosshair(); // Add event listeners to form elements to update the crosshair in real-time const formInputs = document.querySelectorAll('input[type="color"], input[type="range"], input[type="checkbox"]'); formInputs.forEach(input => { input.addEventListener('input', renderCrosshair); input.addEventListener('change', renderCrosshair); }); // Simulate bloom effect when spacebar is pressed document.addEventListener('keydown', function(e) { if (e.code === 'Space') { const dot = crosshairPreview.querySelector('.crosshair-dot'); if (dot) { dot.classList.add('bloom-effect'); setTimeout(() => { dot.classList.remove('bloom-effect'); }, 300); } } }); // Crosshair library item click handler const libraryItems = document.querySelectorAll('#library .bg-gray-800'); libraryItems.forEach(item => { item.addEventListener('click', function() { // In a real app, this would load the selected crosshair settings alert('Crosshair loaded! In a real app, this would apply the selected crosshair settings.'); }); }); });