Spaces:
Running
Running
ทำต่อให้ครบทุกไฟล์
Browse filesFiles changed (2)
- components/footer.jsAdded+32
- components/score-card.jsAdded+101
1234567891011121314151617181920212223242526272829303132class CustomSidebar extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = ` <style> aside { width: 250px; background: #f7fafc; padding: 1rem; height: 100vh; position: fixed; left: 0; top: 0; border-right: 1px solid #e5e7eb; } h3 { margin: 0 0 1rem 0; } ul { list-style: none; padding: 0; margin: 0; } li { margin: 0.5rem 0; } a { color: #374151; text-decoration: none; } a:hover { color: #667eea; } </style> <aside> <h3>Sidebar</h3> <ul> <li><a href="/">Home</a></li> <li><a href="/about.html">About</a></li> </ul> </aside> `; }}customElements.define('custom-sidebar', CustomSidebar);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101<div class="flex justify-between items-center mb-2"> <span class="text-textSecondary">Baseline</span> <span class="text-xl font-medium">${baselineRR}</span></div><div class="p-3 rounded-lg bg-darkBg text-sm"> ${message}</div> </div> `; // 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 => `<div class="p-3 rounded-lg bg-darkBg text-sm">${i}</div>`).join('') : '<div class="text-green-500">✅ อาหารวันนี้ไม่มีผลกระทบต่อการนอน</div>';}
// Nutrition matrixfunction 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 = ` <div class="space-y-4"> <div class="flex justify-between items-center p-3 rounded-lg bg-darkBg"> <span>วันที่กินเค็มมาก</span> <span class="font-bold text-red-500">${avgRHR_highSodium.toFixed(1)} bpm</span> </div> <div class="flex justify-between items-center p-3 rounded-lg bg-darkBg"> <span>วันที่กินปกติ</span> <span class="font-bold text-green-500">${avgRHR_normal.toFixed(1)} bpm</span> </div> <div class="p-3 rounded-lg border border-primary bg-primary bg-opacity-10 text-sm"> 🔍 วันที่มีโซเดียมสูงเฉลี่ย RHR สูงกว่า <strong>${diff} bpm</strong> </div> </div> `;}
// Seasonal reportfunction 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 = ` <div class="space-y-3"> <p>📊 ช่วงเดือนมีนาคมถึงพฤษภาคม เป็นฤดูร้อนที่เครียดที่สุด</p> <p class="p-3 rounded-lg bg-darkBg"> ⚠️ ค่าเฉลี่ยพลังกายพร้อมรบในฤดูร้อน: <strong>${avgRecoveryHotSeason.toFixed(1)}</strong> </p> <p class="text-green-400"> 💡 แนะนำ: เน้นการฟื้นตัวแบบความเย็น ลดการออกกำลังกายกลางแจ้งในช่วง 10:00-16:00 </p> <p class="text-blue-400"> 🧊 เพิ่มการดื่มน้ำเกลือแร่ อาบน้ำเย็น และใช้ห้องแอร์ 24-26°C </p> </div> `;}
// Initialize journal form datafunction initJournalForm() { const journalForm = document.querySelector('journal-form'); if (journalForm) { journalForm.setTodayData(todayData); }}components/footer.jsAdded+32
components/score-card.jsAdded+101