document.addEventListener('DOMContentLoaded', function() { // Create nodes and edges for the brain map const nodes = new vis.DataSet([ { id: 1, label: 'Persona', color: '#0ea5e9', shape: 'box', value: 30 }, { id: 2, label: 'Dialogue', color: '#0ea5e9', value: 25 }, { id: 3, label: 'Memory', color: '#8b5cf6', value: 40 }, { id: 4, label: 'Knowledge', color: '#0ea5e9', value: 35 }, { id: 5, label: 'Emotion', color: '#22c55e', value: 20 }, { id: 6, label: 'Safety', color: '#22c55e', value: 20 }, { id: 7, label: 'Profiling', color: '#22c55e', value: 15 } ]); const edges = new vis.DataSet([ { from: 1, to: 2, arrows: 'to', color: { color: '#64748b' } }, { from: 2, to: 3, arrows: 'to', color: { color: '#64748b' } }, { from: 3, to: 4, arrows: 'to', color: { color: '#64748b' } }, { from: 4, to: 1, arrows: 'to', color: { color: '#10b981' }, dashes: true }, { from: 5, to: 2, arrows: 'to', color: { color: '#3b82f6' }, dashes: true }, { from: 6, to: 2, arrows: 'to', color: { color: '#3b82f6' }, dashes: true }, { from: 7, to: 1, arrows: 'to', color: { color: '#64748b' } } ]); // Create the network const container = document.getElementById('brainMapContainer'); const data = { nodes: nodes, edges: edges }; const options = { nodes: { shape: 'dot', size: 30, font: { size: 14, color: '#1f2937' }, borderWidth: 2, shadow: true }, edges: { width: 2, shadow: true, smooth: { type: 'continuous' } }, physics: { stabilization: { enabled: true, iterations: 1000 }, barnesHut: { gravitationalConstant: -2000, centralGravity: 0.3, springLength: 200 } }, layout: { improvedLayout: true } }; const network = new vis.Network(container, data, options); // Handle node selection network.on('selectNode', function(params) { const nodeId = params.nodes[0]; const node = nodes.get(nodeId); const details = `
Module ID: ${node.id}
Status: Active
Connections: ${edges.get().filter(e => e.from === nodeId || e.to === nodeId).length}
`; document.getElementById('nodeDetails').innerHTML = details; }); // Center and stabilize network network.once('stabilizationIterationsDone', function() { network.fit({ animation: { duration: 1000, easingFunction: 'easeInOutQuad' } }); }); });