Baseline
${baselineRR}
${message}
`;
// Food impact on sleep
const foodContainer = document.getElementById('food-impact-sleep');
const foodImpacts = [];
if (todayData.spicyIntake > 2) {
foodImpacts.push(`🌶️ อาหารเผ็ดมาก ทำให้ RHR สูงขึ้น ${Math.floor(Math.random() * 5 + 3)} bpm ตอนเริ่มนอน`);
}
if (todayData.sodiumIntake > 3) {
foodImpacts.push(`🧂 โซเดียมสูง อาจทำให้คุณภาพการนอนลดลง 15%`);
}
if (todayData.sugarIntake > 4) {
foodImpacts.push(`🍬 น้ำตาลสูง ทำให้ Sleep Latency เพิ่มขึ้น 20 นาที`);
}
foodContainer.innerHTML = foodImpacts.length > 0
? foodImpacts.map(i => `${i}
`).join('')
: '✅ อาหารวันนี้ไม่มีผลกระทบต่อการนอน
';
}
// Nutrition matrix
function loadNutritionMatrix() {
const container = document.getElementById('nutrition-matrix');
// Calculate average RHR on high sodium days vs normal days
const highSodiumDays = mockData.days.filter(d => d.sodiumIntake >= 4);
const normalSodiumDays = mockData.days.filter(d => d.sodiumIntake < 3);
const avgRHR_highSodium = highSodiumDays.length > 0
? highSodiumDays.reduce((sum, d) => sum + d.rhr, 0) / highSodiumDays.length
: 0;
const avgRHR_normal = normalSodiumDays.length > 0
? normalSodiumDays.reduce((sum, d) => sum + d.rhr, 0) / normalSodiumDays.length
: 0;
const diff = Math.abs(avgRHR_highSodium - avgRHR_normal).toFixed(1);
container.innerHTML = `
วันที่กินเค็มมาก
${avgRHR_highSodium.toFixed(1)} bpm
วันที่กินปกติ
${avgRHR_normal.toFixed(1)} bpm
🔍 วันที่มีโซเดียมสูงเฉลี่ย RHR สูงกว่า ${diff} bpm
`;
}
// Seasonal report
function loadSeasonalReport() {
const container = document.getElementById('seasonal-report');
const hotSeasonData = mockData.days.filter(d => {
const month = new Date(d.date).getMonth();
return month >= 2 && month <= 5; // March-May
});
const avgRecoveryHotSeason = hotSeasonData.length > 0
? hotSeasonData.reduce((sum, d) => sum + d.recoveryScore, 0) / hotSeasonData.length
: 70;
container.innerHTML = `
📊 ช่วงเดือนมีนาคมถึงพฤษภาคม เป็นฤดูร้อนที่เครียดที่สุด
⚠️ ค่าเฉลี่ยพลังกายพร้อมรบในฤดูร้อน: ${avgRecoveryHotSeason.toFixed(1)}
💡 แนะนำ: เน้นการฟื้นตัวแบบความเย็น ลดการออกกำลังกายกลางแจ้งในช่วง 10:00-16:00
🧊 เพิ่มการดื่มน้ำเกลือแร่ อาบน้ำเย็น และใช้ห้องแอร์ 24-26°C
`;
}
// Initialize journal form data
function initJournalForm() {
const journalForm = document.querySelector('journal-form');
if (journalForm) {
journalForm.setTodayData(todayData);
}
}