File size: 3,231 Bytes
b989a2e | 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 | 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.');
});
});
}); |