Scientific Fact Generator

Scientific Fact Composer

The core verifiable claim or data point.

Fact Log (Editable Dashboard)

Click directly on any cell to edit the value. Changes are saved automatically.

Statement Field Confidence Source Actions

Final review of the verified fact list.

Click "Next" or "Previous" to refresh this preview.

Generated on: ${data.dateGenerated}

${tableRowsHTML.length > 0 ? tableRowsHTML : ''}
# Statement Field Confidence Source
No facts logged.
`; }; const downloadTxt = () => { const data = getReportData(); let content = `SCIENTIFIC FACT LOG\n`; content += "========================================\n"; content += `Date Generated: ${data.dateGenerated}\n`; content += `Total Facts: ${data.facts.length}\n`; content += "========================================\n\n"; data.facts.forEach((f, index) => { content += `${index + 1}. STATEMENT: ${f.statement}\n`; content += ` FIELD: ${f.field}\n`; content += ` CONFIDENCE: ${f.confidence}\n`; content += ` SOURCE: ${f.source}\n\n`; }); const blob = new Blob([content], { type: 'text/plain;charset=utf-8' }); const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = `scientific_fact_log.txt`; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(a.href); }; const downloadPDF = () => { if (typeof window.jspdf === 'undefined' || typeof window.jspdf.jsPDF === 'undefined') { alert('Error: jsPDF library not loaded.'); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF('l', 'mm', 'a4'); // Landscape for better table fit const data = getReportData(); const margin = 10; const pageWidth = doc.internal.pageSize.getWidth(); let yPos = 15; // 1. Title doc.setFontSize(18); doc.setFont(undefined, 'bold'); doc.setTextColor(44, 62, 80); doc.text(`Scientific Fact Log`, pageWidth / 2, yPos, { align: 'center' }); yPos += 8; doc.setFontSize(10); doc.setFont(undefined, 'normal'); doc.setTextColor(108, 117, 125); doc.text(`Generated on: ${data.dateGenerated} | Total Entries: ${data.facts.length}`, pageWidth / 2, yPos, { align: 'center' }); yPos += 8; // 2. Table Data const logHead = [['#', 'Statement', 'Field', 'Confidence', 'Source / Citation']]; const logBody = data.facts.map((f, index) => [ index + 1, f.statement, f.field, f.confidence, f.source ]); doc.autoTable({ startY: yPos, head: logHead, body: logBody, theme: 'grid', styles: { fontSize: 8, cellPadding: 2, textColor: [52, 73, 94], valign: 'top' }, headStyles: { fillColor: [52, 152, 219], textColor: [255, 255, 255] }, columnStyles: { 0: { cellWidth: 8 }, 1: { cellWidth: 80 }, 2: { cellWidth: 30 }, 3: { cellWidth: 25 }, 4: { cellWidth: 'auto' } }, margin: { left: margin, right: margin } }); doc.save('scientific_fact_log.pdf'); }; // --- Event Listeners --- // Tab Buttons tabButtons.forEach((btn, index) => { btn.addEventListener('click', () => showTab(index + 1)); }); // Next/Prev Navigation nextBtn.addEventListener('click', () => showTab(currentTab + 1)); prevBtn.addEventListener('click', () => showTab(currentTab - 1)); // Tab 1 Action newFactInputs.addBtn.addEventListener('click', () => addFact()); // Tab 2 Actions (Remove and Edit) factTbody.addEventListener('click', (e) => { if (e.target.dataset.removeId) { removeFact(parseInt(e.target.dataset.removeId)); } }); factTbody.addEventListener('blur', (e) => { if (e.target.tagName === 'TD' && e.target.isContentEditable) { const id = parseInt(e.target.dataset.id); const field = e.target.dataset.field; updateFact(id, field, e.target.textContent); } generatePreview(); // Refresh summary on blur }, true); // Tab 3 Actions downloadPdfBtn.addEventListener('click', downloadPDF); downloadTxtBtn.addEventListener('click', downloadTxt); // --- Initialization --- // Pre-populate with sample data addFact({ statement: "The speed of light in a vacuum is 299,792,458 meters per second.", source: "CODATA/NIST", confidence: "High (Established)", field: "Physics", date: "1983-01-01" }); addFact({ statement: "Ocean acidity has increased by approximately 30% since the start of the Industrial Revolution.", source: "NOAA/IPCC AR5", confidence: "High (Established)", field: "Oceanography", date: "2014-01-01" }); // Set default date to today newFactInputs.date.value = new Date().toISOString().substring(0, 10); showTab(1); // Set initial state });
Scroll to Top