Research Summary Generator
Who is the target audience for this summary (e.g., non-experts, internal team)?
What foundational knowledge is needed? What is the current state of research?
What specific gap did this research fill or what question did it answer?
Briefly describe the design, participants, and data analysis methods used.
What were the most important, measurable results? (List each major finding on a new line).
What do the findings mean for the field/real world? What are the limitations or next steps?
Summary Preview
Click 'Refresh Preview' or navigate to Tab 3 and back to update the summary.
${escapeHTML(data.citation)}
` : ''} `; }; const downloadTxt = () => { const data = getData(); let content = `RESEARCH SUMMARY: ${data.paperTitle.toUpperCase()}\n`; content += "========================================================\n"; content += `Authors: ${data.authors}\n`; content += `Source: ${data.journal}\n`; content += `Summary Purpose: ${data.summaryPurpose}\n\n`; content += "1. BACKGROUND & PROBLEM\n"; content += "-------------------------\n"; content += `Context: ${data.context}\n\n`; content += `Research Question: ${data.problem}\n\n`; content += "2. METHODOLOGY\n"; content += "----------------\n"; content += `${data.methodology}\n\n`; content += "3. KEY FINDINGS\n"; content += "----------------\n"; content += `${formatTextForTxt(data.findings)}\n\n`; content += "4. CONCLUSION & IMPLICATIONS\n"; content += "----------------------------\n"; content += `${data.implications}\n\n`; if (data.citation && data.citation !== 'N/A') { content += "5. FULL CITATION\n"; content += "----------------\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 = `summary_${data.paperTitle.replace(/ /g, '_')}.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 = getData(); const margin = 20; const pageWidth = doc.internal.pageSize.getWidth(); const usableWidth = pageWidth - (margin * 2); let yPos = 20; const addTitle = (text, size, isMain = false, isSubtitle = false) => { if (yPos > 270) { doc.addPage(); yPos = 20; } yPos += 5; doc.setFontSize(size); doc.setFont(undefined, isSubtitle ? 'normal' : 'bold'); doc.setTextColor(isMain ? 44 : 155, isMain ? 62 : 89, isMain ? 80 : 182); // Main dark, Section purple doc.text(text, pageWidth / 2, yPos, { align: 'center' }); yPos += 3; if (!isSubtitle) { doc.setDrawColor(224, 224, 224); doc.line(margin, yPos, pageWidth - margin, yPos); yPos += 5; } else { yPos += 5; } }; const addParagraph = (text, isHeading = false, isList = false) => { if (yPos > 280) { doc.addPage(); yPos = 20; } doc.setFontSize(10); doc.setFont(undefined, isHeading ? 'bold' : 'normal'); doc.setTextColor(52, 73, 94); const lines = doc.splitTextToSize(text, usableWidth - (isList ? 10 : 0)); if (lines.length * 6 + yPos > 285) { doc.addPage(); yPos = 20; } lines.forEach((line, index) => { let prefix = isList ? '• ' : ''; if (isList && text.match(/^[0-9.]+\s*/)) { // Use original formatting if numbered list prefix = ''; } doc.text(prefix + line, margin + (isList ? 5 : 0), yPos); yPos += 6; }); yPos += 3; }; // --- Build PDF Document --- // Header addTitle(data.paperTitle, 16, true); addTitle(`Authors: ${data.authors} (${data.journal})`, 10, false, true); addTitle(`Summary for: ${data.summaryPurpose}`, 10, false, true); yPos += 5; // 1. Background & Problem addTitle("1. Background & Problem", 14); addParagraph("Context:", true); addParagraph(data.context); addParagraph("Research Question:", true); addParagraph(data.problem); // 2. Methodology addTitle("2. Methodology", 14); addParagraph(data.methodology); // 3. Key Findings addTitle("3. Key Findings", 14); data.findings.split('\n').filter(line => line.trim() !== '').forEach(line => { addParagraph(line, false, true); }); // 4. Conclusion & Implications addTitle("4. Conclusion & Implications", 14); addParagraph(data.implications); // 5. Citation if (data.citation && data.citation !== 'N/A') { addTitle("5. Full Citation", 14); doc.setFontSize(9); doc.setFont(undefined, 'italic'); doc.setTextColor(52, 73, 94); doc.text(doc.splitTextToSize(data.citation, usableWidth), margin, yPos); yPos += 10; } doc.save(`research_summary_${data.paperTitle.replace(/ /g, '_')}.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 downloadPdfBtn.addEventListener('click', downloadPDF); downloadTxtBtn.addEventListener('click', downloadTxt); refreshPreviewBtn.addEventListener('click', generatePreview); // --- Initialization --- showTab(1); });