Corporate Email Etiquette Analyzer

Corporate Email Etiquette Analyzer

Analysis Report

0%
`; feedbackList.appendChild(li); }); resultsSection.style.display = 'block'; pdfBtn.disabled = false; resultsSection.scrollIntoView({ behavior: 'smooth' }); }; // --- PDF Generation --- const generatePDF = () => { if (!analysisResultCache) return; const { score, feedback, originalText } = analysisResultCache; const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' }); const pageWidth = doc.internal.pageSize.getWidth(); const margin = 50; let cursorY = margin; // Header doc.setFont('helvetica', 'bold'); doc.setFontSize(22); doc.setTextColor(30, 41, 59); doc.text('Email Etiquette Analysis Report', pageWidth / 2, cursorY, { align: 'center' }); cursorY += 20; doc.setFont('helvetica', 'normal'); doc.setFontSize(10); doc.setTextColor(107, 114, 128); doc.text(new Date().toLocaleDateString('en-US', { dateStyle: 'full' }), pageWidth / 2, cursorY, { align: 'center' }); cursorY += 20; doc.setDrawColor(229, 231, 235); doc.line(margin, cursorY, pageWidth - margin, cursorY); cursorY += 30; // Score Section doc.setFont('helvetica', 'bold'); doc.setFontSize(16); doc.text('Overall Score:', margin, cursorY); doc.setFontSize(28); let scoreColor = score >= 85 ? '#22c55e' : (score >= 60 ? '#f59e0b' : '#ef4444'); doc.setTextColor(scoreColor); doc.text(`${score}%`, margin + 100, cursorY); cursorY += 40; // Feedback Section doc.setFont('helvetica', 'bold'); doc.setFontSize(16); doc.setTextColor(30, 41, 59); doc.text('Detailed Feedback:', margin, cursorY); cursorY += 25; doc.setFont('helvetica', 'normal'); doc.setFontSize(11); feedback.forEach(item => { const icon = item.type === 'good' ? '✓' : '!'; const itemColor = item.type === 'good' ? '#16a34a' : '#d97706'; doc.setTextColor(itemColor); doc.text(icon, margin, cursorY); doc.setTextColor(55, 65, 81); const lines = doc.splitTextToSize(item.text, pageWidth - margin * 2 - 20); doc.text(lines, margin + 20, cursorY); cursorY += lines.length * 14 + 10; }); doc.save('Email-Etiquette-Report.pdf'); }; // Event Listeners analyzeBtn.addEventListener('click', analyzeEmail); pdfBtn.addEventListener('click', generatePDF); });
Scroll to Top