11document . addEventListener ( "DOMContentLoaded" , ( ) => {
2- loadCompanyNames ( ) ; // Load company names when the page loads
2+ // loadCompanyNames(); // Load company names when the page loads
3+ loadCompanyNames ( ) ;
4+ bindTabEvents ( ) ;
35} ) ;
46
57let companyInfo = { } ; // To store parsed company_info.json
8+ let selectedRow = null ; // To track the currently selected row
69
7- async function openTab ( tabName , headerText ) {
10+ function bindTabEvents ( ) {
11+ const companyTab = document . getElementById ( 'companyQuestionsTab' ) ;
12+ const interviewTab = document . getElementById ( 'interviewQuestionsTab' ) ;
13+
14+ companyTab . addEventListener ( 'click' , ( ) => openTab ( 'companyQuestions' , 'Filtered by Company' , companyTab ) ) ;
15+ interviewTab . addEventListener ( 'click' , ( ) => openTab ( 'companyTable' , 'Filtered by Problems' , interviewTab ) ) ;
16+ }
17+
18+ async function openTab ( tabName , headerText , tabElement ) {
819 document . getElementById ( 'companyInfoHeaderText' ) . innerText = headerText ;
920
1021 const contents = document . getElementsByClassName ( 'tab-content' ) ;
@@ -18,13 +29,13 @@ async function openTab(tabName, headerText) {
1829 }
1930
2031 document . getElementById ( tabName ) . classList . add ( 'active' ) ;
21- event . target . classList . add ( 'active' ) ;
32+ tabElement . classList . add ( 'active' ) ;
2233
2334 // Check if company names are already loaded
24- const tbody = document . getElementById ( 'companyNameTable' ) . querySelector ( 'tbody' ) ;
35+ /* const tbody = document.getElementById('companyNameTable').querySelector('tbody');
2536 if (tabName === 'companyQuestions' && tbody.children.length === 0) {
2637 await loadCompanyNames();
27- }
38+ } */
2839}
2940
3041
0 commit comments