Pollution Source Tracking Sheet Generator

Pollution Source Tracking Sheet Generator

This is your generated tracking sheet. You can edit the content directly. Configure details in the 'Configuration' tab.


Project: ${projectName} | Location: ${location}

Investigator: ${investigator} | Date: ${date}

${tableRows}
Source ID Type Description Location Severity Notes
`; sheetOutput.innerHTML = html; } async function downloadPDF() { if (!sheetOutput.innerText.trim() || sheetOutput.innerText.includes("will be generated")) { alert("Please generate a sheet before downloading."); return; } const { jsPDF } = window.jspdf; const pdf = new jsPDF('p', 'pt', 'a4'); pdfButton.innerText = 'Generating...'; pdfButton.disabled = true; try { // Temporarily make the output uneditable for a cleaner capture sheetOutput.setAttribute('contenteditable', 'false'); const canvas = await html2canvas(sheetOutput, { scale: 2 }); // Restore edibility sheetOutput.setAttribute('contenteditable', 'true'); const imgData = canvas.toDataURL('image/png'); const imgProps = pdf.getImageProperties(imgData); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width; pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight); const fileName = (projectNameInput.value || 'Pollution_Sheet').replace(/[^a-z0-9]/gi, '_').toLowerCase(); pdf.save(`${fileName}.pdf`); } catch (error) { console.error("PSTG TOOL: PDF Generation Error - ", error); alert("An error occurred while generating the PDF."); } finally { pdfButton.innerText = 'Download Sheet (PDF)'; pdfButton.disabled = false; } } // --- Event Listeners --- addSourceButton.addEventListener('click', () => addSource()); nextButton.addEventListener('click', () => { if (currentTabIndex === 1) { // On Config tab generateSheet(); pstg_showTab(0); } else { // On Dashboard tab pstg_showTab(1); } }); prevButton.addEventListener('click', () => { if (currentTabIndex > 0) { generateSheet(); // Update sheet before going back pstg_showTab(currentTabIndex - 1); } }); pdfButton.addEventListener('click', downloadPDF); // --- Initial Setup --- dateInput.valueAsDate = new Date(); addSource({ type: 'Water', severity: 'High', location: 'South Platte River, Confluence Park', description: 'Visible discoloration and oily sheen observed downstream from industrial outfall pipe. Potential heavy metal contamination.' }); addSource({ type: 'Air', severity: 'Medium', location: 'I-25 & Colfax Ave Intersection', description: 'High concentration of vehicle emissions during peak traffic hours. Noticeable smog and odor.' }); generateSheet(); pstg_showTab(0); }); // --- End of DOMContentLoaded --- // --- Global Functions for onclick --- window.pstg_openTab = function(evt, tabName) { const tabs = ['pstg-tab-dashboard', 'pstg-tab-config']; const newIndex = tabs.indexOf(tabName); if(newIndex === -1) return; // To avoid duplicating logic, we simulate a click on our nav buttons const currentTabIndex = Array.from(document.querySelectorAll('.pstg-tab-button')).findIndex(btn => btn.classList.contains('pstg-active')); if (newIndex > currentTabIndex) { document.getElementById('pstg-next-button').click(); } else if (newIndex < currentTabIndex) { document.getElementById('pstg-prev-button').click(); } }; })();
Scroll to Top