Eulogy Writing Tool

Eulogy Writing Tool

A helping hand to honor a life well-lived.

I'd like to share a small story that I feel captures this spirit. ${data.memory}. It's a simple moment, perhaps, but it's one of many that I will cherish forever. It speaks volumes about who ${pronoun} were.

`; } if (data.impact) { eulogyHTML += `

For me personally, ${data.impact.charAt(0).toLowerCase() + data.impact.slice(1)}. ${pronoun.charAt(0).toUpperCase() + pronoun.slice(1)} left an indelible mark on my life, as I'm sure ${pronoun} did on many of yours.

`; } eulogyHTML += `

The loss of ${name} leaves a space that cannot be filled, but the memories and the love ${pronoun} gave us will endure. ${data.closing}. Thank you.

`; const contentDiv = document.getElementById('generated-eulogy-content'); if (contentDiv) contentDiv.innerHTML = eulogyHTML; } tabs.forEach((tab, index) => tab.addEventListener('click', () => updateTabUI(index))); nextBtn.addEventListener('click', () => { if (currentTab < totalTabs - 1) { if (currentTab === totalTabs - 2) generateEulogy(); updateTabUI(currentTab + 1); } }); prevBtn.addEventListener('click', () => { if (currentTab > 0) updateTabUI(currentTab - 1); }); downloadPdfBtn.addEventListener('click', () => { const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'portrait', unit: 'mm', format: 'a4' }); const eulogyContainer = document.getElementById('generated-eulogy-content'); if (!eulogyContainer) return; const name = eulogyContainer.querySelector('h2')?.innerText.replace('In Loving Memory of ', '') || 'A Eulogy'; // Clone the container to manipulate it without affecting the live DOM const clone = eulogyContainer.cloneNode(true); clone.querySelector('h2').remove(); // Remove title from main text const eulogyText = Array.from(clone.querySelectorAll('p')).map(p => p.innerText).join('\n\n'); const pageW = doc.internal.pageSize.getWidth(); const pageH = doc.internal.pageSize.getHeight(); const margin = 20; let y = margin + 10; const violetColor = '#6d28d9'; const darkGray = '#3f3f46'; // --- Build PDF --- // Decorative top border doc.setDrawColor(violetColor); doc.setLineWidth(0.5); doc.line(margin, margin, pageW - margin, margin); y += 5; // Title doc.setFontSize(22); doc.setFont('times', 'bold'); doc.setTextColor(darkGray); doc.text('In Loving Memory of', pageW / 2, y, { align: 'center' }); y += 10; doc.setFontSize(26); doc.setFont('times', 'italic'); doc.setTextColor(violetColor); doc.text(name, pageW / 2, y, { align: 'center' }); y += 15; // Body text doc.setFontSize(12); doc.setFont('times', 'normal'); doc.setTextColor(darkGray); const lines = doc.splitTextToSize(eulogyText, pageW - margin * 2); lines.forEach(line => { if (y + 5 > pageH - margin) { // Decorative bottom border doc.setDrawColor(violetColor); doc.setLineWidth(0.5); doc.line(margin, pageH - margin, pageW - margin, pageH - margin); doc.addPage(); y = margin + 10; // Decorative top border on new page doc.setDrawColor(violetColor); doc.setLineWidth(0.5); doc.line(margin, margin, pageW - margin, margin); } doc.text(line, margin, y); y += 6; // Line height }); // Decorative bottom border on final page doc.setDrawColor(violetColor); doc.setLineWidth(0.5); doc.line(margin, pageH - margin, pageW - margin, pageH - margin); doc.save(`Eulogy-for-${name.replace(/\s+/g, '-')}.pdf`); }); // Initialize updateTabUI(0); lucide.createIcons(); });
Scroll to Top