-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinteractive.js
More file actions
34 lines (28 loc) · 1.19 KB
/
Copy pathinteractive.js
File metadata and controls
34 lines (28 loc) · 1.19 KB
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
document.addEventListener('DOMContentLoaded', () => {
const svgObject = document.getElementById('architecture-svg');
svgObject.addEventListener('load', () => {
const svgDoc = svgObject.contentDocument;
if (!svgDoc) {
console.error("Could not access SVG document. Make sure it's from the same origin.");
return;
}
const components = document.querySelectorAll('.component');
components.forEach(component => {
const componentId = component.dataset.componentId;
// Mermaid.js generates IDs like `A-codegraph-core`
const node = svgDoc.querySelector(`[id^="${componentId}-"]`);
if (node) {
component.addEventListener('mouseover', () => {
node.classList.add('highlight');
});
component.addEventListener('mouseout', () => {
node.classList.remove('highlight');
});
}
});
});
// Handle case where SVG fails to load
svgObject.addEventListener('error', () => {
console.error('SVG file could not be loaded. Please ensure architecture.svg exists.');
});
});