Pilih Warna Tema

`;// Inject advertisements in precise locations if (q.id === 10) { htmlContent += generateAdSlotHTML(1, "AD SLOT 2"); } else if (q.id === 25) { htmlContent += generateAdSlotHTML(2, "AD SLOT 3"); } else if (q.id === 35) { htmlContent += generateAdSlotHTML(3, "AD SLOT 4"); } });questionsContainer.innerHTML = htmlContent; }// Initialize setup on window load window.onload = function() { initQuestions(); updateProgress(); };// Interactive live update logic for the progress indicators function handleAnswerChange(qid) { // Remove error state borders from this card if any const card = document.getElementById(`card-q-${qid}`); if (card) { card.classList.remove('border-rose-300', 'bg-rose-50/20'); } updateProgress(); }// Return number of answered and next unanswered ID function getProgressInfo() { let answeredCount = 0; let nextUnansweredId = null;for (let i = 1; i <= 40; i++) { const inputs = document.getElementsByName(`question-${i}`); let hasValue = false; for (let input of inputs) { if (input.checked) { hasValue = true; break; } } if (hasValue) { answeredCount++; } else if (nextUnansweredId === null) { nextUnansweredId = i; } }return { answeredCount, nextUnansweredId }; }// Update the live Progress Bar function updateProgress() { const { answeredCount } = getProgressInfo(); const pct = Math.round((answeredCount / 40) * 100); document.getElementById('progressPctText').innerText = `${pct}%`; document.getElementById('progressFractionText').innerText = `${answeredCount} of 40 completed`; document.getElementById('progressBar').style.width = `${pct}%`; }// Quick Jump to Unanswered Button logic (Mobile-friendly UX helper) document.getElementById('jumpToUnansweredBtn').addEventListener('click', () => { const { nextUnansweredId } = getProgressInfo(); if (nextUnansweredId !== null) { const card = document.getElementById(`card-q-${nextUnansweredId}`); if (card) { card.scrollIntoView({ behavior: 'smooth', block: 'center' }); // Give subtle flash effect to draw eye card.classList.add('ring-2', 'ring-teal-500/60'); setTimeout(() => { card.classList.remove('ring-2', 'ring-teal-500/60'); }, 1000); } } else { // If all are answered, jump to Submit action block document.getElementById('submitAssessmentBtn').scrollIntoView({ behavior: 'smooth', block: 'center' }); } });// Scoring & Category Analysis System document.getElementById('submitAssessmentBtn').addEventListener('click', () => { const validationWarning = document.getElementById('validationWarning'); validationWarning.classList.add('hidden');// Gather all responses let allAnswered = true; const answers = []; let uncompletedQuestionId = null;for (let i = 1; i <= 40; i++) { const inputs = document.getElementsByName(`question-${i}`); let selectedVal = null; for (let input of inputs) { if (input.checked) { selectedVal = parseInt(input.value); break; } }if (selectedVal === null) { allAnswered = false; if (uncompletedQuestionId === null) { uncompletedQuestionId = i; } // Highlight the unanswered card const card = document.getElementById(`card-q-${i}`); if (card) { card.classList.add('border-rose-300', 'bg-rose-50/20'); } } else { const qData = QUESTION_BANK.find(q => q.id === i); answers.push({ id: i, question: qData.text, label: qData.label, category: qData.cat, value: selectedVal }); } }if (!allAnswered) { validationWarning.classList.remove('hidden'); // Scroll to the first missed question if (uncompletedQuestionId !== null) { const card = document.getElementById(`card-q-${uncompletedQuestionId}`); if (card) { card.scrollIntoView({ behavior: 'smooth', block: 'center' }); } } return; }// Calculation engines calculateAndDisplayResults(answers); });function calculateAndDisplayResults(answers) { // Compute cumulative totals let totalScore = 0; const categorySums = { "Emotional Exhaustion": 0, "Physical Fatigue": 0, "Motivation & Engagement": 0, "Stress & Overload": 0, "Work-Life Balance": 0 };answers.forEach(ans => { totalScore += ans.value; categorySums[ans.category] += ans.value; });// Set result profile let profileLabel = ""; let profileFeedback = ""; let accentColorClass = "text-emerald-700 bg-emerald-50";if (totalScore <= 32) { profileLabel = "Low Signs of Burnout"; profileFeedback = "You currently show relatively few signs commonly associated with burnout. Maintaining healthy routines, consistent restorative rest, and structured work-life boundaries can continue to support your overall wellness profile."; accentColorClass = "text-emerald-700"; } else if (totalScore <= 64) { profileLabel = "Mild Stress Indicators"; profileFeedback = "You may be experiencing occasional stress or physical fatigue. Your overall score indicates manageable strain, but it is highly beneficial to monitor your daily workload, allocate targeted recovery time, and keep boundaries firm."; accentColorClass = "text-teal-700"; } else if (totalScore <= 96) { profileLabel = "Moderate Burnout Indicators"; profileFeedback = "Your responses suggest several common signs associated with ongoing, chronic stress and fatigue. Prioritizing rest, active screen-free relaxation, self-care routines, and re-negotiating task structures may prevent escalation."; accentColorClass = "text-amber-700"; } else if (totalScore <= 128) { profileLabel = "High Burnout Risk Indicators"; profileFeedback = "Your responses suggest a higher level of stress-related strain across multiple wellness areas. It is highly recommended to review your current commitments, delegate tasks, build structured decompression loops, and seek supportive professional channels."; accentColorClass = "text-orange-700"; } else { profileLabel = "Very High Burnout Risk Indicators"; profileFeedback = "Your responses suggest substantial levels of chronic stress, exhaustion, and boundary strain. If these feelings are persistent, severe, or interfere with daily life, consider consulting with a therapist, counselor, or qualified healthcare professional to build active recovery plans."; accentColorClass = "text-rose-700"; }// Update Header Score Text and progress ring document.getElementById('scoreTextValue').innerText = totalScore; // Render circle svg ring (max score is 160, circle dash length is 377) const ringOffset = 377 - ((totalScore / 160) * 377); document.getElementById('scoreRingProgress').setAttribute('stroke-dashoffset', ringOffset); // Set dynamic text for category const severityEl = document.getElementById('resultSeverityCategory'); severityEl.className = `font-display font-extrabold text-xl sm:text-2xl flex items-center gap-2 ${accentColorClass}`; severityEl.innerHTML = ` ${profileLabel}`; // Delay spinning animation replace with steady alert badge icon setTimeout(() => { let badgeIcon = "fa-circle-check"; if (totalScore > 96) badgeIcon = "fa-circle-exclamation"; severityEl.innerHTML = ` ${profileLabel}`; }, 800);document.getElementById('resultFeedbackText').innerText = profileFeedback;// Category breakdowns cards const categoryGrid = document.getElementById('categoryGrid'); categoryGrid.innerHTML = ''; // Reset GridObject.keys(categorySums).forEach(cat => { const rawSum = categorySums[cat]; const percentageVal = Math.round((rawSum / 32) * 100); // 8 questions * 4 max score = 32 max // Determine Category Accent Color Theme let barColor = "bg-teal-500"; let textColor = "text-teal-700"; let iconClass = "fa-spa"; if (cat === "Emotional Exhaustion") { barColor = "bg-rose-500"; textColor = "text-rose-700"; iconClass = "fa-heart-crack"; } else if (cat === "Physical Fatigue") { barColor = "bg-amber-500"; textColor = "text-amber-700"; iconClass = "fa-battery-quarter"; } else if (cat === "Motivation & Engagement") { barColor = "bg-blue-500"; textColor = "text-blue-700"; iconClass = "fa-gauge-high"; } else if (cat === "Stress & Overload") { barColor = "bg-indigo-500"; textColor = "text-indigo-700"; iconClass = "fa-bolt"; } else if (cat === "Work-Life Balance") { barColor = "bg-emerald-500"; textColor = "text-emerald-700"; iconClass = "fa-scale-balanced"; }const catCard = `
${rawSum}/32

