Spaces:
Running
Running
ชื่อโปรเจกต์: Thai-Max Recovery (TMR) Appเป้าหมาย: สร้างแอปพลิเคชันติดตามและวิเคราะห์สุขภาพแบบองค์รวม (Holistic Health & Recovery) ที่มี คะแนนความพร้อม (Readiness Score) แม่นยำที่สุด สำหรับบริบทของคนไทย โดยรวมปัจจัยด้านสภาพแวดล้อมและพฤติกรรมเฉพาะถิ่นเข้ากับการวิเคราะห์ทางชีวภาพ (Biometric Data)1. 🥇 ฟีเจอร์หลักที่เหนือกว่า Whoop (The Thai Edge)ฟีเจอร์หลัก (Module)รายละเอียดการทำงานที่เหนือกว่าMetric ที่ใช้Recovery Score 2.0 (ค่าน้ำนม)ใช้ชื่อเรียกให้เป็นภาษาไทย/เข้าใจง่าย เช่น "คะแนนน้ำนม" หรือ "พลังกายพร้อมรบ" และเพิ่มตัวแปรการคำนวณที่เกี่ยวข้องกับสภาพแวดล้อมไทยHRV, RHR, Sleep Performance, Temp Delta, Air Quality Index (AQI)Hyper-Localized Strainคำนวณความตึงเครียดจากกิจกรรมควบคู่กับ สภาพอากาศ ในพื้นที่ (อุณหภูมิและความชื้น) และ มลพิษ (PM 2.5)Ambient Temp, Humidity, AQI, Activity Strain (HR)Thai Food Impact Analysisฟังก์ชัน Journal ขั้นสูงที่เน้นอาหารไทย/เอเชีย เพื่อวิเคราะห์ผลกระทบของ รสจัด/เผ็ด และ น้ำตาล/โซเดียม ต่อการนอนหลับ/RHRJournal Data (Spicy, Sugar, Salt intake), RHR, Sleep LatencySocial Stress & Traffic Indexเพิ่มมิติความเครียดทางอารมณ์/สังคมที่สูงในเมืองไทย (รถติด, มลพิษเสียง) เข้าไปในคะแนนความเครียดรายวันJournal Data (Traffic Time/Duration), Perceived Stress Score2. 🧠 โครงสร้างข้อมูล Mockup (Advanced Biometric & Contextual Data)ต้องสร้าง Mock Data ที่สมจริง 30 วันสำหรับผู้ใช้ 1 คน (User Persona: พนักงานออฟฟิศในกรุงเทพฯ ที่วิ่งมาราธอน) โดยมีชุดข้อมูลหลักและชุดข้อมูลบริบท:A. Core Biometric Data (30 Days)MetricRangeDependency (เมื่อสูง/ต่ำ)recoveryScore0-100$\downarrow$ เมื่อ HRV ต่ำ, RHR สูง, ป่วย, หรือ PM 2.5 สูงhrv (RMSSD)30-140 ms$\downarrow$ เมื่อดื่มแอลกอฮอล์, อากาศร้อนจัด, เครียดสูงrhr40-80 bpm$\uparrow$ เมื่อป่วย, ดื่มกาแฟตอนบ่าย, ทานเผ็ดมื้อดึกsleepScore0-100$\downarrow$ เมื่ออุณหภูมิห้องสูง, PM 2.5 สูง, Traffic Index สูงrespiratoryRate12-20 brpm$\uparrow$ เมื่อป่วย (สัญญาณเตือน)tempDelta$\pm 0.5 \text{ }^\circ\text{C}$$\uparrow$ เมื่อมีไข้, $\downarrow$ เมื่อรอบเดือนมาB. Contextual/Environmental Data (30 Days)MetricRangeDescription (บริบทไทย)aqi_pm2520-300ดึงค่า PM 2.5 จำลอง (สูงมากในเดือนที่มีมลพิษ)ambientTemp$25-40 \text{ }^\circ\text{C}$อุณหภูมิภายนอก (ใช้ในการคำนวณ Strain ในการวิ่ง)trafficIndex1-10ระดับความเครียดจากการจราจร (10 คือรถติดหนักมาก)spicyIntake0-3ระดับความเผ็ด (0: ไม่เผ็ด, 3: เผ็ดมาก)sugarIntake0-5ปริมาณน้ำตาล (หน่วย: ช้อนชาเทียบเท่า)sodiumIntake0-5ปริมาณโซเดียม (หน่วย: กรัมเทียบเท่า)3. 🎯 ฟังก์ชันการทำงานโดยละเอียด (Deep Site Function Specifications)A. Recovery Dashboard (คะแนนน้ำนม)Featureคำอธิบายภาษาไทย (UI/Insight)Data SourceCore Scoreพลังกายพร้อมรบ (ตัวเลข 0-100) พร้อมสี (เขียว/เหลือง/แดง)recoveryScoreEnvironmental Warning"สภาพอากาศวันนี้: 🌡️ ร้อนและมี PM 2.5 สูง การฝึกหนักอาจส่งผลต่อ HRV ของคุณ"aqi_pm25, ambientTempStrain Suggestion"ความตึงเครียดวันนี้: แนะนำให้ไม่เกิน 12.5 เนื่องจากอัตราการหายใจสูงกว่าปกติ"recoveryScore, respiratoryRateHRV Visualizationกราฟเส้น 7 วันของ "ความผันผวนของหัวใจ" (HRV) เทียบกับ "ความเครียดที่รับรู้"hrv, trafficIndex (เทียบกัน)B. Sleep Analytics (การนอนหลับ)Featureคำอธิบายภาษาไทย (UI/Insight)Data SourceSleep Qualityประสิทธิภาพการนอน (0-100) และ หนี้การนอน (ชั่วโมง)sleepScore, sleepDebtBedroom Impact"การนอนหลับของคุณถูกขัดจังหวะ 3 ครั้งในช่วง 03:00-05:00 น. อาจเกี่ยวข้องกับ อุณหภูมิห้องที่สูง ในช่วงนั้น"sleepScore, ambientTempSpicy Food Alert"มื้ออาหารเผ็ดเมื่อคืนนี้ ทำให้ RHR สูงขึ้น 4 bpm ในช่วงต้นของการนอนหลับ"rhr, spicyIntake (จาก Journal)Respiratory Statusอัตราการหายใจ เทียบกับค่า Baseline พร้อมคำเตือน "อาจมีอาการป่วยเริ่มต้น"respiratoryRate, tempDeltaC. Journal & Behaviour (บันทึกพฤติกรรมเชิงลึก)ใช้โครงสร้าง Journal ที่ละเอียดจาก Prompt ที่แล้ว รวมถึงฟิลด์บริบทเฉพาะกิจ เพื่อให้ผู้ใช้บันทึกปัจจัยเฉพาะเจาะจง:Field (TH)Data TypeUsage / Analysis Focusเวลาอยู่ในจราจรTime Durationวัดความเครียดทางอารมณ์/มลพิษเสียงระดับเผ็ดของอาหารDropdown (0-3)วิเคราะห์ผลกระทบต่อ RHR/การนอนเครื่องดื่มหวาน/ชานมToggle/Quantityวิเคราะห์ผลกระทบต่อ HRV/RHRความสัมพันธ์ในครอบครัวSelect (ดี/ไม่ดี/เครียด)วัดความเครียดทางสังคม/ครอบครัวช่วงพักร้อน/เที่ยวToggleปรับ Baseline การฟื้นตัวให้ต่ำลง (จากการเดินทาง)D. Advance Lab & Trends (ห้องแล็บขั้นสูง)Featureคำอธิบายภาษาไทย (UI/Insight)Data SourceHolistic Trendกราฟเส้นแสดง คะแนนน้ำนม 30 วัน ควบคู่ไปกับ PM 2.5 และ Traffic Index เพื่อหาความสัมพันธ์recoveryScore, aqi_pm25, trafficIndexNutrition Impact Matrixตารางสรุป: "วันที่มีโซเดียมสูง" โดยเฉลี่ยมี RHR สูงกว่าวันปกติ 3 bpmJournal Data (sodiumIntake, sugarIntake) เทียบกับ rhr, sleepScoreSeasonal Recovery Reportรายงานการฟื้นตัวรายไตรมาส พร้อมคำแนะนำ: "ช่วงเดือนมีนาคมถึงพฤษภาคม เป็นฤดูร้อนที่เครียดที่สุด คุณควรเน้นการฟื้นตัวแบบความเย็น"ambientTemp, recoveryScore (Historical Data)Adaptation Thresholdแสดงขีดจำกัดความพร้อมของร่างกายที่ปรับตัวเข้ากับสภาพแวดล้อม (Baseline การฟื้นตัวใหม่ในช่วง PM 2.5 สูง)hrv, aqi_pm25 (Complex Regression Analysis)4. 🛠️ ข้อกำหนดทางเทคนิค (Deep Site Specifications)ComponentTechnology/RequirementPurposeFrontend/UINative/React Native (Fully localized TH UI)เน้น UX/UI ภาษาไทยที่เข้าใจง่ายและสอดคล้องกับโทนสีอ่อน/เข้มBackend/APINode.js/Python (FastAPI)รองรับการประมวลผลข้อมูลชีวภาพและการคำนวณสูตรซับซ้อน (HRV/Recovery/Strain)Data CalculationCustom Algorithm (ต้องใส่สมการจำลอง)$R_{TMR} = 0.5 R_{WHOOP} + 0.35 R_{ENV} + 0.15 R_{FOOD}$ (สมการจำลองการคำนวณคะแนนน้ำนม)Data Source (Mock)JSON Array 30 วัน (ตาม Section 2)ใช้สำหรับการจำลองผลลัพธ์ที่ซับซ้อนและมีความสัมพันธ์Localizationภาษาไทย 100%ต้องไม่มีคำภาษาอังกฤษหลุดรอดในหน้า Dashboard, Insights, หรือ Reports
Browse files- README.md +8 -5
- components/navbar.js +79 -0
- index.html +158 -19
- script.js +372 -0
- style.css +127 -18
README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title: Thai Health Edge
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Thai Health Edge 🌶️
|
| 3 |
+
colorFrom: blue
|
| 4 |
+
colorTo: blue
|
| 5 |
+
emoji: 🐳
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite-v3
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Welcome to your new DeepSite project!
|
| 13 |
+
This project was created with [DeepSite](https://huggingface.co/deepsite).
|
components/navbar.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class NavComponent extends HTMLElement {
|
| 2 |
+
connectedCallback() {
|
| 3 |
+
this.attachShadow({ mode: 'open' });
|
| 4 |
+
this.shadowRoot.innerHTML = `
|
| 5 |
+
<style>
|
| 6 |
+
:host {
|
| 7 |
+
display: block;
|
| 8 |
+
position: sticky;
|
| 9 |
+
top: 0;
|
| 10 |
+
z-index: 50;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
nav {
|
| 14 |
+
background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
|
| 15 |
+
backdrop-filter: blur(10px);
|
| 16 |
+
border-bottom: 1px solid #374151;
|
| 17 |
+
padding: 1rem 0;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
.container {
|
| 21 |
+
max-width: 1280px;
|
| 22 |
+
margin: 0 auto;
|
| 23 |
+
padding: 0 1rem;
|
| 24 |
+
display: flex;
|
| 25 |
+
justify-content: space-between;
|
| 26 |
+
align-items: center;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
.logo {
|
| 30 |
+
display: flex;
|
| 31 |
+
align-items: center;
|
| 32 |
+
gap: 0.5rem;
|
| 33 |
+
font-size: 1.25rem;
|
| 34 |
+
font-weight: bold;
|
| 35 |
+
color: #f97316;
|
| 36 |
+
text-decoration: none;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
.nav-links {
|
| 40 |
+
display: flex;
|
| 41 |
+
gap: 2rem;
|
| 42 |
+
align-items: center;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
.nav-link {
|
| 46 |
+
color: #9ca3af;
|
| 47 |
+
text-decoration: none;
|
| 48 |
+
font-weight: 500;
|
| 49 |
+
transition: color 0.3s;
|
| 50 |
+
display: flex;
|
| 51 |
+
align-items: center;
|
| 52 |
+
gap: 0.5rem;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
.nav-link:hover {
|
| 56 |
+
color: #f97316;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
.user-menu {
|
| 60 |
+
display: flex;
|
| 61 |
+
align-items: center;
|
| 62 |
+
gap: 0.5rem;
|
| 63 |
+
color: #9ca3af;
|
| 64 |
+
cursor: pointer;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
@media (max-width: 768px) {
|
| 68 |
+
.nav-links {
|
| 69 |
+
display: none;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
.logo span {
|
| 73 |
+
display: none;
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
</style>
|
| 77 |
+
|
| 78 |
+
<nav>
|
| 79 |
+
<
|
index.html
CHANGED
|
@@ -1,19 +1,158 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="th" class="dark">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>พลังกายพร้อมรบ - Thai Health Edge</title>
|
| 7 |
+
<link rel="icon" type="image/x-icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🌶️</text></svg>">
|
| 8 |
+
<link rel="stylesheet" href="style.css">
|
| 9 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 10 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 11 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 12 |
+
<script>
|
| 13 |
+
tailwind.config = {
|
| 14 |
+
darkMode: 'class',
|
| 15 |
+
theme: {
|
| 16 |
+
extend: {
|
| 17 |
+
colors: {
|
| 18 |
+
primary: '#f97316',
|
| 19 |
+
secondary: '#14b8a6',
|
| 20 |
+
darkBg: '#111827',
|
| 21 |
+
cardBg: '#1f2937',
|
| 22 |
+
textPrimary: '#f9fafb',
|
| 23 |
+
textSecondary: '#9ca3af'
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
</script>
|
| 29 |
+
</head>
|
| 30 |
+
<body class="bg-darkBg text-textPrimary min-h-screen">
|
| 31 |
+
<nav-component></nav-component>
|
| 32 |
+
|
| 33 |
+
<main class="container mx-auto px-4 py-8 max-w-7xl">
|
| 34 |
+
<!-- Header Section -->
|
| 35 |
+
<header class="mb-8 text-center">
|
| 36 |
+
<h1 class="text-4xl font-bold text-primary mb-2">พลังกายพร้อมรบ</h1>
|
| 37 |
+
<p class="text-textSecondary">การวิเคราะห์สุขภาพแบบองค์รวมสำหรับคนไทย</p>
|
| 38 |
+
<p class="text-sm text-textSecondary mt-2">ข้อมูล 30 วันสุดท้าย | อัพเดทล่าสุด: <span id="lastUpdate"></span></p>
|
| 39 |
+
</header>
|
| 40 |
+
|
| 41 |
+
<!-- Tab Navigation -->
|
| 42 |
+
<div class="flex flex-wrap justify-center mb-8 gap-2">
|
| 43 |
+
<button onclick="showSection('dashboard')" class="tab-btn active px-6 py-3 rounded-full bg-secondary text-white font-medium transition-all">
|
| 44 |
+
<i data-feather="activity" class="inline mr-2"></i>แดชบอร์ด
|
| 45 |
+
</button>
|
| 46 |
+
<button onclick="showSection('sleep')" class="tab-btn px-6 py-3 rounded-full bg-cardBg text-textPrimary font-medium transition-all hover:bg-secondary">
|
| 47 |
+
<i data-feather="moon" class="inline mr-2"></i>การนอนหลับ
|
| 48 |
+
</button>
|
| 49 |
+
<button onclick="showSection('journal')" class="tab-btn px-6 py-3 rounded-full bg-cardBg text-textPrimary font-medium transition-all hover:bg-secondary">
|
| 50 |
+
<i data-feather="edit-3" class="inline mr-2"></i>บันทึกพฤติกรรม
|
| 51 |
+
</button>
|
| 52 |
+
<button onclick="showSection('trends')" class="tab-btn px-6 py-3 rounded-full bg-cardBg text-textPrimary font-medium transition-all hover:bg-secondary">
|
| 53 |
+
<i data-feather="trending-up" class="inline mr-2"></i>แนวโน้ม
|
| 54 |
+
</button>
|
| 55 |
+
</div>
|
| 56 |
+
|
| 57 |
+
<!-- Dashboard Section -->
|
| 58 |
+
<section id="dashboard-section" class="content-section">
|
| 59 |
+
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-8">
|
| 60 |
+
<!-- Main Score Card -->
|
| 61 |
+
<score-card id="main-score" class="lg:col-span-2"></score-card>
|
| 62 |
+
|
| 63 |
+
<!-- Environmental Alerts -->
|
| 64 |
+
<div class="space-y-4">
|
| 65 |
+
<div class="bg-cardBg rounded-2xl p-6 border-l-4 border-primary">
|
| 66 |
+
<h3 class="text-lg font-semibold mb-3 flex items-center">
|
| 67 |
+
<i data-feather="alert-triangle" class="w-5 h-5 mr-2 text-primary"></i>
|
| 68 |
+
สภาพแวดล้อมวันนี้
|
| 69 |
+
</h3>
|
| 70 |
+
<div id="environmental-warnings" class="space-y-3 text-sm text-textSecondary">
|
| 71 |
+
<!-- Dynamic content -->
|
| 72 |
+
</div>
|
| 73 |
+
</div>
|
| 74 |
+
|
| 75 |
+
<div class="bg-cardBg rounded-2xl p-6">
|
| 76 |
+
<h3 class="text-lg font-semibold mb-3 flex items-center">
|
| 77 |
+
<i data-feather="target" class="w-5 h-5 mr-2 text-secondary"></i>
|
| 78 |
+
คำแนะนำวันนี้
|
| 79 |
+
</h3>
|
| 80 |
+
<div id="daily-suggestions" class="space-y-3 text-sm text-textSecondary">
|
| 81 |
+
<!-- Dynamic content -->
|
| 82 |
+
</div>
|
| 83 |
+
</div>
|
| 84 |
+
</div>
|
| 85 |
+
</div>
|
| 86 |
+
|
| 87 |
+
<!-- HRV & Stress Chart -->
|
| 88 |
+
<div class="bg-cardBg rounded-2xl p-6 mb-8">
|
| 89 |
+
<h3 class="text-xl font-semibold mb-4">ความผันผวนของหัวใจ vs ความเครียด</h3>
|
| 90 |
+
<div class="h-64">
|
| 91 |
+
<canvas id="hrvChart"></canvas>
|
| 92 |
+
</div>
|
| 93 |
+
</div>
|
| 94 |
+
</section>
|
| 95 |
+
|
| 96 |
+
<!-- Sleep Section -->
|
| 97 |
+
<section id="sleep-section" class="content-section hidden">
|
| 98 |
+
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
| 99 |
+
<sleep-analytics-card></sleep-analytics-card>
|
| 100 |
+
|
| 101 |
+
<div class="space-y-6">
|
| 102 |
+
<div class="bg-cardBg rounded-2xl p-6">
|
| 103 |
+
<h3 class="text-lg font-semibold mb-4">สถานะการหายใจ</h3>
|
| 104 |
+
<div id="respiratory-status" class="space-y-4">
|
| 105 |
+
<!-- Dynamic content -->
|
| 106 |
+
</div>
|
| 107 |
+
</div>
|
| 108 |
+
|
| 109 |
+
<div class="bg-cardBg rounded-2xl p-6">
|
| 110 |
+
<h3 class="text-lg font-semibold mb-4">อาหารที่มีผลต่อการนอน</h3>
|
| 111 |
+
<div id="food-impact-sleep" class="space-y-4">
|
| 112 |
+
<!-- Dynamic content -->
|
| 113 |
+
</div>
|
| 114 |
+
</div>
|
| 115 |
+
</div>
|
| 116 |
+
</div>
|
| 117 |
+
</section>
|
| 118 |
+
|
| 119 |
+
<!-- Journal Section -->
|
| 120 |
+
<section id="journal-section" class="content-section hidden">
|
| 121 |
+
<journal-form></journal-form>
|
| 122 |
+
</section>
|
| 123 |
+
|
| 124 |
+
<!-- Trends Section -->
|
| 125 |
+
<section id="trends-section" class="content-section hidden">
|
| 126 |
+
<trends-chart></trends-chart>
|
| 127 |
+
|
| 128 |
+
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mt-8">
|
| 129 |
+
<div class="bg-cardBg rounded-2xl p-6">
|
| 130 |
+
<h3 class="text-lg font-semibold mb-4">ผลกระทบของโภชนาการ</h3>
|
| 131 |
+
<div id="nutrition-matrix" class="space-y-4">
|
| 132 |
+
<!-- Dynamic content -->
|
| 133 |
+
</div>
|
| 134 |
+
</div>
|
| 135 |
+
|
| 136 |
+
<div class="bg-cardBg rounded-2xl p-6">
|
| 137 |
+
<h3 class="text-lg font-semibold mb-4">รายงานฤดูกาล</h3>
|
| 138 |
+
<div id="seasonal-report" class="space-y-4 text-textSecondary text-sm">
|
| 139 |
+
<!-- Dynamic content -->
|
| 140 |
+
</div>
|
| 141 |
+
</div>
|
| 142 |
+
</div>
|
| 143 |
+
</section>
|
| 144 |
+
</main>
|
| 145 |
+
|
| 146 |
+
<footer-component></footer-component>
|
| 147 |
+
|
| 148 |
+
<script src="components/navbar.js"></script>
|
| 149 |
+
<script src="components/footer.js"></script>
|
| 150 |
+
<script src="components/score-card.js"></script>
|
| 151 |
+
<script src="components/sleep-chart.js"></script>
|
| 152 |
+
<script src="components/journal-form.js"></script>
|
| 153 |
+
<script src="components/trends-chart.js"></script>
|
| 154 |
+
<script src="script.js"></script>
|
| 155 |
+
<script>feather.replace();</script>
|
| 156 |
+
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
|
| 157 |
+
</body>
|
| 158 |
+
</html>
|
script.js
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Mock data for 30 days - Bangkok office worker marathon runner
|
| 2 |
+
const mockData = {
|
| 3 |
+
days: Array.from({ length: 30 }, (_, i) => {
|
| 4 |
+
const dayOffset = 29 - i;
|
| 5 |
+
const date = new Date();
|
| 6 |
+
date.setDate(date.getDate() - dayOffset);
|
| 7 |
+
|
| 8 |
+
// Simulate realistic patterns
|
| 9 |
+
const isWeekend = date.getDay() === 0 || date.getDay() === 6;
|
| 10 |
+
const isHotDay = date.getMonth() >= 2 && date.getMonth() <= 5; // March-May hot season
|
| 11 |
+
const pollutionLevel = Math.random() > 0.7 ? 'high' : 'normal';
|
| 12 |
+
|
| 13 |
+
return {
|
| 14 |
+
date: date.toISOString().split('T')[0],
|
| 15 |
+
recoveryScore: Math.max(20, Math.min(100, Math.floor(
|
| 16 |
+
70 + (isWeekend ? 10 : 0) - (pollutionLevel === 'high' ? 15 : 0) - (isHotDay ? 5 : 0) + Math.random() * 20 - 10
|
| 17 |
+
))),
|
| 18 |
+
hrv: Math.floor(40 + Math.random() * 60 + (isWeekend ? 15 : 0) - (pollutionLevel === 'high' ? 10 : 0)),
|
| 19 |
+
rhr: Math.floor(55 + Math.random() * 15 + (pollutionLevel === 'high' ? 5 : 0)),
|
| 20 |
+
sleepScore: Math.floor(65 + Math.random() * 25 + (isWeekend ? 8 : 0)),
|
| 21 |
+
respiratoryRate: Math.floor(14 + Math.random() * 4 + (Math.random() > 0.9 ? 3 : 0)),
|
| 22 |
+
tempDelta: (Math.random() * 1 - 0.5).toFixed(2),
|
| 23 |
+
aqi_pm25: pollutionLevel === 'high' ? Math.floor(100 + Math.random() * 150) : Math.floor(20 + Math.random() * 50),
|
| 24 |
+
ambientTemp: isHotDay ? Math.floor(35 + Math.random() * 5) : Math.floor(28 + Math.random() * 5),
|
| 25 |
+
trafficIndex: Math.floor(2 + Math.random() * 6 + (isWeekend ? -3 : 0)),
|
| 26 |
+
spicyIntake: Math.floor(Math.random() * 4),
|
| 27 |
+
sugarIntake: Math.floor(Math.random() * 6),
|
| 28 |
+
sodiumIntake: Math.floor(Math.random() * 6),
|
| 29 |
+
sleepDebt: Math.floor(Math.random() * 3 - (isWeekend ? 2 : 0)),
|
| 30 |
+
perceivedStress: Math.floor(3 + Math.random() * 5 + (pollutionLevel === 'high' ? 2 : 0))
|
| 31 |
+
};
|
| 32 |
+
})
|
| 33 |
+
};
|
| 34 |
+
|
| 35 |
+
// Current day data
|
| 36 |
+
const todayData = mockData.days[mockData.days.length - 1];
|
| 37 |
+
|
| 38 |
+
// Utility functions
|
| 39 |
+
function getScoreColor(score) {
|
| 40 |
+
if (score >= 80) return '#10b981'; // Green
|
| 41 |
+
if (score >= 60) return '#f59e0b'; // Yellow
|
| 42 |
+
return '#ef4444'; // Red
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
function getScoreText(score) {
|
| 46 |
+
if (score >= 80) return { text: 'พร้อมรบ', color: 'text-green-500' };
|
| 47 |
+
if (score >= 60) return { text: 'ปานกลาง', color: 'text-yellow-500' };
|
| 48 |
+
return { text: 'ต้องพัก', color: 'text-red-500' };
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
function formatDateThai(dateString) {
|
| 52 |
+
const date = new Date(dateString);
|
| 53 |
+
const options = { year: 'numeric', month: 'long', day: 'numeric', locale: 'th-TH' };
|
| 54 |
+
return date.toLocaleDateString('th-TH', options);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
function calculateTrend(values) {
|
| 58 |
+
const recent = values.slice(-7);
|
| 59 |
+
const previous = values.slice(-14, -7);
|
| 60 |
+
const recentAvg = recent.reduce((a, b) => a + b, 0) / recent.length;
|
| 61 |
+
const prevAvg = previous.reduce((a, b) => a + b, 0) / previous.length;
|
| 62 |
+
return recentAvg - prevAvg;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
// Initialize app
|
| 66 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 67 |
+
// Set last update time
|
| 68 |
+
document.getElementById('lastUpdate').textContent = formatDateThai(new Date().toISOString());
|
| 69 |
+
|
| 70 |
+
// Load environmental warnings
|
| 71 |
+
loadEnvironmentalWarnings();
|
| 72 |
+
|
| 73 |
+
// Load daily suggestions
|
| 74 |
+
loadDailySuggestions();
|
| 75 |
+
|
| 76 |
+
// Initialize HRV chart
|
| 77 |
+
initHRVChart();
|
| 78 |
+
|
| 79 |
+
// Load sleep data
|
| 80 |
+
loadSleepData();
|
| 81 |
+
|
| 82 |
+
// Load nutrition matrix
|
| 83 |
+
loadNutritionMatrix();
|
| 84 |
+
|
| 85 |
+
// Load seasonal report
|
| 86 |
+
loadSeasonalReport();
|
| 87 |
+
|
| 88 |
+
// Initialize journal form data
|
| 89 |
+
initJournalForm();
|
| 90 |
+
});
|
| 91 |
+
|
| 92 |
+
// Tab navigation
|
| 93 |
+
function showSection(sectionName) {
|
| 94 |
+
// Hide all sections
|
| 95 |
+
document.querySelectorAll('.content-section').forEach(section => {
|
| 96 |
+
section.classList.add('hidden');
|
| 97 |
+
});
|
| 98 |
+
|
| 99 |
+
// Show selected section
|
| 100 |
+
document.getElementById(`${sectionName}-section`).classList.remove('hidden');
|
| 101 |
+
|
| 102 |
+
// Update tab buttons
|
| 103 |
+
document.querySelectorAll('.tab-btn').forEach(btn => {
|
| 104 |
+
btn.classList.remove('active', 'bg-secondary');
|
| 105 |
+
btn.classList.add('bg-cardBg');
|
| 106 |
+
});
|
| 107 |
+
|
| 108 |
+
event.target.closest('.tab-btn').classList.add('active', 'bg-secondary');
|
| 109 |
+
event.target.closest('.tab-btn').classList.remove('bg-cardBg');
|
| 110 |
+
|
| 111 |
+
// Trigger chart resize if needed
|
| 112 |
+
if (sectionName === 'trends' && window.trendsChartInstance) {
|
| 113 |
+
setTimeout(() => window.trendsChartInstance.resize(), 100);
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
// Environmental warnings
|
| 118 |
+
function loadEnvironmentalWarnings() {
|
| 119 |
+
const warningsContainer = document.getElementById('environmental-warnings');
|
| 120 |
+
const warnings = [];
|
| 121 |
+
|
| 122 |
+
if (todayData.aqi_pm25 > 100) {
|
| 123 |
+
warnings.push(`🌫️ ค่า PM 2.5 สูง (${todayData.aqi_pm25} μg/m³) อาจลด HRV ของคุณได้`);
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
if (todayData.ambientTemp > 35) {
|
| 127 |
+
warnings.push(`🌡️ อุณหภูมิสูง (${todayData.ambientTemp}°C) เพิ่มความเครียดในการออกกำลังกาย`);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
if (todayData.trafficIndex > 7) {
|
| 131 |
+
warnings.push(`🚗 รถติดหนัก (ระดับ ${todayData.trafficIndex}/10) เพิ่มความเครียดทางอารมณ์`);
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
warningsContainer.innerHTML = warnings.length > 0
|
| 135 |
+
? warnings.map(w => `<div class="flex items-start"><span class="mr-2">•</span><span>${w}</span></div>`).join('')
|
| 136 |
+
: '<div class="text-green-500">✅ สภาพแวดล้อมอยู่ในเกณฑ์ดี</div>';
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
// Daily suggestions
|
| 140 |
+
function loadDailySuggestions() {
|
| 141 |
+
const suggestionsContainer = document.getElementById('daily-suggestions');
|
| 142 |
+
const suggestions = [];
|
| 143 |
+
|
| 144 |
+
if (todayData.recoveryScore < 60) {
|
| 145 |
+
suggestions.push(`⚠️ ควรลดความตึงเครียดวันนี้ไม่เกิน 12.5 จุด`);
|
| 146 |
+
suggestions.push(`💤 แนะนำให้นอนกลางวัน 20-30 นาที`);
|
| 147 |
+
} else if (todayData.recoveryScore < 80) {
|
| 148 |
+
suggestions.push(`💪 สามารถฝึกกลางได้ตามปกติ แต่ควรหลีกเลี่ยงช่วงเที่ยง`);
|
| 149 |
+
suggestions.push(`🥤 เพิ่มการดื่มน้ำ 2 เท่า จากภาวะอากาศร้อน`);
|
| 150 |
+
} else {
|
| 151 |
+
suggestions.push(`🔥 พร้อมสำหรับการฝึกซ้อมหนักวันนี้!`);
|
| 152 |
+
suggestions.push(`🏃♂️ เหมาะสำหรับการวิ่งระยะไกล`);
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
if (todayData.spicyIntake > 2) {
|
| 156 |
+
suggestions.push(`🌶️ ระวังอาหารเผ็ดอาจทำให้ RHR สูงขึ้นตอนนอน`);
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
suggestionsContainer.innerHTML = suggestions.map(s =>
|
| 160 |
+
`<div class="flex items-start"><span class="mr-2">•</span><span>${s}</span></div>`
|
| 161 |
+
).join('');
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
// HRV Chart
|
| 165 |
+
function initHRVChart() {
|
| 166 |
+
const ctx = document.getElementById('hrvChart').getContext('2d');
|
| 167 |
+
const last7Days = mockData.days.slice(-7);
|
| 168 |
+
|
| 169 |
+
new Chart(ctx, {
|
| 170 |
+
type: 'line',
|
| 171 |
+
data: {
|
| 172 |
+
labels: last7Days.map(d => formatDateThai(d.date).split(' ')[0]),
|
| 173 |
+
datasets: [{
|
| 174 |
+
label: 'HRV (ms)',
|
| 175 |
+
data: last7Days.map(d => d.hrv),
|
| 176 |
+
borderColor: '#14b8a6',
|
| 177 |
+
backgroundColor: 'rgba(20, 184, 166, 0.1)',
|
| 178 |
+
tension: 0.4,
|
| 179 |
+
yAxisID: 'y'
|
| 180 |
+
}, {
|
| 181 |
+
label: 'ความเครียด',
|
| 182 |
+
data: last7Days.map(d => d.perceivedStress),
|
| 183 |
+
borderColor: '#f97316',
|
| 184 |
+
backgroundColor: 'rgba(249, 115, 22, 0.1)',
|
| 185 |
+
tension: 0.4,
|
| 186 |
+
yAxisID: 'y1'
|
| 187 |
+
}]
|
| 188 |
+
},
|
| 189 |
+
options: {
|
| 190 |
+
responsive: true,
|
| 191 |
+
maintainAspectRatio: false,
|
| 192 |
+
interaction: {
|
| 193 |
+
mode: 'index',
|
| 194 |
+
intersect: false
|
| 195 |
+
},
|
| 196 |
+
plugins: {
|
| 197 |
+
legend: {
|
| 198 |
+
labels: {
|
| 199 |
+
color: '#9ca3af'
|
| 200 |
+
}
|
| 201 |
+
}
|
| 202 |
+
},
|
| 203 |
+
scales: {
|
| 204 |
+
y: {
|
| 205 |
+
type: 'linear',
|
| 206 |
+
display: true,
|
| 207 |
+
position: 'left',
|
| 208 |
+
title: {
|
| 209 |
+
display: true,
|
| 210 |
+
text: 'HRV (ms)',
|
| 211 |
+
color: '#9ca3af'
|
| 212 |
+
},
|
| 213 |
+
grid: {
|
| 214 |
+
color: 'rgba(156, 163, 175, 0.1)'
|
| 215 |
+
},
|
| 216 |
+
ticks: {
|
| 217 |
+
color: '#9ca3af'
|
| 218 |
+
}
|
| 219 |
+
},
|
| 220 |
+
y1: {
|
| 221 |
+
type: 'linear',
|
| 222 |
+
display: true,
|
| 223 |
+
position: 'right',
|
| 224 |
+
title: {
|
| 225 |
+
display: true,
|
| 226 |
+
text: 'ระดับความเครียด (1-10)',
|
| 227 |
+
color: '#9ca3af'
|
| 228 |
+
},
|
| 229 |
+
grid: {
|
| 230 |
+
drawOnChartArea: false
|
| 231 |
+
},
|
| 232 |
+
ticks: {
|
| 233 |
+
color: '#9ca3af'
|
| 234 |
+
}
|
| 235 |
+
},
|
| 236 |
+
x: {
|
| 237 |
+
ticks: {
|
| 238 |
+
color: '#9ca3af'
|
| 239 |
+
},
|
| 240 |
+
grid: {
|
| 241 |
+
color: 'rgba(156, 163, 175, 0.1)'
|
| 242 |
+
}
|
| 243 |
+
}
|
| 244 |
+
}
|
| 245 |
+
}
|
| 246 |
+
});
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
// Sleep data
|
| 250 |
+
function loadSleepData() {
|
| 251 |
+
// Respiratory status
|
| 252 |
+
const respiratoryContainer = document.getElementById('respiratory-status');
|
| 253 |
+
const baselineRR = 16;
|
| 254 |
+
const currentRR = todayData.respiratoryRate;
|
| 255 |
+
const diff = currentRR - baselineRR;
|
| 256 |
+
|
| 257 |
+
let status = 'good';
|
| 258 |
+
let message = 'อัตราการหายใจปกติ';
|
| 259 |
+
|
| 260 |
+
if (diff > 3) {
|
| 261 |
+
status = 'danger';
|
| 262 |
+
message = '⚠️ อัตราการหายใจสูงผิดปกติ อาจมีอาการป่วยเริ่มต้น';
|
| 263 |
+
} else if (diff > 1) {
|
| 264 |
+
status = 'warning';
|
| 265 |
+
message = 'อัตราการหายใจสูงกว่าปกติเล็กน้อย';
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
respiratoryContainer.innerHTML = `
|
| 269 |
+
<div class="flex justify-between items-center mb-2">
|
| 270 |
+
<span class="text-textSecondary">ปัจจุบัน</span>
|
| 271 |
+
<span class="text-2xl font-bold ${status === 'danger' ? 'text-red-500' : status === 'warning' ? 'text-yellow-500' : 'text-green-500'}">${currentRR}</span>
|
| 272 |
+
</div>
|
| 273 |
+
<div class="flex justify-between items-center mb-4">
|
| 274 |
+
<span class="text-textSecondary">Baseline</span>
|
| 275 |
+
<span class="text-xl font-medium">${baselineRR}</span>
|
| 276 |
+
</div>
|
| 277 |
+
<div class="p-3 rounded-lg bg-darkBg text-sm">
|
| 278 |
+
${message}
|
| 279 |
+
</div>
|
| 280 |
+
`;
|
| 281 |
+
|
| 282 |
+
// Food impact on sleep
|
| 283 |
+
const foodContainer = document.getElementById('food-impact-sleep');
|
| 284 |
+
const foodImpacts = [];
|
| 285 |
+
|
| 286 |
+
if (todayData.spicyIntake > 2) {
|
| 287 |
+
foodImpacts.push(`🌶️ อาหารเผ็ดมาก ทำให้ RHR สูงขึ้น ${Math.floor(Math.random() * 5 + 3)} bpm ตอนเริ่มนอน`);
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
if (todayData.sodiumIntake > 3) {
|
| 291 |
+
foodImpacts.push(`🧂 โซเดียมสูง อาจทำให้คุณภาพการนอนลดลง 15%`);
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
if (todayData.sugarIntake > 4) {
|
| 295 |
+
foodImpacts.push(`🍬 น้ำตาลสูง ทำให้ Sleep Latency เพิ่มขึ้น 20 นาที`);
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
foodContainer.innerHTML = foodImpacts.length > 0
|
| 299 |
+
? foodImpacts.map(i => `<div class="p-3 rounded-lg bg-darkBg text-sm">${i}</div>`).join('')
|
| 300 |
+
: '<div class="text-green-500">✅ อาหารวันนี้ไม่มีผลกระทบต่อการนอน</div>';
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
// Nutrition matrix
|
| 304 |
+
function loadNutritionMatrix() {
|
| 305 |
+
const container = document.getElementById('nutrition-matrix');
|
| 306 |
+
|
| 307 |
+
// Calculate average RHR on high sodium days vs normal days
|
| 308 |
+
const highSodiumDays = mockData.days.filter(d => d.sodiumIntake >= 4);
|
| 309 |
+
const normalSodiumDays = mockData.days.filter(d => d.sodiumIntake < 3);
|
| 310 |
+
|
| 311 |
+
const avgRHR_highSodium = highSodiumDays.length > 0
|
| 312 |
+
? highSodiumDays.reduce((sum, d) => sum + d.rhr, 0) / highSodiumDays.length
|
| 313 |
+
: 0;
|
| 314 |
+
const avgRHR_normal = normalSodiumDays.length > 0
|
| 315 |
+
? normalSodiumDays.reduce((sum, d) => sum + d.rhr, 0) / normalSodiumDays.length
|
| 316 |
+
: 0;
|
| 317 |
+
|
| 318 |
+
const diff = Math.abs(avgRHR_highSodium - avgRHR_normal).toFixed(1);
|
| 319 |
+
|
| 320 |
+
container.innerHTML = `
|
| 321 |
+
<div class="space-y-4">
|
| 322 |
+
<div class="flex justify-between items-center p-3 rounded-lg bg-darkBg">
|
| 323 |
+
<span>วันที่กินเค็มมาก</span>
|
| 324 |
+
<span class="font-bold text-red-500">${avgRHR_highSodium.toFixed(1)} bpm</span>
|
| 325 |
+
</div>
|
| 326 |
+
<div class="flex justify-between items-center p-3 rounded-lg bg-darkBg">
|
| 327 |
+
<span>วันที่กินปกติ</span>
|
| 328 |
+
<span class="font-bold text-green-500">${avgRHR_normal.toFixed(1)} bpm</span>
|
| 329 |
+
</div>
|
| 330 |
+
<div class="p-3 rounded-lg border border-primary bg-primary bg-opacity-10 text-sm">
|
| 331 |
+
🔍 วันที่มีโซเดียมสูงเฉลี่ย RHR สูงกว่า <strong>${diff} bpm</strong>
|
| 332 |
+
</div>
|
| 333 |
+
</div>
|
| 334 |
+
`;
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
// Seasonal report
|
| 338 |
+
function loadSeasonalReport() {
|
| 339 |
+
const container = document.getElementById('seasonal-report');
|
| 340 |
+
|
| 341 |
+
const hotSeasonData = mockData.days.filter(d => {
|
| 342 |
+
const month = new Date(d.date).getMonth();
|
| 343 |
+
return month >= 2 && month <= 5; // March-May
|
| 344 |
+
});
|
| 345 |
+
|
| 346 |
+
const avgRecoveryHotSeason = hotSeasonData.length > 0
|
| 347 |
+
? hotSeasonData.reduce((sum, d) => sum + d.recoveryScore, 0) / hotSeasonData.length
|
| 348 |
+
: 70;
|
| 349 |
+
|
| 350 |
+
container.innerHTML = `
|
| 351 |
+
<div class="space-y-3">
|
| 352 |
+
<p>📊 ช่วงเดือนมีนาคมถึงพฤษภาคม เป็นฤดูร้อนที่เครียดที่สุด</p>
|
| 353 |
+
<p class="p-3 rounded-lg bg-darkBg">
|
| 354 |
+
⚠️ ค่าเฉลี่ยพลังกายพร้อมรบในฤดูร้อน: <strong>${avgRecoveryHotSeason.toFixed(1)}</strong>
|
| 355 |
+
</p>
|
| 356 |
+
<p class="text-green-400">
|
| 357 |
+
💡 แนะนำ: เน้นการฟื้นตัวแบบความเย็น ลดการออกกำลังกายกลางแจ้งในช่วง 10:00-16:00
|
| 358 |
+
</p>
|
| 359 |
+
<p class="text-blue-400">
|
| 360 |
+
🧊 เพิ่มการดื่มน้ำเกลือแร่ อาบน้ำเย็น และใช้ห้องแอร์ 24-26°C
|
| 361 |
+
</p>
|
| 362 |
+
</div>
|
| 363 |
+
`;
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
// Initialize journal form data
|
| 367 |
+
function initJournalForm() {
|
| 368 |
+
const journalForm = document.querySelector('journal-form');
|
| 369 |
+
if (journalForm) {
|
| 370 |
+
journalForm.setTodayData(todayData);
|
| 371 |
+
}
|
| 372 |
+
}
|
style.css
CHANGED
|
@@ -1,28 +1,137 @@
|
|
|
|
|
|
|
|
| 1 |
body {
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
}
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
}
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
font-size: 15px;
|
| 14 |
-
margin-bottom: 10px;
|
| 15 |
-
margin-top: 5px;
|
| 16 |
}
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
border: 1px solid lightgray;
|
| 23 |
-
border-radius: 16px;
|
| 24 |
}
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Custom dark mode styles and animations */
|
| 2 |
+
|
| 3 |
body {
|
| 4 |
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
/* Custom scrollbars */
|
| 8 |
+
::-webkit-scrollbar {
|
| 9 |
+
width: 8px;
|
| 10 |
+
height: 8px;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
::-webkit-scrollbar-track {
|
| 14 |
+
background: #1f2937;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
::-webkit-scrollbar-thumb {
|
| 18 |
+
background: #f97316;
|
| 19 |
+
border-radius: 4px;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
::-webkit-scrollbar-thumb:hover {
|
| 23 |
+
background: #ea580c;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/* Animation for score changes */
|
| 27 |
+
@keyframes pulseScore {
|
| 28 |
+
0%, 100% { transform: scale(1); }
|
| 29 |
+
50% { transform: scale(1.05); }
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
.score-pulse {
|
| 33 |
+
animation: pulseScore 0.5s ease-in-out;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/* Gradient backgrounds for cards */
|
| 37 |
+
.card-gradient {
|
| 38 |
+
background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
|
| 39 |
}
|
| 40 |
|
| 41 |
+
/* Hover effects */
|
| 42 |
+
.tab-btn {
|
| 43 |
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
| 44 |
}
|
| 45 |
|
| 46 |
+
.tab-btn.active {
|
| 47 |
+
box-shadow: 0 4px 15px rgba(20, 184, 166, 0.3);
|
|
|
|
|
|
|
|
|
|
| 48 |
}
|
| 49 |
|
| 50 |
+
/* Chart container styles */
|
| 51 |
+
.chart-container {
|
| 52 |
+
position: relative;
|
| 53 |
+
height: 300px;
|
|
|
|
|
|
|
| 54 |
}
|
| 55 |
|
| 56 |
+
/* Mobile optimizations */
|
| 57 |
+
@media (max-width: 768px) {
|
| 58 |
+
.container {
|
| 59 |
+
padding-left: 1rem;
|
| 60 |
+
padding-right: 1rem;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
h1 {
|
| 64 |
+
font-size: 2rem;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
.tab-btn {
|
| 68 |
+
padding: 0.75rem 1rem;
|
| 69 |
+
font-size: 0.875rem;
|
| 70 |
+
}
|
| 71 |
}
|
| 72 |
+
|
| 73 |
+
/* Loading states */
|
| 74 |
+
.loading-skeleton {
|
| 75 |
+
background: linear-gradient(90deg, #1f2937 25%, #374151 50%, #1f2937 75%);
|
| 76 |
+
background-size: 200% 100%;
|
| 77 |
+
animation: loading 1.5s infinite;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
@keyframes loading {
|
| 81 |
+
0% { background-position: 200% 0; }
|
| 82 |
+
100% { background-position: -200% 0; }
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
/* Tooltip styles */
|
| 86 |
+
.tooltip {
|
| 87 |
+
position: relative;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
.tooltip:hover::after {
|
| 91 |
+
content: attr(data-tooltip);
|
| 92 |
+
position: absolute;
|
| 93 |
+
bottom: 100%;
|
| 94 |
+
left: 50%;
|
| 95 |
+
transform: translateX(-50%);
|
| 96 |
+
background: #374151;
|
| 97 |
+
color: #f9fafb;
|
| 98 |
+
padding: 0.5rem;
|
| 99 |
+
border-radius: 0.375rem;
|
| 100 |
+
font-size: 0.75rem;
|
| 101 |
+
white-space: nowrap;
|
| 102 |
+
z-index: 10;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
/* Status indicators */
|
| 106 |
+
.status-good { color: #10b981; }
|
| 107 |
+
.status-warning { color: #f59e0b; }
|
| 108 |
+
.status-danger { color: #ef4444; }
|
| 109 |
+
|
| 110 |
+
/* Custom form elements */
|
| 111 |
+
input[type="range"] {
|
| 112 |
+
-webkit-appearance: none;
|
| 113 |
+
appearance: none;
|
| 114 |
+
background: #374151;
|
| 115 |
+
height: 6px;
|
| 116 |
+
border-radius: 3px;
|
| 117 |
+
outline: none;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
input[type="range"]::-webkit-slider-thumb {
|
| 121 |
+
-webkit-appearance: none;
|
| 122 |
+
appearance: none;
|
| 123 |
+
width: 20px;
|
| 124 |
+
height: 20px;
|
| 125 |
+
border-radius: 50%;
|
| 126 |
+
background: #f97316;
|
| 127 |
+
cursor: pointer;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
input[type="range"]::-moz-range-thumb {
|
| 131 |
+
width: 20px;
|
| 132 |
+
height: 20px;
|
| 133 |
+
border-radius: 50%;
|
| 134 |
+
background: #f97316;
|
| 135 |
+
cursor: pointer;
|
| 136 |
+
border: none;
|
| 137 |
+
}
|