Earnings Transcript Keyword Analyzer

Enter Transcript and Keywords

Analysis Summary

Submit transcript and keywords to see the analysis.

Keyword in Context

Analyzed keywords will show contextual sentences here.

No specific sentences found containing this keyword.

"; } contextHtml += ``; }); } else { contextHtml = "

No keywords analyzed or no contexts found.

"; } contextOutput.innerHTML = contextHtml; if (pdfBtn) pdfBtn.style.display = 'inline-block'; } function etka_downloadPDF() { // Check if jsPDF and autotable are loaded if (typeof window.jspdf === 'undefined' || typeof window.jspdf.jsPDF === 'undefined') { alert("Error: jsPDF library not loaded. Cannot generate PDF. Please check your internet connection or ensure the library is included."); console.error("jsPDF main library not found."); return; } // Autotable is a plugin on jsPDF instances, or on window.jspdf.autoTable if (typeof window.jspdf.autoTable === 'undefined' && (typeof window.jspdf.jsPDF.API === 'undefined' || typeof window.jspdf.jsPDF.API.autoTable === 'undefined')) { alert("Error: jsPDF AutoTable plugin not loaded. Cannot generate PDF tables. Please ensure the plugin is included."); console.error("jsPDF AutoTable plugin not found."); return; } if (!etka_globals.analysisResults) { alert("No analysis results to download. Please analyze a transcript first."); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF(); doc.setFontSize(18); doc.text("Earnings Transcript Keyword Analyzer - Report", 14, 22); doc.setFontSize(10); doc.setTextColor(100); const generationDate = `Generated: ${new Date().toLocaleString()}`; doc.text(generationDate, 14, 30); let currentY = 40; doc.setFontSize(12); doc.setTextColor(0); doc.text(`Total Words in Transcript: ${etka_globals.analysisResults.totalWords}`, 14, currentY); currentY += 10; const head = [['Keyword', 'Count', 'Density (%)']]; const body = etka_globals.analysisResults.keywords.map(keyword => [ keyword, etka_globals.analysisResults.counts[keyword], etka_globals.analysisResults.density[keyword] + '%' ]); doc.autoTable({ startY: currentY, head: head, body: body, theme: 'striped', headStyles: { fillColor: [52, 152, 219], textColor: [255,255,255] }, margin: { top: 10 } }); currentY = doc.autoTable.previous.finalY + 15; doc.setFontSize(14); doc.setTextColor(0); doc.text("Keyword in Context", 14, currentY); currentY += 10; etka_globals.analysisResults.keywords.forEach(keyword => { if (currentY > 265) { // Check for page break (A4 height ~297mm) doc.addPage(); currentY = 20; } doc.setFontSize(12); doc.setTextColor(41, 128, 185); doc.text(keyword, 14, currentY); currentY += 7; doc.setTextColor(0); doc.setFontSize(10); const contexts = etka_globals.analysisResults.contexts[keyword]; if (contexts.length > 0) { contexts.forEach(sentenceWithMark => { if (currentY > 275) { doc.addPage(); currentY = 20; doc.setFontSize(12); doc.setTextColor(41, 128, 185); doc.text(`${keyword} (continued)`, 14, currentY); currentY += 7; doc.setTextColor(0); doc.setFontSize(10); } // Strip tags for PDF output as jsPDF text doesn't render HTML const cleanSentence = sentenceWithMark.replace(/<\/?mark>/g, ""); const splitSentences = doc.splitTextToSize(cleanSentence, doc.internal.pageSize.width - 32); // 14mm margin left/right (14+14=28, give bit more) splitSentences.forEach(line => { if (currentY > 280) { // Re-check for each line after split doc.addPage(); currentY = 20; } doc.text(line, 16, currentY); currentY += 5; // Line height }); currentY += 2; }); } else { if (currentY > 280) { doc.addPage(); currentY = 20; } doc.text(" No specific sentences found containing this keyword.", 16, currentY); currentY += 7; } currentY += 4; }); doc.save('Earnings_Transcript_Analysis.pdf'); } document.addEventListener('DOMContentLoaded', function() { // Cache core DOM elements used by the tool etka_globals.domElements['etka-transcript'] = document.getElementById('etka-transcript'); etka_globals.domElements['etka-keywords'] = document.getElementById('etka-keywords'); etka_globals.domElements['etka-case-sensitive'] = document.getElementById('etka-case-sensitive'); etka_globals.domElements['etka-summary-output'] = document.getElementById('etka-summary-output'); etka_globals.domElements['etka-context-output'] = document.getElementById('etka-context-output'); // Initialize Tab Buttons and cache them etka_initTabButtons(); // This also populates button IDs in DOM for etka_getElement if needed // Display initial tab (Input & Settings) if (etka_globals.tabIds.length > 0 && etka_globals.tabButtonLabels.length > 0) { const initialTabId = etka_globals.tabIds[0]; const initialTabButton = etka_getElement(`etka-tab-btn-${initialTabId}`); if (initialTabButton) { etka_openTab({ currentTarget: initialTabButton }, initialTabId, 0); } else { // Fallback if button ID not found (should not happen if initTabButtons worked) const tabButtons = document.querySelectorAll('.etka-tool .etka-tab-button'); if (tabButtons[0]) etka_openTab({ currentTarget: tabButtons[0] }, initialTabId, 0); } } // Attach event listeners using cached elements where possible const analyzeBtn = etka_getElement('etka-analyze-btn'); if (analyzeBtn) { analyzeBtn.onclick = etka_analyzeTranscript; } else { console.error("ETKA Critical Error: Analyze button (id: etka-analyze-btn) not found for listener attachment."); } const downloadPdfBtn = etka_getElement('etka-download-pdf-btn'); if (downloadPdfBtn) { downloadPdfBtn.onclick = etka_downloadPDF; } else { console.error("ETKA Critical Error: Download PDF button (id: etka-download-pdf-btn) not found for listener attachment."); } const prevBtn = etka_getElement('etka-prev-btn'); if (prevBtn) { prevBtn.onclick = function() { etka_navigateTab('prev'); }; } else { console.error("ETKA Critical Error: Previous button (id: etka-prev-btn) not found."); } const nextBtn = etka_getElement('etka-next-btn'); if (nextBtn) { nextBtn.onclick = function() { etka_navigateTab('next'); }; } else { console.error("ETKA Critical Error: Next button (id: etka-next-btn) not found."); } });
Scroll to Top