${cat}

${percentageVal}% Indicator
`; categoryGrid.innerHTML += catCard; });// Build Personalized Answer Review Explanation Section const reviewContainer = document.getElementById('answerReviewList'); reviewContainer.innerHTML = ''; // Clear review listanswers.forEach(ans => { // Focus primarily on high-frequency questions (scores 2, 3, 4) to highlight improvement opportunities let optLabel = "Never"; let pillClass = "bg-slate-100 text-slate-600"; if (ans.value === 1) { optLabel = "Rarely"; pillClass = "bg-slate-50 text-slate-600 border border-slate-100"; } else if (ans.value === 2) { optLabel = "Sometimes"; pillClass = "bg-amber-50 text-amber-700 border border-amber-100"; } else if (ans.value === 3) { optLabel = "Often"; pillClass = "bg-orange-50 text-orange-700 border border-orange-150"; } else if (ans.value === 4) { optLabel = "Very Often"; pillClass = "bg-rose-50 text-rose-700 border border-rose-150"; }// Get dynamic category explanation range let expText = ""; const catRange = EXPLANATION_MATRIX[ans.category]; if (ans.value <= 1) expText = catRange.low; else if (ans.value === 2) expText = catRange.medium; else expText = catRange.high;const reviewItem = `
Q-${ans.id} (${ans.category})

${ans.question}

Reflection Insight: ${expText}

Answered: ${optLabel}
`; reviewContainer.innerHTML += reviewItem; });// Unhide results container const resultsSection = document.getElementById('resultsSection'); resultsSection.classList.remove('hidden'); // Scroll to results cleanly setTimeout(() => { resultsSection.scrollIntoView({ behavior: 'smooth', block: 'start' }); }, 150);// Set up Copy Raw Summary action document.getElementById('copySummaryBtn').onclick = () => { const rawSummaryText = `Burnout & Stress Assessment Tool Summary: ------------------------------------------ Total Score: ${totalScore} / 160 Severity: ${profileLabel}Category Breakdown: - Emotional Exhaustion: ${categorySums["Emotional Exhaustion"]}/32 - Physical Fatigue: ${categorySums["Physical Fatigue"]}/32 - Motivation & Engagement: ${categorySums["Motivation & Engagement"]}/32 - Stress & Overload: ${categorySums["Stress & Overload"]}/32 - Work-Life Balance: ${categorySums["Work-Life Balance"]}/32*Disclaimer: This self-reflection assessment is for educational awareness purposes only and is not a medical diagnosis.*`; // Copy using document.execCommand to bypass sandbox iframe limits const tempTextArea = document.createElement('textarea'); tempTextArea.value = rawSummaryText; document.body.appendChild(tempTextArea); tempTextArea.select(); try { document.execCommand('copy'); const copyBtn = document.getElementById('copySummaryBtn'); const originalHTML = copyBtn.innerHTML; copyBtn.innerHTML = ` Copied to Clipboard!`; setTimeout(() => { copyBtn.innerHTML = originalHTML; }, 2000); } catch (err) { console.error("Copy failed: ", err); } document.body.removeChild(tempTextArea); }; }

Tinggalkan Komentar

Your email address will not be published. Required fields are marked *