11/**
22 * Main entry point for the C# Code Graph Visualizer
3- * This file loads all the required modules in the correct order
3+ * This file loads all the required modules and contains all shared variables
44 */
55
66// Global graph data
@@ -25,100 +25,39 @@ let zoomBehavior;
2525let simulation ;
2626let currentLayout = 'force' ;
2727
28- // Load the visualization modules sequentially with dynamic imports
29- document . addEventListener ( 'DOMContentLoaded' , async function ( ) {
30- // Add dynamic script loading function
31- function loadScript ( src ) {
32- return new Promise ( ( resolve , reject ) => {
33- const script = document . createElement ( 'script' ) ;
34- script . src = src ;
35- script . onload = resolve ;
36- script . onerror = reject ;
37- document . body . appendChild ( script ) ;
38- } ) ;
39- }
28+ // State tracking
29+ let selectedNode = null ;
30+ let highlightedNode = null ;
4031
41- try {
42- console . log ( 'C# Code Graph Visualizer starting...' ) ;
43-
44- // Initialize UI references
45- chartContainer = document . getElementById ( 'chart' ) ;
46- detailPanel = document . getElementById ( 'detail-panel' ) ;
47- loadingOverlay = document . getElementById ( 'loading-overlay' ) ;
48- tooltip = document . getElementById ( 'tooltip' ) ;
49- filterContainer = document . getElementById ( 'filters-container' ) ;
50-
51- // Show loading overlay
52- if ( loadingOverlay ) {
53- console . log ( 'Showing loading overlay' ) ;
54- loadingOverlay . style . display = 'flex' ;
55- } else {
56- console . error ( 'Loading overlay element not found!' ) ;
57- }
58-
59- // Load modules in the required order
60- console . log ( 'Loading visualization modules...' ) ;
61- await loadScript ( 'visualizer-data.js' ) ;
62- await loadScript ( 'visualizer-styles.js' ) ;
63- await loadScript ( 'visualizer-filters.js' ) ;
64- await loadScript ( 'visualizer-ui.js' ) ;
65- await loadScript ( 'visualizer-core.js' ) ;
66-
67- console . log ( 'All visualization modules loaded successfully' ) ;
68-
69- // Initialize the visualization manually since modules are loaded dynamically
70- setTimeout ( ( ) => initVisualization ( ) , 100 ) ;
71- } catch ( error ) {
72- console . error ( 'Error loading visualization modules:' , error ) ;
73-
74- // Hide loading overlay on error
75- if ( loadingOverlay ) {
76- loadingOverlay . style . display = 'none' ;
77- }
78-
79- // Show error to user
80- alert ( 'Failed to load visualization: ' + error . message ) ;
32+ // Initialize when the document is loaded
33+ document . addEventListener ( 'DOMContentLoaded' , function ( ) {
34+ console . log ( 'C# Code Graph Visualizer starting...' ) ;
35+
36+ // Initialize UI references
37+ chartContainer = document . getElementById ( 'chart' ) ;
38+ detailPanel = document . getElementById ( 'detail-panel' ) ;
39+ loadingOverlay = document . getElementById ( 'loading-overlay' ) ;
40+ tooltip = document . getElementById ( 'tooltip' ) ;
41+ filterContainer = document . getElementById ( 'filters-container' ) ;
42+
43+ // Show loading overlay
44+ if ( loadingOverlay ) {
45+ console . log ( 'Showing loading overlay' ) ;
46+ loadingOverlay . style . display = 'flex' ;
8147 }
82- } ) ;
83-
84- /**
85- * Initialize the visualization
86- */
87- async function initVisualization ( ) {
88- try {
89- console . log ( 'Initializing visualization...' ) ;
90-
91- // Load data
92- await loadGraph ( ) ;
93-
94- // Setup visualization components
95- setupVisualization ( ) ;
96-
97- // Initialize filters
98- initializeFilters ( ) ;
99-
100- // Add custom styles
101- addStyles ( ) ;
102-
103- // Setup event listeners for layout controls
104- document . getElementById ( 'force-layout' ) . addEventListener ( 'click' , switchToForceDirectedLayout ) ;
105- document . getElementById ( 'hierarchical-layout' ) . addEventListener ( 'click' , switchToHierarchicalLayout ) ;
106- document . getElementById ( 'reset-zoom' ) . addEventListener ( 'click' , resetZoom ) ;
107- document . getElementById ( 'reset-filters' ) . addEventListener ( 'click' , resetAllFilters ) ;
108-
109- // Hide loading overlay when complete
48+
49+ // Load the original visualizer script
50+ const script = document . createElement ( 'script' ) ;
51+ script . src = 'enhanced_visualizer.js' ;
52+ script . onload = function ( ) {
53+ console . log ( 'Visualization loaded successfully' ) ;
54+ } ;
55+ script . onerror = function ( error ) {
56+ console . error ( 'Error loading visualization:' , error ) ;
11057 if ( loadingOverlay ) {
11158 loadingOverlay . style . display = 'none' ;
112- console . log ( 'Visualization initialized successfully!' ) ;
11359 }
114- } catch ( error ) {
115- console . error ( 'Error initializing visualization:' , error ) ;
116-
117- // Hide loading overlay on error
118- if ( loadingOverlay ) {
119- loadingOverlay . style . display = 'none' ;
120- }
121-
122- alert ( 'Failed to initialize visualization: ' + error . message ) ;
123- }
124- }
60+ alert ( 'Failed to load visualization: ' + error ) ;
61+ } ;
62+ document . body . appendChild ( script ) ;
63+ } ) ;
0 commit comments