Famous Scientist Report Generator
Report Subject
Biographical Details
What was the world/scientific community like during her time?
Scientific Contribution
How did she test her theory? (e.g., equipment, process, key data)
The main results of her research.
Legacy & Impact
How did this work change science or society?
Source for your information (e.g., book, website, textbook).
Key Experiment/Theory: ${escapeHTML(data.keyExperiment)}
Methodology Summary: ${escapeHTML(data.methodology)}
Primary Findings:
- ${formatTextList(data.primaryFindings)}
IV. Legacy and Conclusion
Famous Quotation:
"${escapeHTML(data.quotation)}"
"${escapeHTML(data.quotation)}"
Long-Term Scientific Impact: ${escapeHTML(data.longTermImpact)}
V. Source Citation
${escapeHTML(data.citation)}
`; }; const downloadTxt = () => { const data = getReportData(); let content = `SCIENTIFIC REPORT: ${data.reportTitle.toUpperCase()}\n`; content += `Subject: ${data.subjectName} | Field: ${data.field}\n`; content += "===========================================================\n\n"; content += "I. INTRODUCTION\n"; content += `Thesis Statement: ${data.mainContribution}\n\n`; content += "II. BIOGRAPHY AND CONTEXT\n"; content += `Dates: ${data.birthDeath}\n`; content += `Nationality: ${data.nationality}\n`; content += `Education: ${data.education}\n`; content += `Historical Context: ${data.historicalContext}\n\n`; content += "III. KEY WORK AND SCIENTIFIC FINDINGS\n"; content += `Key Experiment/Theory: ${data.keyExperiment}\n`; content += `Methodology Summary: ${data.methodology}\n`; content += `Primary Findings:\n`; data.primaryFindings.split('\n').filter(l => l.trim().length > 0).forEach(l => content += ` - ${l.trim()}\n`); content += `\n`; content += "IV. LEGACY AND CONCLUSION\n"; content += `Famous Quotation: "${data.quotation}"\n`; content += `Long-Term Scientific Impact: ${data.longTermImpact}\n\n`; content += "V. SOURCE CITATION\n"; content += `${data.citation}\n`; const blob = new Blob([content], { type: 'text/plain;charset=utf-8' }); const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = `${data.reportTitle.replace(/ /g, '_')}_report.txt`; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(a.href); }; const downloadPDF = () => { if (typeof window.jspdf === 'undefined' || typeof window.jspdf.jsPDF === 'undefined') { alert('Error: jsPDF library not loaded.'); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF('p', 'mm', 'a4'); const data = getReportData(); const margin = 15; const pageWidth = doc.internal.pageSize.getWidth(); const usableWidth = pageWidth - margin * 2; let yPos = 20; const addWrappedText = (text, size, style, color = [52, 73, 94], align = 'left', indent = 0) => { doc.setFontSize(size); doc.setFont(undefined, style); doc.setTextColor(color[0], color[1], color[2]); const splitText = doc.splitTextToSize(text, usableWidth - indent); if (yPos + (splitText.length * 5) > 280) { doc.addPage(); yPos = 20; } doc.text(splitText, margin + indent, yPos); yPos += (splitText.length * 5) + 3; }; const addSectionHeader = (title) => { yPos += 5; doc.setFontSize(14); doc.setFont(undefined, 'bold'); doc.setTextColor(52, 152, 219); // Blue doc.text(title, margin, yPos); doc.setDrawColor(224, 224, 224); doc.line(margin, yPos + 1, pageWidth - margin, yPos + 1); yPos += 8; }; // --- Build PDF Document --- // 1. Title Block doc.setFontSize(20); doc.setFont(undefined, 'bold'); doc.setTextColor(44, 62, 80); doc.text(data.reportTitle.toUpperCase(), pageWidth / 2, yPos, { align: 'center' }); yPos += 8; addWrappedText(`By: [Your Name] | Subject: ${data.subjectName} (${data.field})`, 10, 'italic', [108, 117, 125], 'center'); yPos += 5; // 2. Introduction addSectionHeader("I. Introduction"); addWrappedText(data.mainContribution, 10, 'normal'); yPos += 5; // 3. Biography addSectionHeader("II. Biography and Historical Context"); addWrappedText(`Dates: ${data.birthDeath}`, 10, 'normal', [52, 73, 94], 'left', 5); addWrappedText(`Nationality: ${data.nationality}`, 10, 'normal', [52, 73, 94], 'left', 5); addWrappedText(`Education & Institutions: ${data.education}`, 10, 'normal', [52, 73, 94], 'left', 5); addWrappedText(`Historical Context: ${data.historicalContext}`, 10, 'normal', [52, 73, 94], 'left', 5); yPos += 5; // 4. Key Work and Findings addSectionHeader("III. Key Work and Scientific Findings"); addWrappedText(`Key Experiment/Theory: ${data.keyExperiment}`, 10, 'normal', [52, 73, 94], 'left', 5); addWrappedText(`Methodology Summary: ${data.methodology}`, 10, 'normal', [52, 73, 94], 'left', 5); yPos += 3; addWrappedText("Primary Findings:", 10, 'bold', [52, 73, 94], 'left', 5); data.primaryFindings.split('\n').filter(l => l.trim().length > 0).forEach(l => { addWrappedText(`- ${l.trim()}`, 10, 'normal', [52, 73, 94], 'left', 10); }); yPos += 5; // 5. Legacy addSectionHeader("IV. Legacy and Conclusion"); // Quote Box doc.setDrawColor(52, 152, 219); doc.setLineWidth(0.5); doc.rect(margin + 5, yPos, usableWidth - 10, 15, 'S'); addWrappedText(`"${data.quotation}"`, 11, 'italic', [44, 62, 80], 'center', 0); addWrappedText(`- ${data.subjectName}`, 10, 'normal', [108, 117, 125], 'right', 10); yPos += 10; addWrappedText(`Long-Term Scientific Impact: ${data.longTermImpact}`, 10, 'normal', [52, 73, 94], 'left', 5); yPos += 5; // 6. Citation addSectionHeader("V. Source Citation"); addWrappedText(data.citation, 9, 'normal', [52, 73, 94], 'left', 5); doc.save('scientific_report.pdf'); }; // --- Event Listeners --- // Tab Buttons tabButtons.forEach((btn, index) => { btn.addEventListener('click', () => showTab(index + 1)); }); // Next/Prev Navigation nextBtn.addEventListener('click', () => showTab(currentTab + 1)); prevBtn.addEventListener('click', () => showTab(currentTab - 1)); // Tab 4 Actions refreshBtn.addEventListener('click', generatePreview); downloadPdfBtn.addEventListener('click', downloadPDF); downloadTxtBtn.addEventListener('click', downloadTxt); // --- Initialization --- showTab(1); // Set initial state });