@@ -91,47 +91,70 @@ document.addEventListener('DOMContentLoaded', function() {
91
91
team . scouting_data . forEach ( entry => {
92
92
const row = document . createElement ( 'tr' ) ;
93
93
94
- // Format coral scores as L1/L2/L3/L4
94
+ const createCell = ( content ) => {
95
+ const td = document . createElement ( 'td' ) ;
96
+ td . className = 'px-6 py-4 whitespace-nowrap' ;
97
+ if ( typeof content === 'string' || typeof content === 'number' ) {
98
+ td . textContent = content ;
99
+ } else {
100
+ td . appendChild ( content ) ;
101
+ }
102
+ return td ;
103
+ } ;
104
+
105
+ // Format scores
95
106
const autoCoral = `${ entry . auto_coral_level1 } /${ entry . auto_coral_level2 } /${ entry . auto_coral_level3 } /${ entry . auto_coral_level4 } ` ;
96
107
const teleopCoral = `${ entry . teleop_coral_level1 } /${ entry . teleop_coral_level2 } /${ entry . teleop_coral_level3 } /${ entry . teleop_coral_level4 } ` ;
97
-
98
- // Format algae scores as net/processor
99
108
const autoAlgae = `${ entry . auto_algae_net } /${ entry . auto_algae_processor } ` ;
100
109
const teleopAlgae = `${ entry . teleop_algae_net } /${ entry . teleop_algae_processor } /${ entry . human_player || 0 } ` ;
101
-
102
- row . innerHTML = `
103
- <td class="px-6 py-4 whitespace-nowrap">${ entry . event_code } </td>
104
- <td class="px-6 py-4 whitespace-nowrap">${ entry . match_number } </td>
105
- <td class="px-6 py-4 whitespace-nowrap">${ autoCoral } </td>
106
- <td class="px-6 py-4 whitespace-nowrap">${ autoAlgae } </td>
107
- <td class="px-6 py-4 whitespace-nowrap">${ teleopCoral } </td>
108
- <td class="px-6 py-4 whitespace-nowrap">${ teleopAlgae } </td>
109
- <td class="px-6 py-4 whitespace-nowrap">
110
- ${ entry . climb_success ?
111
- `<span class="text-green-600">✓ ${ entry . climb_type } </span>` :
112
- `<span class="text-red-600">✗ ${ entry . climb_type || 'Failed' } </span>` }
113
- </td>
114
- <td class="px-6 py-4 whitespace-nowrap">
115
- ${ entry . auto_path ?
116
- `<button onclick="showAutoPath('${ entry . auto_path } ', '${ entry . auto_notes } ')"
117
- class="text-blue-600 hover:text-blue-900">
118
- View Path
119
- </button>` :
120
- `<span class="text-gray-400">No path</span>` }
121
- </td>
122
- <td class="px-6 py-4 whitespace-nowrap">${ entry . defense_rating } /5</td>
123
- <td class="px-6 py-4 whitespace-nowrap">${ entry . notes || '' } </td>
124
- <td class="px-6 py-4 whitespace-nowrap">${ entry . scouter_name } </td>
125
- ` ;
110
+
111
+ // Create climb status cell
112
+ const climbSpan = document . createElement ( 'span' ) ;
113
+ climbSpan . className = entry . climb_success ? 'text-green-600' : 'text-red-600' ;
114
+ climbSpan . textContent = `${ entry . climb_success ? '✓' : '✗' } ${ entry . climb_type || 'Failed' } ` ;
115
+
116
+ // Create auto path cell
117
+ const pathCell = document . createElement ( 'td' ) ;
118
+ pathCell . className = 'px-6 py-4 whitespace-nowrap' ;
119
+ if ( entry . auto_path ) {
120
+ const pathButton = document . createElement ( 'button' ) ;
121
+ pathButton . className = 'text-blue-600 hover:text-blue-900' ;
122
+ pathButton . textContent = 'View Path' ;
123
+ pathButton . addEventListener ( 'click' , ( ) => {
124
+ showAutoPath ( entry . auto_path , entry . auto_notes ) ;
125
+ } ) ;
126
+ pathCell . appendChild ( pathButton ) ;
127
+ } else {
128
+ const noPath = document . createElement ( 'span' ) ;
129
+ noPath . className = 'text-gray-400' ;
130
+ noPath . textContent = 'No path' ;
131
+ pathCell . appendChild ( noPath ) ;
132
+ }
133
+
134
+ // Add all cells to the row
135
+ row . append (
136
+ createCell ( entry . event_code ) ,
137
+ createCell ( entry . match_number ) ,
138
+ createCell ( autoCoral ) ,
139
+ createCell ( autoAlgae ) ,
140
+ createCell ( teleopCoral ) ,
141
+ createCell ( teleopAlgae ) ,
142
+ createCell ( climbSpan ) ,
143
+ pathCell ,
144
+ createCell ( `${ entry . defense_rating } /5` ) ,
145
+ createCell ( entry . notes || '' ) ,
146
+ createCell ( entry . scouter_name )
147
+ ) ;
148
+
126
149
scoutingTableBody . appendChild ( row ) ;
127
150
} ) ;
128
151
} else {
129
152
const row = document . createElement ( 'tr' ) ;
130
- row . innerHTML = `
131
- <td colspan="11" class="px-6 py-4 text-center text-gray-500">
132
- No scouting data available for this team
133
- </td>
134
- ` ;
153
+ const cell = document . createElement ( 'td' ) ;
154
+ cell . colSpan = 11 ;
155
+ cell . className = 'px-6 py-4 text-center text-gray-500' ;
156
+ cell . textContent = 'No scouting data available for this team' ;
157
+ row . appendChild ( cell ) ;
135
158
scoutingTableBody . appendChild ( row ) ;
136
159
}
137
160
0 commit comments