Professional Bio Generator
My Templates
| Template Name | Action |
|---|
No bio templates found. Please add one in the "Template Configuration" tab.
'; return; } bioTemplates.forEach(template => { let bioText = template.text; // Replace all placeholders for (const [key, value] of Object.entries(data)) { // Use a regex to replace all instances bioText = bioText.replace(new RegExp(key, 'g'), value); } // Cleanup: Fix potential double periods or spaces bioText = bioText.replace(/\.\./g, '.'); bioText = bioText.replace(/\s\s+/g, ' '); bioText = bioText.replace(/\s\./g, '.'); const card = document.createElement('div'); card.className = 'bio-review-card'; card.innerHTML = `${template.name}
${bioText}
`; reviewArea.appendChild(card); }); switchTab(1); // Switch to review tab } function downloadPDF() { const { jsPDF } = window.jspdf; const doc = new jsPDF(); const pageHeight = doc.internal.pageSize.height; const pageWidth = doc.internal.pageSize.width; const margin = 20; const maxWidth = pageWidth - (margin * 2); let currentY = margin; doc.setFontSize(20); doc.setFont(undefined, 'bold'); doc.text("Professional Bio Drafts", pageWidth / 2, currentY, { align: 'center' }); currentY += 15; const reviewCards = reviewArea.querySelectorAll('.bio-review-card'); reviewCards.forEach(card => { const title = card.querySelector('h3').textContent; const text = card.querySelector('p').textContent; const titleHeight = 10; const textLines = doc.splitTextToSize(text, maxWidth); const textHeight = textLines.length * 7 + 10; // 7 per line + padding if (currentY + titleHeight + textHeight > pageHeight - margin) { doc.addPage(); currentY = margin; } doc.setFontSize(16); doc.setFont(undefined, 'bold'); doc.text(title, margin, currentY); currentY += titleHeight; doc.setFontSize(11); doc.setFont(undefined, 'normal'); doc.text(textLines, margin, currentY); currentY += textHeight; }); doc.save('professional-bio-drafts.pdf'); } // --- Tab Navigation --- function switchTab(tabIndex) { tabs.forEach((tab, index) => { tab.classList.toggle('active', index === tabIndex); contents[index].classList.toggle('active', index === tabIndex); }); currentTab = tabIndex; updateNavButtons(); } function updateNavButtons() { prevBtn.disabled = currentTab === 0; nextBtn.disabled = currentTab === tabs.length - 1; } tabs.forEach((tab, index) => { tab.addEventListener('click', () => switchTab(index)); }); nextBtn.addEventListener('click', () => { if (currentTab < tabs.length - 1) switchTab(currentTab + 1); }); prevBtn.addEventListener('click', () => { if (currentTab > 0) switchTab(currentTab - 1); }); // --- Event Listeners --- generateBtn.addEventListener('click', generateBios); configForm.addEventListener('submit', handleAddTemplate); pdfDownloadBtn.addEventListener('click', downloadPDF); // --- Initial Setup --- loadDefaultTemplates(); updateNavButtons(); });