`;
pdfContainer.innerHTML = pdfHtml;
document.body.appendChild(pdfContainer);
window.html2canvas(pdfContainer, { scale: 2 }).then(canvas => {
const imgData = canvas.toDataURL('image/png');
const { jsPDF } = window.jspdf;
const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' });
const pdfWidth = pdf.internal.pageSize.getWidth();
const contentWidth = pdfWidth - 80;
const imgHeight = canvas.height * contentWidth / canvas.width;
pdf.addImage(imgData, 'PNG', 40, 40, contentWidth, imgHeight);
pdf.save('First_Aid_Checklist.pdf');
document.body.removeChild(pdfContainer);
});
};
initialize();
});
function switchTab(tabId) {
const tabs = ['profile', 'activities', 'checklist'];
const buttons = {
next: document.getElementById('next-btn'),
prev: document.getElementById('prev-btn'),
generate: document.getElementById('generate-checklist-btn')
};
tabs.forEach(id => {
document.getElementById(`${id}-tab`).style.display = (id === tabId) ? 'block' : 'none';
document.getElementById(`tab-${id}-btn`).classList.toggle('active', id === tabId);
});
buttons.prev.disabled = (tabId === 'profile');
buttons.next.style.display = (tabId === 'activities' || tabId === 'checklist') ? 'none' : 'inline-block';
buttons.generate.style.display = (tabId === 'activities') ? 'inline-block' : 'none';
if (tabId === 'checklist') {
document.getElementById('tab-checklist-btn').disabled = false;
}
}
function navigateTabs(direction) {
const currentActive = document.querySelector('.tab-btn.active');
const tabs = ['profile', 'activities', 'checklist'];
let currentIndex = tabs.findIndex(t => `tab-${t}-btn` === currentActive.id);
if (direction === 'next' && currentIndex < tabs.length - 1) {
switchTab(tabs[currentIndex + 1]);
} else if (direction === 'prev' && currentIndex > 0) {
switchTab(tabs[currentIndex - 1]);
}
}
