Biodiversity Study Sheet Generator
Field Observation Log and Metric Summary
Species Richness (S):
0
BIODIVERSITY FIELD STUDY LOG
Project: Project Name | Date: ---
Habitat: N/A | Observer: N/A
Summary Metrics
Total Individuals: 0
Species Richness (S): 0
Total Observations: 0
Detailed Species Log
| Time | Species (Common / Scientific) | Count | Specific Location / Sub-Habitat | Notes / Behavior |
|---|
Generated by Biodiversity Study Sheet Generator. Data recorded must adhere to standard taxonomic practice.
Project & Site Context
Log a New Sighting
Enter the data for a single observation event (time and specific location are key).
Current Log Entries
Log is empty.
"; return; } const sortedObs = [...wloData.observations].sort((a, b) => a.time.localeCompare(b.time)); sortedObs.forEach(obs => { const row = document.createElement('div'); row.className = 'bio-obs-row'; row.innerHTML = `
[${obs.time}] ${obs.species} (Qty: ${obs.count})
`;
outputs.obsListEditor.appendChild(row);
});
}
// --- 5. EVENT LISTENERS & ACTIONS ---
function attachListeners() {
// Meta Inputs
const metaInputs = Object.values(inputs).filter(i => !i.id.includes('inp-'));
metaInputs.forEach(inp => inp.addEventListener('input', renderAll));
// Add Observation Button
document.getElementById('btn-add-obs').addEventListener('click', addObservation);
}
function addObservation() {
const time = inputs.time.value;
const species = inputs.species.value.trim();
const count = parseInt(inputs.count.value) || 0;
const location = inputs.location.value.trim();
const notes = inputs.notes.value.trim();
if (!time || !species || count <= 0) {
alert("Time, Species, and Count (> 0) are required.");
return;
}
const newObs = {
id: Date.now(),
time: time,
species: species,
count: count,
location: location || "N/A",
notes: notes || "N/A"
};
wloData.observations.push(newObs);
// Clear inputs
inputs.species.value = "";
inputs.count.value = "1";
inputs.location.value = "";
inputs.notes.value = "";
renderAll();
}
window.removeObservation = function(id) {
if(confirm("Remove this observation entry?")) {
wloData.observations = wloData.observations.filter(obs => obs.id !== id);
renderAll();
}
};
// --- 6. TAB NAVIGATION ---
window.bioSwitchTab = function(tabId) {
document.querySelectorAll('.bio-tab-pane').forEach(p => p.classList.remove('active'));
document.querySelectorAll('.bio-tab-btn').forEach(b => b.classList.remove('active'));
document.getElementById(tabId).classList.add('active');
document.querySelector(`.bio-tab-btn[data-tab="${tabId}"]`).classList.add('active');
document.getElementById('biodiversity-tool').scrollIntoView({behavior: 'smooth'});
};
document.querySelectorAll('.bio-tab-btn').forEach(btn => {
btn.addEventListener('click', function() { bioSwitchTab(this.dataset.tab); });
});
// --- 7. PDF EXPORT ---
const btnDown = document.getElementById('bio-download-btn');
if(btnDown) {
btnDown.addEventListener('click', function() {
renderAll();
const element = document.getElementById('bio-render-area');
const filename = (inputs.projectName.value || 'Biodiversity_Study').replace(/\s+/g,'_');
const opt = {
margin: 0.4,
filename: `${filename}_Field_Log.pdf`,
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2, useCORS: true },
jsPDF: { unit: 'in', format: 'letter', orientation: 'landscape' } // Landscape for wide tables
};
const origText = btnDown.innerText;
btnDown.innerText = "Generating Study Sheet...";
html2pdf().set(opt).from(element).save().then(() => {
document.getElementById('bio-download-btn').innerText = origText;
});
});
}
// Start
init();
});
