Archaeological Stratigraphy Diagrammer
Define layers, visualize composition, and log associated finds and contexts.
1. Site & Trench Details
2. Stratum Definition (Add Top to Bottom)
Stratigraphic Column List:
Archaeological Stratigraphic Log
Site/Unit: | Log Date:
Stratigraphic Column (Visual)
Context Log & Associated Finds
| Context ID | Depth Range (m) | Composition | Key Finds |
|---|
No layers defined. Start by adding Context ID 101.
'; return; } strata.forEach(s => { const item = document.createElement('div'); item.className = 'flex justify-between items-center bg-white border-l-4 border-gray-300 p-2 rounded'; item.style.borderColor = s.color; item.innerHTML = ` ${s.contextId} Depth: ${s.depth}m ${escapeHtml(s.description)} `; list.appendChild(item); }); } // --- Preview Generation --- function asdtUpdatePreview() { // Metadata const siteId = document.getElementById('asdt-site-id').value || "Unit ID Missing"; const dateRaw = document.getElementById('asdt-date').value; const date = dateRaw ? new Date(dateRaw).toLocaleDateString('en-US') : "N/A"; const datum = document.getElementById('asdt-datum').value || "0.00 m"; // Update Metadata Display document.getElementById('disp-site-id').textContent = siteId; document.getElementById('disp-date').textContent = date; // 1. Render Visualization Column const vizDiv = document.getElementById('asdt-diagram-output'); const logTbody = document.getElementById('asdt-log-tbody'); vizDiv.innerHTML = `GROUND LEVEL (Z = ${datum})
`; logTbody.innerHTML = ''; if (strata.length === 0) { vizDiv.innerHTML += 'No layers defined.
'; return; } let previousDepth = 0; strata.forEach(s => { const depthRange = `${previousDepth.toFixed(2)}m - ${s.depth.toFixed(2)}m`; const heightFactor = (s.depth - previousDepth) * 100; // Visual scaling factor // a. Visualization Layer const layer = document.createElement('div'); layer.className = 'asdt-stratum'; layer.style.setProperty('--stratum-color', s.color); layer.style.minHeight = Math.max(heightFactor, 50) + 'px'; // Ensure visibility layer.innerHTML = ` ${s.contextId} ${escapeHtml(s.description)} `; vizDiv.appendChild(layer); // b. Log Table Row const tr = document.createElement('tr'); tr.innerHTML = `STERILE SUBSOIL
`; }; // --- PDF Download --- window.asdtDownloadPDF = function() { // Ensure preview is up to date asdtUpdatePreview(); const element = document.getElementById('asdt-print-area'); const siteId = document.getElementById('asdt-site-id').value.split('/')[0].trim() || "Stratigraphy_Report"; document.body.classList.add('asdt-generating-pdf'); const opt = { margin: [0.75, 0.75], filename: `${siteId.replace(/\s+/g, '_')}_Stratigraphy_Report.pdf`, image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, useCORS: true }, jsPDF: { unit: 'in', format: 'letter', orientation: 'landscape' } }; html2pdf().set(opt).from(element).save().then(() => { document.body.classList.remove('asdt-generating-pdf'); }); }; // Utility: HTML Escape function escapeHtml(text) { if (!text) return ''; return text.replace(/[&<>"']/g, function(m) { switch (m) { case '&': return '&'; case '<': return '<'; case '>': return '>'; case '"': return '"'; case "'": return '''; default: return m; } }); }