III. Conclusion
A. Restate Thesis & Summarize Main Points
Briefly revisit the introduction and the main arguments from the body paragraphs to reinforce the essay's position.
`;
}
function showMessage() {
messageBox.classList.remove('opacity-0', 'translate-y-10');
messageBox.classList.add('opacity-100', 'translate-y-0');
setTimeout(() => {
messageBox.classList.remove('opacity-100', 'translate-y-0');
messageBox.classList.add('opacity-0', 'translate-y-10');
}, 2000);
}
function generatePdf() {
const { jsPDF } = window.jspdf;
const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' });
const data = getFormData();
const margin = 20;
const pageW = pdf.internal.pageSize.getWidth();
let y = 0;
const lineH = 7;
const addHeaderFooter = (title) => {
const pageCount = pdf.internal.getNumberOfPages();
for (let i = 1; i <= pageCount; i++) {
pdf.setPage(i);
pdf.setFontSize(9);
pdf.setTextColor('#9ca3af');
pdf.text(title, margin, 12);
pdf.text(`Page ${i}`, pageW - margin, pdf.internal.pageSize.getHeight() - 10, { align: 'right' });
}
};
const addSectionHeader = (title) => {
y += lineH * 1.5;
if (y > 250) { pdf.addPage(); y = margin; }
pdf.setFontSize(14);
pdf.setFont('helvetica', 'bold');
pdf.setTextColor('#1e3a8a');
pdf.text(title, margin, y);
y += lineH;
};
const addText = (text, options={}) => {
const {size=10, style='normal', color='#334155', indent=0} = options;
if (!text || y > 260) {
if(y > 260) {
pdf.addPage(); y = margin;
} else {
return;
}
}
pdf.setFontSize(size);
pdf.setFont('helvetica', style);
pdf.setTextColor(color);
const lines = pdf.splitTextToSize(text, pageW - (margin * 2) - indent);
pdf.text(lines, margin + indent, y);
y += lines.length * lineH * 0.8;
};
// --- Build PDF Document ---
pdf.setFontSize(24);
pdf.setFont('helvetica', 'bold');
pdf.setTextColor('#1e293b');
pdf.text(data.title, pageW / 2, 30, { align: 'center' });
pdf.setFontSize(12);
pdf.setTextColor('#475569');
pdf.text(`Course: ${data.subject || 'N/A'}`, pageW / 2, 40, { align: 'center' });
y = 55;
addSectionHeader("I. Introduction");
addText('Thesis Statement:', {style: 'bold'});
addText(data.thesis, {indent: 5, style: 'italic'});
y += lineH;
addSectionHeader("II. Body Paragraphs");
data.arguments.forEach((arg, index) => {
if(arg.topic) {
addText(`Argument ${index + 1}: ${arg.topic}`, {style: 'bold'});
addText(`Evidence: ${arg.evidence || 'N/A'}`, {indent: 5, size: 9});
y += lineH * 0.5;
}
});
y += lineH;
addSectionHeader("III. Conclusion");
addText('A. Restate Thesis & Summarize Main Points', {style: 'bold'});
addText('Briefly revisit the introduction and the main arguments from the body paragraphs to reinforce the essay\'s position.', {indent: 5, size: 9});
addHeaderFooter('Academic Essay Plan');
pdf.save(`Essay_Plan_${data.title.replace(/\s/g, '_')}.pdf`);
}
// --- Event Listeners & Init ---
tabs.forEach(tab => tab.addEventListener('click', () => goToTab(parseInt(tab.dataset.tab))));
prevButton.addEventListener('click', () => goToTab(currentTab - 1));
nextButton.addEventListener('click', () => goToTab(currentTab + 1));
copyButton.addEventListener('click', () => {
const outline = document.getElementById('outline-container');
if(outline) {
navigator.clipboard.writeText(outline.innerText).then(() => {
showMessage();
}).catch(err => console.error('Copy failed:', err));
}
});
pdfDownloadButton.addEventListener('click', generatePdf);
addArgumentButton.addEventListener('click', addArgumentItem);
// Add one initial argument item
addArgumentItem();
updateTabUI();
});