Daily Emotional Well-being Check-in

How are you feeling at work today?
Current Work Factors
Coping Mechanisms Used Today

Insights & Suggestions (Based on Latest Check-in)

Complete a check-in on Tab 1 to see insights here.

Suggestions & Reflections:

  • Suggestions will appear here based on your check-in.

Well-being Log & Trends

Check-in History:

    Resource Hub & Settings

    Manage Custom Factors & Mechanisms

    Custom Positive Work Factors

      Custom Stressor Factors

        Custom Coping Mechanisms

          Data Management

          This will remove all your logged check-ins, custom factors, and mechanisms.

          Feeling: ${primaryEmotion} (Intensity: ${emotionIntensity}/5)

          Situation: ${workSituation || 'Not specified'}

          ${positiveFactors.length > 0 ? `

          Positive Factors: ${positiveFactors.map(id => ewb_positiveWorkFactors.find(pf=>pf.id===id)?.name || id).join(', ')}

          ` : ''} ${stressorFactors.length > 0 ? `

          Stressors/Challenges: ${stressorFactors.map(id => ewb_stressorFactors.find(sf=>sf.id===id)?.name || id).join(', ')}

          ` : ''} ${loggedCoping.length > 0 ? `

          Coping Used: ${loggedCoping.map(lc => `${lc.name} (Effectiveness: ${lc.effectiveness}⭐)`).join('; ')}

          ` : ''} `; if(journalTextarea) journalTextarea.value = journalEntry || ''; // Rule-based suggestions suggestionsEl.innerHTML = ''; let suggestions = []; if (['Stressed', 'Anxious', 'Overwhelmed', 'Frustrated'].includes(primaryEmotion) && emotionIntensity >= 3) { suggestions.push("Acknowledge these feelings. It's okay to feel this way given the circumstances."); if (stressorFactors.includes('sf_workload') || stressorFactors.includes('sf_deadline')) { suggestions.push("Try breaking down large tasks. Can anything be delegated or postponed? The Eisenhower Matrix might help prioritize."); } suggestions.push("Consider a short mindfulness exercise or deep breathing to center yourself."); const effectiveCoping = loggedCoping.filter(lc => lc.effectiveness >= 4); if(effectiveCoping.length > 0) { suggestions.push(`Remember that ${effectiveCoping.map(lc=>lc.name).join(' and ')} felt helpful.`); } else { suggestions.push("Explore some coping mechanisms from the Resource Hub like taking a walk or listening to calming music."); } } if (['Happy', 'Content', 'Motivated', 'Grateful'].includes(primaryEmotion) && emotionIntensity >=3) { suggestions.push("It's wonderful you're feeling positive! Acknowledge what contributed to this feeling."); if(positiveFactors.length > 0) suggestions.push(`Lean into positive factors like '${ewb_positiveWorkFactors.find(pf=>pf.id===positiveFactors[0])?.name || positiveFactors[0]}'.`); } if (primaryEmotion === 'Tired' && emotionIntensity >=3) { suggestions.push("Ensure you're getting enough rest. A short break or ensuring good sleep tonight might help."); } if(suggestions.length === 0) suggestions.push("Continue to be mindful of your well-being. Regular check-ins can help you understand your patterns."); suggestions.forEach(s => {const li = document.createElement('li'); li.textContent = s; suggestionsEl.appendChild(li);}); document.getElementById('ewb-downloadPdfBtn').style.display = 'inline-block'; } function ewb_saveJournalEntry() { if (ewb_latestFullCheckInResult) { ewb_latestFullCheckInResult.journalEntry = document.getElementById('ewb-journalEntry').value; const idx = ewb_checkIns.findIndex(a => a.id === ewb_latestFullCheckInResult.id); if (idx > -1) ewb_checkIns[idx].journalEntry = ewb_latestFullCheckInResult.journalEntry; ewb_saveData(); alert("Journal entry saved for this check-in."); } else { alert("Please complete a check-in first to save a journal entry for it."); } } // --- Well-being Log & Trends Tab --- function ewb_initLogTrendsTab() { const todayForPicker = EWB_TODAY_CONTEXT; document.getElementById('ewb-logFilterStartDate').value = new Date(todayForPicker.getFullYear(), todayForPicker.getMonth(), 1).toISOString().split('T')[0]; // Default to start of current month document.getElementById('ewb-logFilterEndDate').value = todayForPicker.toISOString().split('T')[0]; ewb_renderCheckInLog(); ewb_renderEmotionTrendChart(); } function ewb_renderCheckInLog(){ const listEl = document.getElementById('ewb-checkInHistoryList'); listEl.innerHTML = ''; const startDate = document.getElementById('ewb-logFilterStartDate').value; const endDate = document.getElementById('ewb-logFilterEndDate').value; const filtered = ewb_checkIns.filter(ci => { let match = true; if(startDate && ci.date < startDate) match = false; if(endDate && ci.date > endDate) match = false; return match; }); if(filtered.length === 0){ listEl.innerHTML = '
        • No check-ins found for the selected period.
        • '; return;} filtered.forEach(ci => { const li = document.createElement('li'); li.innerHTML = `${new Date(ci.date+"T00:00:00Z").toLocaleDateString()}: Felt ${ci.primaryEmotion} (Intensity: ${ci.emotionIntensity})
          Situation: ${(ci.workSituation || "N/A").substring(0,50)}...
          `; listEl.appendChild(li); }); } function ewb_viewCheckInDetail(id){ const checkIn = ewb_checkIns.find(ci => ci.id === id); if(checkIn) { ewb_latestFullCheckInResult = checkIn; // Set it as the one to view/edit // Populate check-in form document.getElementById('ewb-checkInId').value = checkIn.id; document.getElementById('ewb-checkInDate').value = checkIn.date; document.getElementById('ewb-primaryEmotion').value = checkIn.primaryEmotion; document.getElementById('ewb-emotionIntensity').value = checkIn.emotionIntensity; document.getElementById('val-emotionIntensity').textContent = checkIn.emotionIntensity; document.getElementById('ewb-workSituation').value = checkIn.workSituation; Array.from(document.querySelectorAll('input[name="positiveFactors"]')).forEach(cb => cb.checked = (checkIn.positiveFactors || []).includes(cb.value)); Array.from(document.querySelectorAll('input[name="stressorFactors"]')).forEach(cb => cb.checked = (checkIn.stressorFactors || []).includes(cb.value)); ewb_currentCheckInForLog.loggedCoping = [...(checkIn.loggedCoping || [])]; // Load coping logs const displayArea = document.getElementById('ewb-todaysCopingLogs'); displayArea.innerHTML = 'Logged for this check-in:
            ' + ewb_currentCheckInForLog.loggedCoping.map(lc => `
          • ${lc.name} (Effectiveness: ${lc.effectiveness}⭐)
          • `).join('') + '
          '; const checkInTabButton = document.querySelector(`.ewb-tab-button[onclick*="'ewb-checkInTab'"]`); ewb_openTab({currentTarget: checkInTabButton}, 'ewb-checkInTab'); // Switch to check-in tab for editing } } function ewb_renderEmotionTrendChart(){ const chartContainer = document.getElementById('ewb-emotionTrendChartContainer'); const chartCanvas = document.getElementById('ewb-emotionTrendChart'); const recentCheckIns = ewb_checkIns.slice(0, 10).reverse(); // Last 10, chronological if(recentCheckIns.length < 2) { chartContainer.style.display = 'none'; return;} chartContainer.style.display = 'block'; const labels = recentCheckIns.map(ci => new Date(ci.date+"T00:00:00Z").toLocaleDateString('en-US', {month:'short', day:'numeric'})); const dataIntensities = recentCheckIns.map(ci => ci.emotionIntensity); // Could add self-perceived overall feeling too // const dataOverallFeeling = recentCheckIns.map(ci => ci.overallFeeling / 2); // Scale 1-10 to 0.5-5 for chart if(ewb_emotionTrendChartInstance) ewb_emotionTrendChartInstance.destroy(); ewb_emotionTrendChartInstance = new Chart(chartCanvas.getContext('2d'), { type:'line', data: { labels: labels, datasets: [{ label: 'Emotion Intensity (1-5)', data: dataIntensities, borderColor: '#76D7C4', tension: 0.1, fill: false }] }, options: { responsive: true, maintainAspectRatio:false, scales:{y:{beginAtZero:true, max:5, ticks:{stepSize:1}}}} }); } // --- Resources & Settings Tab --- function ewb_initResourcesSettingsTab(){ ewb_renderCustomFactorList('ewb-customPositiveFactorsList', ewb_positiveWorkFactors, 'PositiveFactor'); ewb_renderCustomFactorList('ewb-customStressorFactorsList', ewb_stressorFactors, 'StressorFactor'); ewb_renderCustomFactorList('ewb-customCopingMechanismsList', ewb_copingMechanisms, 'CopingMechanism'); } function ewb_renderCustomFactorList(listId, dataArray, typePrefix){ const listEl = document.getElementById(listId); listEl.innerHTML = ''; const customItems = dataArray.filter(item => !item.isDefault); if(customItems.length === 0) { listEl.innerHTML = `
        • No custom ${typePrefix.toLowerCase().replace('factor','').replace('mechanism','')}s added.
        • `; return; } customItems.forEach(item => { const li = document.createElement('li'); li.innerHTML = `${item.name}
          `; listEl.appendChild(li); }); } document.getElementById('ewb-positiveFactorForm').onsubmit = (e) => { e.preventDefault(); ewb_addCustomFactor('ewb-newPositiveFactor', ewb_positiveWorkFactors, 'PositiveFactor');}; document.getElementById('ewb-stressorFactorForm').onsubmit = (e) => { e.preventDefault(); ewb_addCustomFactor('ewb-newStressorFactor', ewb_stressorFactors, 'StressorFactor');}; document.getElementById('ewb-copingMechanismCustomForm').onsubmit = (e) => { e.preventDefault(); ewb_addCustomFactor('ewb-newCopingMechanism', ewb_copingMechanisms, 'CopingMechanism');}; function ewb_addCustomFactor(inputId, dataArray, typePrefix){ const nameInput = document.getElementById(inputId); const name = nameInput.value.trim(); if(!name || dataArray.some(item => item.name.toLowerCase() === name.toLowerCase())){ alert(name ? "This item already exists." : "Name cannot be empty."); return; } dataArray.push({id: ewb_generateId(), name: name, isDefault: false}); ewb_saveData(); ewb_renderCustomFactorList(`ewb-custom${typePrefix}sList`, dataArray, typePrefix); // e.g. ewb-customPositiveFactorsList nameInput.value = ''; // Refresh relevant dropdowns/checkbox lists in other tabs if(typePrefix === 'PositiveFactor') ewb_renderCheckboxList('ewb-positiveFactorsList', ewb_positiveWorkFactors, 'positiveFactors'); if(typePrefix === 'StressorFactor') ewb_renderCheckboxList('ewb-stressorFactorsList', ewb_stressorFactors, 'stressorFactors'); if(typePrefix === 'CopingMechanism') ewb_populateSelectWithOptions('ewb-copingMechanismUsed', ewb_copingMechanisms.map(c => ({value:c.id, text:c.name})), "-- Select Coping Mechanism --"); } function ewb_deleteCustomItem(typePrefix, itemId){ let dataArray; if(typePrefix === 'PositiveFactor') dataArray = ewb_positiveWorkFactors; else if(typePrefix === 'StressorFactor') dataArray = ewb_stressorFactors; else if(typePrefix === 'CopingMechanism') dataArray = ewb_copingMechanisms; else return; // Check if used, then confirm and delete // For simplicity, this check is omitted here but would be important in a fuller version. // Example: if deleting a coping mechanism, check if it's in any ewb_checkIns[i].loggedCoping. if(confirm("Are you sure you want to delete this custom item?")){ const initialLength = dataArray.length; if(typePrefix === 'PositiveFactor') ewb_positiveWorkFactors = dataArray.filter(item => item.id !== itemId); else if(typePrefix === 'StressorFactor') ewb_stressorFactors = dataArray.filter(item => item.id !== itemId); else if(typePrefix === 'CopingMechanism') ewb_copingMechanisms = dataArray.filter(item => item.id !== itemId); if(dataArray.length < initialLength) { // Item was found and removed ewb_saveData(); ewb_renderCustomFactorList(`ewb-custom${typePrefix}sList`, dataArray.filter(item=>!item.isDefault) , typePrefix); // Re-render with the MODIFIED array if(typePrefix === 'PositiveFactor') ewb_renderCheckboxList('ewb-positiveFactorsList', ewb_positiveWorkFactors, 'positiveFactors'); if(typePrefix === 'StressorFactor') ewb_renderCheckboxList('ewb-stressorFactorsList', ewb_stressorFactors, 'stressorFactors'); if(typePrefix === 'CopingMechanism') ewb_populateSelectWithOptions('ewb-copingMechanismUsed', ewb_copingMechanisms.map(c => ({value:c.id, text:c.name})), "-- Select Coping Mechanism --"); } } } function ewb_clearAllData() { if (confirm("Are you sure you want to clear ALL your check-in data, custom factors, and mechanisms? This cannot be undone.")) { ewb_checkIns = []; ewb_positiveWorkFactors = ewb_positiveWorkFactors.filter(f => f.isDefault); ewb_stressorFactors = ewb_stressorFactors.filter(f => f.isDefault); ewb_copingMechanisms = ewb_copingMechanisms.filter(c => c.isDefault); ewb_latestFullCheckInResult = null; ewb_saveData(); // Re-initialize tabs to reflect cleared data ewb_openTab(null, ewb_tabs[0]); // Go to first tab alert("All your data has been cleared."); } } // --- PDF Download --- document.getElementById('ewb-downloadPdfBtn').onclick = async () => { if (!ewb_latestFullCheckInResult) { alert("Please complete a check-in first to download a summary."); return; } const { jsPDF } = window.jspdf; const pdf = new jsPDF('p', 'mm', 'a4'); let currentY = 15; const margin = 15; const contentWidth = pdf.internal.pageSize.getWidth() - 2*margin; const { date, primaryEmotion, emotionIntensity, workSituation, positiveFactors, stressorFactors, loggedCoping, journalEntry, calculatedScore, calculatedLevel, resultClass } = ewb_latestFullCheckInResult; let levelColorPdf = '#37474F'; // Default text color if(resultClass === 'ewb-result-Low') levelColorPdf = '#388E3C'; else if(resultClass === 'ewb-result-Moderate') levelColorPdf = '#FBC02D'; else if(resultClass === 'ewb-result-High') levelColorPdf = '#E64A19'; else if(resultClass === 'ewb-result-VeryHigh') levelColorPdf = '#D32F2F'; pdf.setFontSize(18); pdf.setTextColor(levelColorPdf); pdf.text("Emotional Well-being Check-in Summary", pdf.internal.pageSize.getWidth() / 2, currentY, { align: 'center' }); currentY += 8; pdf.setFontSize(10); pdf.setTextColor('#546E7A'); pdf.text(`Assessment Date: ${new Date(date+"T00:00:00Z").toLocaleDateString()}`, pdf.internal.pageSize.getWidth() / 2, currentY, { align: 'center'}); currentY += 10; pdf.setFontSize(12); pdf.setTextColor(levelColorPdf); pdf.text(`Indicated Level: ${calculatedLevel}`, margin, currentY); currentY += 6; pdf.setFontSize(10); pdf.setTextColor('#37474F'); pdf.text(`Primary Emotion: ${primaryEmotion} (Intensity: ${emotionIntensity}/5)`, margin, currentY); currentY += 6; const situationLines = pdf.splitTextToSize(`Situation: ${workSituation || 'Not specified'}`, contentWidth); pdf.text(situationLines, margin, currentY); currentY += (situationLines.length * 5) + 3; if (positiveFactors.length > 0) { pdf.text(`Positive Factors: ${positiveFactors.map(id => ewb_positiveWorkFactors.find(pf=>pf.id===id)?.name || id).join(', ')}`, margin, currentY); currentY += 5; } if (stressorFactors.length > 0) { pdf.text(`Stressors/Challenges: ${stressorFactors.map(id => ewb_stressorFactors.find(sf=>sf.id===id)?.name || id).join(', ')}`, margin, currentY); currentY += 5; } if (loggedCoping.length > 0) { pdf.text("Coping Mechanisms Used:", margin, currentY); currentY +=5; loggedCoping.forEach(lc => { pdf.text(`- ${lc.name} (Effectiveness: ${'⭐'.repeat(lc.effectiveness)})`, margin + 5, currentY); currentY +=5; }); } currentY += 3; const suggestionsElContent = document.querySelector('#ewb-personalizedSuggestions ul'); if (suggestionsElContent && suggestionsElContent.children.length > 0 && !suggestionsElContent.textContent.includes("after a check-in")) { if (currentY > pdf.internal.pageSize.getHeight() - 30) { pdf.addPage(); currentY = margin; } pdf.setFontSize(11); pdf.setTextColor('#00796B'); pdf.text("Suggestions & Reflections Provided:", margin, currentY); currentY += 6; pdf.setFontSize(9); pdf.setTextColor('#37474F'); Array.from(suggestionsElContent.children).forEach(li => { if (currentY > pdf.internal.pageSize.getHeight() - 10) { pdf.addPage(); currentY = margin; } const tipLines = pdf.splitTextToSize(`- ${li.textContent}`, contentWidth - 5); pdf.text(tipLines, margin + 5, currentY); currentY += (tipLines.length * 4) + 1; }); currentY += 3; } if (journalEntry) { if (currentY > pdf.internal.pageSize.getHeight() - 30) { pdf.addPage(); currentY = margin; } pdf.setFontSize(11); pdf.setTextColor('#00796B'); pdf.text("Personal Journal Entry:", margin, currentY); currentY += 6; pdf.setFontSize(9); pdf.setTextColor('#37474F'); const journalLines = pdf.splitTextToSize(journalEntry, contentWidth); pdf.text(journalLines, margin, currentY); } pdf.save(`WellBeing_CheckIn_${date}.pdf`); }; // --- Initial Load --- document.addEventListener('DOMContentLoaded', () => { ewb_openTab(null, ewb_tabs[0]); const firstTabButton = document.querySelector(`.ewb-tab-button[onclick*="'${ewb_tabs[0]}'"]`); if (firstTabButton) firstTabButton.classList.add('active'); else console.error("First tab button not found for initial activation."); ewb_updateNavButtons(); });
          Scroll to Top