`;
}
};
const createCard = (title, subtitle, items) => `
`;
// --- PDF UTILITY ---
const downloadPDF = () => {
const { jsPDF } = window.jspdf;
const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' });
const title = "Clarity & Conciseness Report";
const originalText = elements.inputText.value;
const revisedText = elements.revisedText.value;
const PAGE_WIDTH = pdf.internal.pageSize.getWidth();
const MARGIN = 50;
let y = 0;
// Header
pdf.setFillColor(15, 116, 109); // teal-700
pdf.rect(0, 0, PAGE_WIDTH, 70, 'F');
pdf.setFont('helvetica', 'bold');
pdf.setFontSize(22);
pdf.setTextColor(255, 255, 255);
pdf.text(title, MARGIN, 45);
y = 110;
const addSection = (secTitle, secContent) => {
if (y > pdf.internal.pageSize.getHeight() - 100) { pdf.addPage(); y = MARGIN; }
pdf.setFont('helvetica', 'bold');
pdf.setFontSize(14);
pdf.setTextColor(13, 148, 136); // teal-600
pdf.text(secTitle, MARGIN, y);
y += 20;
pdf.setFont('helvetica', 'normal');
pdf.setFontSize(10);
pdf.setTextColor(51, 65, 85); // slate-700
const lines = pdf.splitTextToSize(secContent, PAGE_WIDTH - MARGIN * 2);
pdf.text(lines, MARGIN, y);
y += lines.length * 12 + 25;
};
// Summary
addSection('Analysis Summary', `Original Word Count: ${analysisData.stats.words}, Sentences: ${analysisData.stats.sentences}. The following suggestions were provided:`);
if (analysisData.longSentences.length > 0) {
addSection('Long Sentences to Review', analysisData.longSentences.join('\n\n'));
}
if (analysisData.passiveSentences.length > 0) {
addSection('Sentences with Passive Voice', analysisData.passiveSentences.join('\n\n'));
}
if (analysisData.fillerWords.length > 0) {
addSection('Filler Words to Consider Removing', analysisData.fillerWords.join(', '));
}
pdf.addPage();
y = MARGIN;
addSection('Original Text', originalText);
if (revisedText !== originalText) {
addSection('Revised Text', revisedText);
}
pdf.save(`Clarity_Report.pdf`);
};
// --- EVENT LISTENERS ---
elements.prevBtn.addEventListener('click', () => nextPrev(-1));
elements.nextBtn.addEventListener('click', () => nextPrev(1));
elements.tabs.forEach((tab, i) => {
tab.addEventListener('click', () => console.warn("Direct tab navigation is disabled. Please use Next/Previous buttons."));
});
elements.downloadPdfBtn.addEventListener('click', downloadPDF);
// Initialize
showTab(currentTab);
});
${title} (${items.length})
${subtitle}
- ${items.map(item => `
- ‣${item} `).join('')}
