Labor Law Compliance Checker

Labor Law Compliance Checker

Assess your practices against key U.S. labor law standards.

Compliance Checklist

${q.text}

`; categoryDiv.appendChild(card); }); checklistContainer.appendChild(categoryDiv); }); }; const calculateAndRenderReport = () => { const formData = new FormData(complianceForm); const answers = Object.fromEntries(formData.entries()); let totalCompliant = 0; let totalApplicable = 0; const reportDetailsContainer = document.getElementById('reportDetails'); reportDetailsContainer.innerHTML = ''; Object.keys(checklistData).forEach(category => { let categoryHTML = `

${category}

    `; const questions = checklistData[category]; questions.forEach(q => { const answer = answers[q.id]; let isCompliant = false; if (answer !== 'na') { totalApplicable++; if (answer === q.compliant_answer) { totalCompliant++; isCompliant = true; } } let statusIcon = answer === 'na' ? '⚪️' : (isCompliant ? '🟢' : '🔴'); let statusText = answer === 'na' ? 'N/A' : (isCompliant ? 'Compliant' : 'Review Needed'); categoryHTML += `
  • ${statusIcon} ${q.text} (${statusText})
  • `; }); categoryHTML += `
`; reportDetailsContainer.innerHTML += categoryHTML; }); const compliancePercentage = totalApplicable > 0 ? Math.round((totalCompliant / totalApplicable) * 100) : 100; let summaryColor = 'text-green-600'; let summaryText = 'Strong Compliance'; if (compliancePercentage < 70) { summaryColor = 'text-red-600'; summaryText = 'Action Required'; } else if (compliancePercentage < 90) { summaryColor = 'text-yellow-600'; summaryText = 'Areas for Improvement'; } document.getElementById('reportSummary').innerHTML = `

${compliancePercentage}%

${summaryText}

Based on ${totalCompliant} compliant answers out of ${totalApplicable} applicable items.

`; }; // === Tab Navigation Logic === const validateChecklist = () => { const allQuestions = Object.values(checklistData).flat(); for (const q of allQuestions) { const radios = document.getElementsByName(q.id); if (![...radios].some(r => r.checked)) { radios[0].closest('.question-card').classList.add('border-2', 'border-red-500'); // Scroll to the invalid element radios[0].closest('.question-card').scrollIntoView({ behavior: 'smooth', block: 'center' }); return false; } radios[0].closest('.question-card').classList.remove('border-2', 'border-red-500'); } return true; }; const updateTabs = (newTab) => { currentTab = newTab; tabContents.forEach((content, index) => { content.classList.toggle('hidden', index !== currentTab); tabButtons[index].classList.toggle('active', index === currentTab); }); prevBtn.disabled = currentTab === 0; nextBtn.textContent = currentTab === 0 ? 'Generate Report' : 'Finish'; nextBtn.disabled = currentTab === tabButtons.length - 1; if (currentTab === 1) { // Report Tab calculateAndRenderReport(); } }; prevBtn.addEventListener('click', () => { if (currentTab > 0) updateTabs(0); }); nextBtn.addEventListener('click', () => { if (currentTab === 0) { if (!validateChecklist()) return; updateTabs(1); } }); // === PDF Download Logic === downloadPdfBtn.addEventListener('click', () => { const { jsPDF } = window.jspdf; const pdfContent = document.getElementById('pdfContent'); html2canvas(pdfContent, { scale: 2 }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const canvasAspectRatio = canvas.width / canvas.height; const margin = 40; let imgFinalWidth = pdfWidth - (margin * 2); let imgFinalHeight = imgFinalWidth / canvasAspectRatio; if (imgFinalHeight > pdfHeight - (margin * 2)) { imgFinalHeight = pdfHeight - (margin * 2); imgFinalWidth = imgFinalHeight * canvasAspectRatio; } const x = (pdfWidth - imgFinalWidth) / 2; const y = margin; pdf.addImage(imgData, 'PNG', x, y, imgFinalWidth, imgFinalHeight); pdf.save('Labor_Law_Compliance_Report.pdf'); }); }); // Initial setup calls renderChecklist(); });
Scroll to Top