Science Flashcard Maker Generator

Science Flashcard Maker Generator

Science Flashcard Maker Generator

Create, categorize, and export study cards for scientific concepts.

Enter your terms and definitions. The **Topic** field is used for categorization during review and export.

Card Log

# Science Topic Term / Question (Front) Definition / Answer (Back) Action

Review your final set of flashcards below. You can filter by topic before generating the PDF.

${card.definition}

`; cardList.appendChild(cardDiv); }); } // --- Tab Switching --- function sfmg_showTab(targetId, element) { tabButtons.forEach(btn => btn.classList.remove('sfmg-active')); document.querySelectorAll('.sfmg-tab-content').forEach(content => content.classList.remove('active')); if (element) { element.classList.add('sfmg-active'); } document.getElementById(targetId).classList.add('active'); if (targetId === 'review') { sfmg_renderReview(dom.topicFilter.value); } } window.sfmg_showTab = sfmg_showTab; // --- PDF Export --- function sfmg_downloadPDF() { sfmg_collectCardData(); const filterTopic = dom.topicFilter.value; if (typeof jspdf === 'undefined' || typeof jspdf.plugin.autotable === 'undefined') { alert('Error: PDF library not fully loaded for export.'); return; } const filteredCards = filterTopic === 'all' ? SFMG_STATE.cards : SFMG_STATE.cards.filter(c => c.topic === filterTopic); if (filteredCards.length === 0) { alert('No cards match the current filter selection for export.'); return; } const { jsPDF } = jspdf; const doc = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' }); doc.setFont('sans-serif', 'normal'); const margin = 40; const pageWidth = doc.internal.pageSize.getWidth(); let yPos = margin; // --- Header --- doc.setFontSize(18); doc.setFont('sans-serif', 'bold'); doc.setTextColor('#0891b2'); // Cyan-600 doc.text(`Science Flashcard Set: ${filterTopic === 'all' ? 'All Topics' : filterTopic}`, pageWidth / 2, yPos, { align: 'center' }); yPos += 30; // --- Flashcard Table --- doc.setFontSize(10); const tableHeaders = ['#', 'Topic', 'Term / Question', 'Definition / Answer']; const tableBody = filteredCards.map((card, index) => [ (index + 1).toString(), card.topic, card.term, card.definition ]); doc.autoTable({ head: [tableHeaders], body: tableBody, startY: yPos, theme: 'grid', styles: { fontSize: 9, cellPadding: 6, overflow: 'linebreak' }, headStyles: { fillColor: [8, 145, 178], textColor: 255, fontStyle: 'bold' }, // Cyan-600 alternateRowStyles: { fillColor: [245, 255, 255] }, columnStyles: { 0: { cellWidth: 20, halign: 'center' } }, didDrawPage: function(data) { yPos = data.cursor.y; } }); doc.save(`Flashcard_Set_${filterTopic.replace(/\s/g, '_')}.pdf`); } // --- Initialization --- document.addEventListener('DOMContentLoaded', () => { // 1. Assign DOM elements dom.topicFilter = document.getElementById('topic-filter'); // 2. Attach listeners document.getElementById('sfmg-add-card-btn').addEventListener('click', sfmg_addCard); document.getElementById('matrix-next-btn').addEventListener('click', () => sfmg_showTab('review', document.querySelector('.sfmg-tab-btn[data-tab="review"]'))); document.getElementById('sfmg-download-pdf').addEventListener('click', sfmg_downloadPDF); tabButtons.forEach(btn => { btn.addEventListener('click', (e) => sfmg_showTab(e.target.dataset.tab, e.target)); }); // Filter listener dom.topicFilter.addEventListener('change', () => sfmg_renderReview(dom.topicFilter.value)); // 3. Initial population sfmg_renderMatrixTable(); });
Scroll to Top