Health & Safety Law Compliance Checker

Health & Safety Law Compliance Checker

Assess your workplace compliance based on general OSHA standards.

Assessment Information

Date: ${formattedDate}


`; let totalYes = 0, totalNo = 0, totalApplicable = 0; let questionIndex = 0; Object.keys(checklistData).forEach(category => { reportHTML += `

${category}

`; reportHTML += ''; checklistData[category].forEach(questionText => { const answer = document.querySelector(`input[name="q${questionIndex}"]:checked`).value; const bgColor = answer === 'No' ? '#fee2e2' : (answer === 'Yes' ? '#dcfce7' : '#f1f5f9'); reportHTML += ` `; if (answer === 'Yes') totalYes++; if (answer === 'No') totalNo++; if (answer !== 'N/A') totalApplicable++; questionIndex++; }); reportHTML += '
${questionText} ${answer}
'; }); const score = totalApplicable > 0 ? ((totalYes / totalApplicable) * 100).toFixed(0) : 100; const scoreColor = score >= 80 ? '#198754' : (score >= 50 ? '#FFC107' : '#DC3545'); let summaryHTML = `

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(); });
Scroll to Top