| document.addEventListener('DOMContentLoaded', () => { |
| |
| const mindmap = document.getElementById('mindmap'); |
| |
| if (mindmap) { |
| |
| const updateMindmapSize = () => { |
| const container = mindmap.parentElement; |
| const aspectRatio = 1200 / 700; |
| const containerWidth = container.clientWidth; |
| const containerHeight = container.clientHeight; |
| |
| let newWidth, newHeight; |
| |
| if (containerWidth / containerHeight > aspectRatio) { |
| newHeight = containerHeight; |
| newWidth = newHeight * aspectRatio; |
| } else { |
| newWidth = containerWidth; |
| newHeight = newWidth / aspectRatio; |
| } |
| |
| mindmap.style.width = `${newWidth}px`; |
| mindmap.style.height = `${newHeight}px`; |
| }; |
| |
| window.addEventListener('resize', updateMindmapSize); |
| updateMindmapSize(); |
| |
| |
| const clickableElements = mindmap.querySelectorAll('[id^="block"]'); |
| clickableElements.forEach(el => { |
| el.addEventListener('mouseenter', () => { |
| el.querySelector('rect').classList.add('stroke-orange-500'); |
| }); |
| |
| el.addEventListener('mouseleave', () => { |
| if (!el.classList.contains('active')) { |
| el.querySelector('rect').classList.remove('stroke-orange-500'); |
| } |
| }); |
| }); |
| } |
| |
| |
| tippy('[data-tippy-content]', { |
| placement: 'top', |
| theme: 'light', |
| animation: 'scale', |
| duration: 200, |
| arrow: true |
| }); |
| }); |