Seismic Data Log Generator

Seismic Data Log Generator

Project Metadata

Add New Event Reading

Logged Seismic Events (Editable)

# Time/Date Magnitude Depth (km) Location/Notes Actions

Review the final summary statistics and export options.

Summary Statistics

Log at least one event in Tab 2 to see the summary.

Full Report Preview

Refresh the preview using the buttons below.

Avg. Depth (km): ${stats.avgDepth}

Max Depth (km): ${stats.maxDepth}

` : `

Insufficient data for statistics.

`}

3. Raw Event Log

${itemRowsHTML.length > 0 ? itemRowsHTML : ''}
# Time/Date Magnitude Depth (km) Location/Notes
No events logged.
`; }; const downloadTxt = () => { const data = getReportData(); const stats = data.stats; let content = `SEISMIC DATA LOG: ${data.setup.project.toUpperCase()}\n`; content += "========================================================\n"; content += `Site ID: ${data.setup.site}\nOperator: ${data.setup.operator}\n`; content += `Period: ${data.setup.start} to ${data.setup.end}\n`; content += `Notes: ${data.setup.notes}\n\n`; if (stats) { content += "SUMMARY STATISTICS\n"; content += `Total Events: ${stats.count}\nAvg. Mag: ${stats.avgMag}\nMax Mag: ${stats.maxMag}\nAvg. Depth: ${stats.avgDepth} km\n\n`; } content += "RAW EVENT LOG\n"; content += "--------------------------------------------------------\n"; content += " # | Time/Date\t\t| Mag\t| Depth(km)\t| Location/Notes\n"; content += "--------------------------------------------------------\n"; data.log.forEach((event, index) => { content += `${(index + 1).toString().padStart(2)} | ${event.time}\t| ${event.magnitude.toFixed(1)}\t| ${event.depth_km.toFixed(1)}\t\t| ${event.location}\n`; }); const blob = new Blob([content], { type: 'text/plain;charset=utf-8' }); const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = `${data.setup.project.replace(/ /g, '_')}_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 log table const data = getReportData(); const stats = data.stats; const margin = 10; const pageWidth = doc.internal.pageSize.getWidth(); const usableWidth = pageWidth - margin * 2; let yPos = 15; // --- Helper for wrapping text const addSectionTitle = (title) => { doc.setFontSize(14); doc.setFont(undefined, 'bold'); doc.setTextColor(142, 68, 173); // Purple doc.text(title, margin, yPos); doc.setDrawColor(224, 224, 224); doc.line(margin, yPos + 1, pageWidth - margin, yPos + 1); yPos += 6; }; // 1. Header doc.setFontSize(20); doc.setFont(undefined, 'bold'); doc.setTextColor(44, 62, 80); doc.text(`Seismic Data Log: ${data.setup.project}`, pageWidth / 2, yPos, { align: 'center' }); yPos += 8; doc.setFontSize(10); doc.setFont(undefined, 'normal'); doc.setTextColor(108, 117, 125); doc.text(`Site ID: ${data.setup.site} | Operator: ${data.setup.operator}`, pageWidth / 2, yPos, { align: 'center' }); yPos += 8; // 2. Metadata addSectionTitle("1. Project Metadata"); doc.setFontSize(10); doc.setTextColor(52, 73, 94); doc.text(`Period: ${data.setup.start} to ${data.setup.end}`, margin, yPos); yPos += 5; const notesLines = doc.splitTextToSize(`Setup Notes: ${data.setup.notes}`, usableWidth); doc.text(notesLines, margin, yPos); yPos += (notesLines.length * 4) + 5; // 3. Summary Statistics if (stats) { addSectionTitle("2. Summary Statistics"); const statsHead = [['Total Events', 'Avg. Mag (M)', 'Max Mag (M)', 'Min Mag (M)', 'Avg. Depth (km)', 'Max Depth (km)']]; const statsBody = [[ stats.count, stats.avgMag, stats.maxMag, stats.minMag, stats.avgDepth, stats.maxDepth ]]; doc.autoTable({ startY: yPos, head: statsHead, body: statsBody, theme: 'grid', styles: { fontSize: 10, cellPadding: 3, textColor: [52, 73, 94] }, headStyles: { fillColor: [230, 230, 230], textColor: [44, 62, 80] }, margin: { left: margin, right: margin } }); yPos = doc.autoTable.previous.finalY + 10; } // 4. Raw Log Table addSectionTitle("3. Raw Event Log"); const logHead = [['#', 'Time/Date', 'Magnitude', 'Depth (km)', 'Location/Notes']]; const logBody = data.log.map((event, index) => [ index + 1, event.time, event.magnitude.toFixed(1), event.depth_km.toFixed(1), event.location ]); doc.autoTable({ startY: yPos, head: logHead, body: logBody, theme: 'grid', styles: { fontSize: 9, cellPadding: 2, textColor: [52, 73, 94], valign: 'top' }, headStyles: { fillColor: [142, 68, 173], textColor: [255, 255, 255] }, columnStyles: { 0: { cellWidth: 8 }, 1: { cellWidth: 35 }, 2: { cellWidth: 20 }, 3: { cellWidth: 20 }, 4: { cellWidth: 'auto' } }, margin: { left: margin, right: margin } }); doc.save(`${data.setup.project.replace(/ /g, '_')}_seismic_report.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 2 Actions (Add, Remove, Edit) newEventInputs.addBtn.addEventListener('click', addEvent); eventsTbody.addEventListener('click', (e) => { if (e.target.dataset.removeId) { removeEvent(parseInt(e.target.dataset.removeId)); } }); eventsTbody.addEventListener('blur', (e) => { if (e.target.tagName === 'TD' && e.target.isContentEditable) { const id = parseInt(e.target.dataset.id); const field = e.target.dataset.field; updateEvent(id, field, e.target.textContent); } }, true); // Tab 3 Actions refreshBtn.addEventListener('click', calculateAndRenderStats); refreshBtn.addEventListener('click', generatePreview); downloadPdfBtn.addEventListener('click', downloadPDF); downloadTxtBtn.addEventListener('click', downloadTxt); // --- Initialization --- newEventInputs.time.value = new Date().toISOString().slice(0, 19).replace('T', ' '); showTab(1); // Set initial state });
Scroll to Top