Remy88/vulnvigil-exploit-watchtower
0
1// Main application script for VulnVigil2document.addEventListener('DOMContentLoaded', function() {3 // Initialize tooltips for all elements with data-tooltip attribute4 const tooltipTriggers = document.querySelectorAll('[data-tooltip]');5 6 tooltipTriggers.forEach(trigger => {7 trigger.addEventListener('mouseenter', showTooltip);8 trigger.addEventListener('mouseleave', hideTooltip);9 });10 11 // Function to show tooltip12 function showTooltip(event) {13 const tooltipText = this.getAttribute('data-tooltip');14 const tooltip = document.createElement('div');15 tooltip.className = 'absolute z-10 bg-gray-800 text-white text-xs rounded py-1 px-2 whitespace-nowrap';16 tooltip.textContent = tooltipText;17 18 const rect = this.getBoundingClientRect();19 tooltip.style.top = `${rect.bottom + window.scrollY}px`;20 tooltip.style.left = `${rect.left + rect.width / 2}px`;21 tooltip.style.transform = 'translateX(-50%)';22 23 this.appendChild(tooltip);24 25 // Remove tooltip after a delay if mouse stays over26 this.tooltipTimeout = setTimeout(() => {27 if (this.contains(tooltip)) {28 this.removeChild(tooltip);29 }30 }, 3000);31 }32 33 // Function to hide tooltip34 function hideTooltip() {35 clearTimeout(this.tooltipTimeout);36 const tooltip = this.querySelector('.bg-gray-800');37 if (tooltip) {38 this.removeChild(tooltip);39 }40 }41 42 // Search functionality (would be connected to API in production)43 const searchInput = document.querySelector('input[type="text"]');44 if (searchInput) {45 searchInput.addEventListener('input', debounce(searchVulnerabilities, 300));46 }47 48 function searchVulnerabilities() {49 const searchTerm = this.value.toLowerCase();50 console.log(`Searching for: ${searchTerm}`);51 // In a real implementation, this would filter or fetch search results52 }53 54 // Simple debounce function55 function debounce(func, wait) {56 let timeout;57 return function() {58 const context = this;59 const args = arguments;60 clearTimeout(timeout);61 timeout = setTimeout(() => {62 func.apply(context, args);63 }, wait);64 };65 }66});