Smart Affirmation Generator
Create powerful, personalized affirmations to inspire your day.
I am capable of achieving amazing things.
My Favorite Affirmations
You haven't saved any affirmations yet.
Choose Categories
Add Custom Keywords
You haven't saved any affirmations yet.
`; return; } favoritesList.innerHTML = ''; favorites.forEach((fav, index) => { const item = document.createElement('div'); item.className = 'flex justify-between items-center bg-gray-100 p-3 rounded-lg'; item.innerHTML = ` ${fav} `; favoritesList.appendChild(item); }); } window.removeFavorite = function(index) { favorites.splice(index, 1); renderFavorites(); } function addKeyword() { const keyword = customKeywordInput.value.trim(); if (keyword && !customKeywords.includes(keyword)) { customKeywords.push(keyword); customKeywordInput.value = ''; renderKeywords(); } } function renderKeywords() { keywordTags.innerHTML = ''; customKeywords.forEach((kw, index) => { const tag = document.createElement('span'); tag.className = 'bg-orange-200 text-orange-800 text-sm font-medium px-3 py-1 rounded-full flex items-center'; tag.innerHTML = ` ${kw} `; keywordTags.appendChild(tag); }); } window.removeKeyword = function(index) { customKeywords.splice(index, 1); renderKeywords(); } function downloadPDF() { if (favorites.length === 0) { console.warn("No favorites to export."); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF(); const tableData = favorites.map(fav => [fav]); doc.setFontSize(18); doc.text('My Favorite Affirmations', 14, 22); doc.setFontSize(11); doc.setTextColor(100); doc.text(`Generated on: ${new Date().toLocaleDateString()}`, 14, 30); doc.autoTable({ head: [['Affirmation']], body: tableData, startY: 35, theme: 'grid', headStyles: { fillColor: [234, 88, 12] }, // Orange-600 styles: { cellPadding: 3 } }); doc.save('My-Favorite-Affirmations.pdf'); } // --- Event Listeners --- generateBtn.addEventListener('click', generateAffirmation); saveFavoriteBtn.addEventListener('click', saveFavorite); addKeywordBtn.addEventListener('click', addKeyword); customKeywordInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') addKeyword(); }); downloadPdfBtn.addEventListener('click', downloadPDF); // --- Initial Setup --- updateNavButtons(); renderFavorites(); });