Experimental Philosophy Survey Drafter
Design and structure vignettes and response scales for testing philosophical intuitions.
Enter the **Vignette Text**, the specific **Intuition** being measured, and the required **Response Scale** for each item.
Review the final instrument as it will appear to participants. Ensure the flow, tone, and measurement scales are consistent.
Scale: ${item.scaleText}
`; instrumentList.appendChild(cardDiv); }); } // --- Tab Switching --- function epsd_showTab(targetId, element) { tabButtons.forEach(btn => btn.classList.remove('epsd-active')); document.querySelectorAll('.epsd-tab-content').forEach(content => content.classList.remove('active')); if (element) { element.classList.add('epsd-active'); } document.getElementById(targetId).classList.add('active'); if (targetId === 'review') { epsd_renderReview(); } } window.epsd_showTab = epsd_showTab; // --- PDF Export --- function epsd_downloadPDF() { epsd_renderReview(); if (typeof jspdf === 'undefined' || typeof jspdf.plugin.autotable === 'undefined') { alert('Error: PDF library not fully loaded for export.'); return; } if (EPSD_STATE.items.length === 0) { alert('Please define survey items before generating the PDF.'); 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('#1e3a8a'); // Navy doc.text(`Experimental Philosophy Survey Instrument`, pageWidth / 2, yPos, { align: 'center' }); yPos += 30; // --- Instrument Table --- const tableHeaders = ['#', 'Intuition', 'Vignette/Scenario', 'Question', 'Response Scale']; const tableBody = EPSD_STATE.items.map((item, index) => [ (index + 1).toString(), item.intuition, item.vignette, item.question, item.scaleText ]); doc.autoTable({ head: [tableHeaders], body: tableBody, startY: yPos, theme: 'grid', styles: { fontSize: 8, cellPadding: 5, overflow: 'linebreak' }, headStyles: { fillColor: [30, 58, 138], textColor: 255, fontStyle: 'bold' }, // Navy-800 alternateRowStyles: { fillColor: [245, 245, 255] }, columnStyles: { 0: { cellWidth: 20, halign: 'center' }, 2: { cellWidth: 150 }, // Vignette gets space 3: { cellWidth: 100 }, // Question gets space 4: { cellWidth: 130 } // Scale gets space }, didDrawPage: function(data) { yPos = data.cursor.y; } }); doc.save(`ExPhil_Survey_Instrument.pdf`); } // --- Initialization --- document.addEventListener('DOMContentLoaded', () => { // 1. Attach listeners document.getElementById('epsd-add-item-btn').addEventListener('click', epsd_addItem); document.getElementById('matrix-next-btn').addEventListener('click', () => epsd_showTab('review', document.querySelector('.epsd-tab-btn[data-tab="review"]'))); document.getElementById('epsd-download-pdf').addEventListener('click', epsd_downloadPDF); tabButtons.forEach(btn => { btn.addEventListener('click', (e) => epsd_showTab(e.target.dataset.tab, e.target)); }); // 2. Initial population epsd_renderMatrixTable(); });