Health & Safety Law Compliance Checker
Assess your workplace compliance based on general OSHA standards.
Assessment Information
Generating your PDF report, please wait...
Date: ${formattedDate}
`; let totalYes = 0, totalNo = 0, totalApplicable = 0; let questionIndex = 0; Object.keys(checklistData).forEach(category => { reportHTML += `
${category}
`; reportHTML += '| ${questionText} | ${answer} |
Summary
${score}%
Compliance Score
${totalYes}
Compliant Items
${totalNo}
Non-Compliant Items
Note: This checklist is a general guide based on common OSHA standards and is not a substitute for legal advice. A 'No' answer indicates an area that may require immediate attention to ensure compliance.
`; reportPreview.innerHTML = summaryHTML + reportHTML; }; // --- PDF Download Logic --- downloadPdfBtn.addEventListener('click', async () => { if (!window.jspdf || !window.html2canvas) { alert('PDF generation library is not loaded.'); return; } loader.classList.remove('hidden'); downloadPdfBtn.disabled = true; try { const { jsPDF } = window.jspdf; const canvas = await html2canvas(reportPreview, { scale: 2 }); const pdf = new jsPDF('p', 'mm', 'a4'); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgHeight = canvas.height * pdfWidth / canvas.width; let heightLeft = imgHeight; let position = 0; pdf.addImage(canvas.toDataURL('image/png'), 'PNG', 0, position, pdfWidth, imgHeight); heightLeft -= pdfHeight; while (heightLeft > 0) { position = heightLeft - imgHeight; pdf.addPage(); pdf.addImage(canvas.toDataURL('image/png'), 'PNG', 0, position, pdfWidth, imgHeight); heightLeft -= pdfHeight; } pdf.save('Health_Safety_Compliance_Report.pdf'); } catch (error) { console.error("PDF Generation Error:", error); alert("An error occurred generating the PDF."); } finally { loader.classList.add('hidden'); downloadPdfBtn.disabled = false; } }); // --- Event Listeners for Navigation --- window.changeTab = (tabIndex) => { currentTab = tabIndex; updateTabUI(); }; prevBtn.addEventListener('click', () => { if (currentTab > 0) { currentTab--; updateTabUI(); } }); nextBtn.addEventListener('click', () => { if (currentTab < tabs.length - 1) { currentTab++; updateTabUI(); } }); // --- Final Setup --- populateChecklists(); updateTabUI(); });