Ergonomic Workspace Assessment Tool

Ergonomic Workspace Assessment

Analyze your setup and get personalized recommendations in minutes.

How to Use This Tool

This tool will guide you through a quick assessment of your primary workspace. For each section, answer the questions based on your typical posture and setup.

The goal is to identify areas for improvement to enhance your comfort and reduce the risk of strain. Let's begin by assessing your chair.

${item.question}

`; }); form.innerHTML = html; }); } // --- IV. EVENT HANDLING --- nav.next.addEventListener('click', () => changeStep(1)); nav.prev.addEventListener('click', () => changeStep(-1)); document.getElementById('download-pdf-btn').addEventListener('click', generatePDF); // --- V. LOGIC & UI FUNCTIONS --- function changeStep(direction) { if (direction > 0 && !validateStep(currentStep)) { alert('Please answer all questions in this section.'); return; } if (direction > 0) collectStepData(currentStep); currentStep += direction; updateUI(); } function validateStep(step) { if (step === 0 || step === 4) return true; // No validation for start/report const section = Object.keys(assessmentData)[step - 1]; const form = document.getElementById(`${section}-form`); const questions = assessmentData[section]; return questions.every(q => form.elements[q.id].value !== ''); } function collectStepData(step) { if (step === 0 || step === 4) return; const section = Object.keys(assessmentData)[step - 1]; const form = document.getElementById(`${section}-form`); assessmentData[section].forEach(q => { userAnswers[q.id] = form.elements[q.id].value; }); } function updateUI() { for (let i = 0; i < totalSteps; i++) { document.getElementById(`content-panel-${i}`).classList.toggle('hidden', i !== currentStep); const tabBtn = document.getElementById(`tab-btn-${i}`); tabBtn.classList.remove('tab-active', 'tab-inactive', 'tab-complete'); if (i === currentStep) tabBtn.classList.add('tab-active'); else if (i < currentStep) tabBtn.classList.add('tab-complete'); else tabBtn.classList.add('tab-inactive'); } nav.prev.disabled = currentStep === 0; nav.next.disabled = currentStep === totalSteps - 1; nav.next.textContent = currentStep === totalSteps - 2 ? 'Generate Report' : 'Next'; if (currentStep === totalSteps - 1) { generateAndDisplayReport(); } } function generateAndDisplayReport() { const reportContainer = document.getElementById('report-output'); let html = '

Your Ergonomic Report

'; Object.keys(assessmentData).forEach(section => { const questions = assessmentData[section]; const score = questions.filter(q => userAnswers[q.id] === 'yes').length; const total = questions.length; const recommendations = questions.filter(q => userAnswers[q.id] === 'no').map(q => q.recommendation); html += createReportCard(section, score, total, recommendations); }); html += '
'; reportContainer.innerHTML = html; } function createReportCard(section, score, total, recommendations) { const percentage = (score / total) * 100; let color, ratingText; if (percentage >= 80) { color = 'green'; ratingText = 'Excellent'; } else if (percentage >= 50) { color = 'yellow'; ratingText = 'Good'; } else { color = 'red'; ratingText = 'Needs Improvement'; } const colorMap = { green: 'green', yellow: 'amber', red: 'red' }; const bgColor = `bg-${colorMap[color]}-100`; const textColor = `text-${colorMap[color]}-700`; const progressColor = `bg-${colorMap[color]}-500`; let recommendationsHTML = recommendations.length > 0 ? `

Recommendations:

    ${recommendations.map(r => `
  • ${r}
  • `).join('')}
` : `

Your ${section} setup looks great! No immediate recommendations.

`; return `

${section} Assessment

${ratingText}
${recommendationsHTML}
`; } // --- VI. PDF GENERATION --- function generatePDF() { const reportContainer = document.createElement('div'); reportContainer.id = 'pdf-report-container'; reportContainer.innerHTML = generatePdfReportHTML(); document.body.appendChild(reportContainer); html2canvas(reportContainer, { scale: 2, useCORS: true }).then(canvas => { const { jsPDF } = window.jspdf; const doc = new jsPDF('p', 'mm', 'a4'); const imgData = canvas.toDataURL('image/png'); const pdfWidth = doc.internal.pageSize.getWidth(); const imgProps = doc.getImageProperties(imgData); const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width; doc.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight); doc.save('Ergonomic-Workspace-Report.pdf'); document.body.removeChild(reportContainer); }).catch(err => { console.error("PDF generation error:", err); document.body.removeChild(reportContainer); }); } function generatePdfReportHTML() { const date = new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); const colorHex = { green: '#16A34A', yellow: '#D97706', red: '#DC2626' }; let reportHTML = ''; Object.keys(assessmentData).forEach(section => { const questions = assessmentData[section]; const score = questions.filter(q => userAnswers[q.id] === 'yes').length; const total = questions.length; const percentage = (score / total) * 100; const recommendations = questions.filter(q => userAnswers[q.id] === 'no').map(q => q.recommendation); let ratingColor, ratingText; if (percentage >= 80) { ratingColor = colorHex.green; ratingText = 'Excellent'; } else if (percentage >= 50) { ratingColor = colorHex.yellow; ratingText = 'Good'; } else { ratingColor = colorHex.red; ratingText = 'Needs Improvement'; } let recommendationsHTML = recommendations.length > 0 ? `
    ${recommendations.map(r => `
  • ${r}
  • `).join('')}
` : `

No issues found. Your setup in this area is good.

`; reportHTML += `

${section} Assessment

${ratingText}

Actionable Recommendations:

${recommendationsHTML}
`; }); return `

Ergonomic Workspace Report

Assessment Date: ${date}

${reportHTML}
Disclaimer: This tool provides general ergonomic suggestions and is not a substitute for a professional medical or ergonomic consultation. If you experience pain or discomfort, please consult a qualified professional.
`; } // --- VII. SCRIPT EXECUTION START --- initializeQuestions(); updateUI(); });
Scroll to Top