Team Sentiment Analysis Tool
Paste team feedback, survey results, or chat logs to analyze overall sentiment.
Input Text
Analysis Results
Analyzing sentiment...
Your analysis will appear here after you submit text.
Overall Sentiment
Sentiment Score
Key Themes
Key Phrases
"${phrase}"
`).join(''); resultsContent.classList.remove('hidden'); }; const generatePDF = async () => { if (!analysisData) { alert("Please analyze some text before downloading a report."); return; } const reportElement = document.getElementById('resultsPanel'); if (!reportElement) { console.error("Results panel element not found for PDF generation."); return; } const originalButtonText = downloadPdfBtn.innerHTML; downloadPdfBtn.innerHTML = 'Generating...'; downloadPdfBtn.disabled = true; try { const canvas = await html2canvas(reportElement, { scale: 2, backgroundColor: '#ffffff', useCORS: true, }); const imgData = canvas.toDataURL('image/png'); if (!imgData || imgData === 'data:,') { throw new Error("html2canvas failed to generate a valid image."); } const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'portrait', unit: 'px', format: 'a4' }); const pdfWidth = doc.internal.pageSize.getWidth(); const pdfHeight = doc.internal.pageSize.getHeight(); const canvasWidth = canvas.width; const canvasHeight = canvas.height; const ratio = canvasWidth / canvasHeight; const imgWidth = pdfWidth; const imgHeight = pdfWidth / ratio; let heightLeft = imgHeight; let position = 0; doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight); heightLeft -= pdfHeight; while (heightLeft > 0) { position -= pdfHeight; doc.addPage(); doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight); heightLeft -= pdfHeight; } doc.save('sentiment-analysis-report.pdf'); } catch (error) { console.error("PDF generation failed:", error); alert("Sorry, there was an error creating the PDF. Please try again."); } finally { downloadPdfBtn.innerHTML = originalButtonText; downloadPdfBtn.disabled = false; } }; // Event Listeners analyzeBtn.addEventListener('click', handleAnalysis); downloadPdfBtn.addEventListener('click', generatePDF); });