Mood Tracking Dashboard
Log your feelings and visualize your emotional well-being.
Your Mood Overview
Monthly Mood Calendar
Mood Distribution
How are you feeling today?
Your Mood History
| Date | Mood | Notes | Action |
|---|
${mood}
`; option.addEventListener('click', () => { document.querySelectorAll('.mood-option').forEach(el => el.classList.remove('selected')); option.classList.add('selected'); }); elements.logForm.moodSelector.appendChild(option); }); }; const renderHistoryTable = () => { elements.historyTableBody.innerHTML = ''; if (moodEntries.length === 0) { elements.historyTableBody.innerHTML = `No data to display. Log your mood to see a chart.
`; if(moodChart) moodChart.destroy(); moodChart = null; return; } const options = { chart: { type: 'donut', height: '100%' }, series: series, labels: labels, colors: colors, legend: { position: 'bottom' }, responsive: [{ breakpoint: 480, options: { chart: { width: '100%' } } }] }; if (moodChart) { moodChart.updateOptions(options); } else { moodChart = new ApexCharts(elements.chart, options); moodChart.render(); } }; const renderCalendar = () => { // This is a simplified calendar representation. elements.calendar.innerHTML = 'Calendar view coming soon. Check your history tab for entries.
'; // A full calendar implementation is complex; this focuses on core requirements. }; // --- IV. EVENT HANDLING & LOGIC --- const saveEntry = () => { const date = elements.logForm.date.value; const selectedMoodEl = document.querySelector('.mood-option.selected'); const notes = elements.logForm.notes.value.trim(); if (!date) { showMessage('Please select a date.', 'error'); return; } if (!selectedMoodEl) { showMessage('Please select a mood.', 'error'); return; } const mood = selectedMoodEl.dataset.mood; // Remove any existing entry for the same date before adding the new one moodEntries = moodEntries.filter(entry => entry.date !== date); moodEntries.push({ date, mood, notes }); saveToLocalStorage(); renderAll(); showMessage('Mood entry saved successfully!'); switchTab('dashboard'); // Switch to dashboard after saving }; window.deleteEntry = (date) => { moodEntries = moodEntries.filter(entry => entry.date !== date); saveToLocalStorage(); renderAll(); showMessage('Entry deleted.', 'success'); }; const downloadPdf = async () => { const { jsPDF } = window.jspdf; const title = "Mood History Report"; // Create a clean table for PDF export let tableHtml = `${title}
| Date | Mood | Notes |
|---|---|---|
| ${entry.date} | ${entry.mood} | ${notesText} |
