Spaces:
Running
สร้างเว็บแอป HTML5 “หน้าเดียว” สไตล์โมบาย (จออ้างอิง 390×844) ที่ “ได้รับแรงบันดาลใจ” จากแอป WHOOP โดยห้ามคัดลอกดีไซน์/ทรัพย์สินทางปัญญาแบบหนึ่งต่อหนึ่ง แต่คงฟีเจอร์หลักทั้งหมด เน้นกราฟและอินไซต์เชิงสุขภาพ ฟีเจอร์ทั้งหมดต้องใช้งานได้ด้วยข้อมูลจำลอง (mock data) และไม่มีการเรียก API ภายนอก ผลลัพธ์ต้องอยู่ในไฟล์เดียว (inline CSS + inline JS) พร้อมใช้งานทันที
Browse files1) โครงหลัก & สไตล์
โหมด Dark เป็นค่าเริ่มต้น สลับ Light ได้
โทนสี: เขียวมินต์/ฟ้าเทค + เทาเข้ม, ใช้ระบบสีแบบ CSS variables
ฟอนต์: ระบบ (SF Pro / Inter / Prompt) สำรองได้
ใช้ Flex/Grid ให้ลื่นไหล รองรับ iPhone/Android แนวตั้ง
สร้าง Header แบบ sticky พร้อมเมนูแท็บด้านบน และ Bottom Tab Bar 5 ปุ่ม: Today, Recovery, Sleep, Training, Trends
ทุกส่วน scroll นุ่มนวล มี skeleton loader สำหรับกราฟ
2) หน้า/แท็บ & คอมโพเนนต์ (ทั้งหมดภายในหน้าเดียว สลับด้วย JS)
(A) Today (สรุปภาพรวมประจำวัน)
การ์ด “Daily Overview”: วันที่, คะแนน Strain วันนี้, Recovery %, Sleep %, HRV, Resting HR
วิดเจ็ตวงแหวน (donut) 3 วง: Strain, Recovery, Sleep
เส้น HR แบบ real-time mock (อัปเดตทุก 1 วิ ด้วยค่าสุ่มภายในช่วงที่สมเหตุสมผล)
Timeline กิจกรรมวันนี้: เดิน, วิ่ง, เวท, โยคะ ฯลฯ (ไอคอน + ระยะเวลา + kcal + HR เฉลี่ย)
ปุ่ม “Log Journal” (เปิดโมดอลบันทึกพฤติกรรม)
(B) Recovery
การ์ด “Recovery Score” (0–100) + แถบสถานะ 3 โซน: แดง/เหลือง/เขียว
กราฟเส้น/พื้นที่ HRV 7/14 วัน, กราฟแท่ง Resting HR 7/14 วัน
ปัจจัยประกอบ: Sleep performance, Strain เมื่อวาน, Respiration rate, Skin temp (mock)
(C) Sleep
การ์ด “Sleep Coach”: เวลาที่แนะนำเข้านอน/ตื่น, เป้าหมายชั่วโมงนอน ตาม Strain
กราฟสเตจการนอน (Awake/Light/Deep/REM) แบบ stacked area ต่อคืน
กราฟเส้นประสิทธิภาพการนอนย้อนหลัง 14 วัน (เวลาเข้านอน, ระยะเวลานอน, ประสิทธิภาพ %)
สรุปคุณภาพ: Sleep Debt, Efficiency, Disturbances (ค่าจำลอง)
(D) Training
ปุ่ม “Start Live Workout (mock)” แสดงแดชบอร์ดสด: HR ปัจจุบัน, โซน HR, เวลา, kcal, Strain สด
เลือกชนิดกีฬา (วิ่ง/ปั่น/เวท/ว่ายน้ำ/HIIT/โยคะ/อื่นๆ)
กราฟเส้น HR สด และกราฟแท่งโซน HR ระหว่างเซสชัน
หลังจบเซสชัน สร้างบันทึกกิจกรรม + ใส่โน้ต/ความรู้สึก (RPE)
ลิสต์บันทึกการฝึกย้อนหลังพร้อมกราฟจิ๋ว (sparkline)
(E) Trends
สวิตช์ช่วงเวลา: 7D / 30D / 90D
กราฟรวมหลายมิติ: Strain (เส้น), Recovery (เส้น), Sleep (คอลัมน์) บนแกนคู่
กราฟ HRV vs Resting HR (scatter/dual-line) เพื่อดูความสัมพันธ์
กราฟ “Weekly/Monthly Report” สรุป: ค่าเฉลี่ย/สูงสุด/ต่ำสุด + ไฮไลต์สัปดาห์
ส่วนเสริมในโมดอล/หน้ารอง (ภายในไฟล์เดียว)
Journal (พฤติกรรม): แคตาล็อกพฤติกรรมครบหมวด (เช่น คาเฟอีน/แอลกอฮอล์/เวลาทานอาหาร/เม็ดกาแฟ/เดินทาง/ป่วย/คุณภาพอารมณ์/การฟื้นตัว/ซาวน่า/น้ำเย็น/เมนส์ ฯลฯ) ให้ติ๊กและให้คะแนนความเข้ม 0–3
Teams/Community (mock): กระดานอันดับประจำสัปดาห์ (ชื่อเล่น + คะแนน Strain/Recovery)
Calendar: เลือกดูย้อนหลังรายวันพร้อมจุดสีตาม Recovery zone
Settings: หน่วย (metric/imperial), ภาษาสองภาษา (TH/EN), โหมดสี, การรีเซ็ตข้อมูลจำลอง
3) ชาร์ต & ไลบรารี
ใช้ Chart.js (บันเดิลแบบ inline script) หรือ D3 ได้ แต่ต้องฝังภายในไฟล์เดียว
ประเภทกราฟที่ต้องมี: line, area (filled line), bar, stacked area, donut, scatter
Hover tooltip, legend, และ pinch-zoom (ถ้าทำได้ด้วยปลั๊กอินที่ฝัง inline)
กราฟต้องปรับขนาดอัตโนมัติเมื่อเปลี่ยนแท็บ/หมุนจอ
4) ข้อมูลจำลอง & โมเดล
สร้าง mock database ในตัว ด้วย JSON เดียว:
{
"profile": {"name":"Demo User","age":32,"gender":"unspecified"},
"today": {
"date":"2025-11-11",
"strain": 13.2,
"recovery": 74,
"sleep_score": 82,
"hr_current": 64,
"hrv_ms": 85,
"rhr_bpm": 52,
"resp_rate": 14.2,
"skin_temp_delta": 0.1
},
"sleep": {
"coach_recommended_bedtime":"22:45",
"coach_recommended_waketime":"06:30",
"stages":[
{"t":"22:50","stage":"Light"},
{"t":"23:40","stage":"Deep"},
{"t":"01:10","stage":"REM"},
{"t":"02:00","stage":"Light"},
{"t":"03:20","stage":"Deep"},
{"t":"05:40","stage":"REM"}
],
"history": [/* 14 รายการของ nightly metrics */]
},
"recovery_history": [/* 14–30 วัน: {date, recovery, rhr, hrv} */],
"strain_history": [/* 14–30 วัน: {date, strain} */],
"workouts": [/* เซสชันย้อนหลัง: {date, sport, duration_min, kcal, avg_hr, max_hr, strain} */],
"journal_catalog": [/* รายการพฤติกรรมแบบหมวดหมู่ */],
"journal_logs": [/* บันทึกต่อวัน */],
"teams": [/* กระดานอันดับ mock */]
}
มี data generator สำหรับค่ารายวันย้อนหลัง 90 วัน (สุ่มภายใต้ช่วงทางสรีรวิทยาที่สมเหตุสมผล)
ฟังก์ชัน simulate live HR (random walk ภายในโซน 45–180 bpm) ขณะเริ่ม Workout
5) อินเทอร์แอคชันสำคัญ
สลับแท็บแบบไม่รีเฟรชหน้า
โมดอล: Journal, Workout live, Settings, Report share
ปุ่ม “Share Report” สร้างภาพ PNG จากพื้นที่สรุป (ใช้ canvas.toDataURL) ดาวน์โหลดได้
ปรับภาษา TH/EN ทั้ง UI และหน่วย (เช่น km/mi, kcal) แบบทันที
Gesture: ปัดซ้าย/ขวาเพื่อเปลี่ยนช่วงกราฟ (ถ้าไม่สะดวกใช้ปุ่ม)
6) การเข้าถึง & ประสิทธิภาพ
ใส่ aria-labels, คอนทราสต์ผ่านมาตรฐาน WCAG AA
โหลดเร็ว: ใช้ inline SVG ไอคอน, ลด DOM, Debounce resize
ติดตั้งเป็น PWA ได้: ใส่ manifest (inline JSON ในสคริปต์) + Service Worker (inline ผ่าน blob URL)
7) โครงสร้างไฟล์เดียว (ตัวอย่างสเกลตัน)
<head>: meta viewport, style (CSS variables, utilities), icon font (inline)
<body>:
Header (วันที่/เมนูบน)
Tab content wrappers: #tab-today, #tab-recovery, #tab-sleep, #tab-training, #tab-trends
Bottom Tab Bar
Modals: #modal-journal, #modal-workout, #modal-settings, #modal-report
<script>:
Mock data + generator
Chart helpers (สร้าง/อัปเดต/ทำลาย)
State management (แท็บ, ภาษา, ธีม)
Live workout simulator
Share-as-image utility
Initialization: render ทุกกราฟ + event listeners
8) เกณฑ์ยอมรับ (Acceptance Criteria)
ผลลัพธ์เป็น ไฟล์ HTML เดียว เปิดแล้วใช้งานได้ทันที
แท็บทั้งหมดทำงานได้จริง ก�
- README.md +8 -5
- index.html +1515 -19
|
@@ -1,10 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: VitalTrack Pro 🏃♂️
|
| 3 |
+
colorFrom: green
|
| 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).
|
|
@@ -1,19 +1,1515 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="th">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
| 6 |
+
<title>VitalTrack Pro</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 9 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 10 |
+
|
| 11 |
+
<style>
|
| 12 |
+
:root {
|
| 13 |
+
--primary: #10b981;
|
| 14 |
+
--primary-dark: #059669;
|
| 15 |
+
--secondary: #06b6d4;
|
| 16 |
+
--secondary-dark: #0891b2;
|
| 17 |
+
--bg-dark: #0f172a;
|
| 18 |
+
--bg-light: #f8fafc;
|
| 19 |
+
--card-dark: #1e293b;
|
| 20 |
+
--card-light: #ffffff;
|
| 21 |
+
--text-dark: #f1f5f9;
|
| 22 |
+
--text-light: #0f172a;
|
| 23 |
+
--border-dark: #334155;
|
| 24 |
+
--border-light: #e2e8f0;
|
| 25 |
+
--success: #22c55e;
|
| 26 |
+
--warning: #f59e0b;
|
| 27 |
+
--danger: #ef4444;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
* {
|
| 31 |
+
margin: 0;
|
| 32 |
+
padding: 0;
|
| 33 |
+
box-sizing: border-box;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
body {
|
| 37 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'SF Pro Display', 'Prompt', sans-serif;
|
| 38 |
+
background: var(--bg-dark);
|
| 39 |
+
color: var(--text-dark);
|
| 40 |
+
min-height: 100vh;
|
| 41 |
+
overflow-x: hidden;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
body.light-mode {
|
| 45 |
+
background: var(--bg-light);
|
| 46 |
+
color: var(--text-light);
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
.card {
|
| 50 |
+
background: var(--card-dark);
|
| 51 |
+
border-radius: 16px;
|
| 52 |
+
padding: 16px;
|
| 53 |
+
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
|
| 54 |
+
border: 1px solid var(--border-dark);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
body.light-mode .card {
|
| 58 |
+
background: var(--card-light);
|
| 59 |
+
border-color: var(--border-light);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
.tab-content {
|
| 63 |
+
display: none;
|
| 64 |
+
animation: fadeIn 0.3s ease-in-out;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
.tab-content.active {
|
| 68 |
+
display: block;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
@keyframes fadeIn {
|
| 72 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 73 |
+
to { opacity: 1; transform: translateY(0); }
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
.bottom-nav {
|
| 77 |
+
position: fixed;
|
| 78 |
+
bottom: 0;
|
| 79 |
+
left: 0;
|
| 80 |
+
right: 0;
|
| 81 |
+
background: var(--card-dark);
|
| 82 |
+
border-top: 1px solid var(--border-dark);
|
| 83 |
+
padding: 8px 0;
|
| 84 |
+
z-index: 100;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
body.light-mode .bottom-nav {
|
| 88 |
+
background: var(--card-light);
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
.nav-item {
|
| 92 |
+
flex: 1;
|
| 93 |
+
display: flex;
|
| 94 |
+
flex-direction: column;
|
| 95 |
+
align-items: center;
|
| 96 |
+
padding: 8px;
|
| 97 |
+
cursor: pointer;
|
| 98 |
+
transition: all 0.2s;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
.nav-item.active {
|
| 102 |
+
color: var(--primary);
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
.modal {
|
| 106 |
+
display: none;
|
| 107 |
+
position: fixed;
|
| 108 |
+
top: 0;
|
| 109 |
+
left: 0;
|
| 110 |
+
right: 0;
|
| 111 |
+
bottom: 0;
|
| 112 |
+
background: rgba(0, 0, 0, 0.5);
|
| 113 |
+
z-index: 200;
|
| 114 |
+
padding: 20px;
|
| 115 |
+
overflow-y: auto;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
.modal.active {
|
| 119 |
+
display: flex;
|
| 120 |
+
align-items: center;
|
| 121 |
+
justify-content: center;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
.modal-content {
|
| 125 |
+
background: var(--card-dark);
|
| 126 |
+
border-radius: 20px;
|
| 127 |
+
width: 100%;
|
| 128 |
+
max-width: 390px;
|
| 129 |
+
max-height: 90vh;
|
| 130 |
+
overflow-y: auto;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
body.light-mode .modal-content {
|
| 134 |
+
background: var(--card-light);
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
.donut-chart {
|
| 138 |
+
width: 120px;
|
| 139 |
+
height: 120px;
|
| 140 |
+
position: relative;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
.progress-ring {
|
| 144 |
+
transform: rotate(-90deg);
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
.progress-ring-bg {
|
| 148 |
+
stroke: var(--border-dark);
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
.progress-ring-fill {
|
| 152 |
+
transition: stroke-dashoffset 0.5s ease;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
.skeleton {
|
| 156 |
+
background: linear-gradient(90deg, var(--border-dark) 25%, var(--card-dark) 50%, var(--border-dark) 75%);
|
| 157 |
+
background-size: 200% 100%;
|
| 158 |
+
animation: loading 1.5s infinite;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
@keyframes loading {
|
| 162 |
+
0% { background-position: 200% 0; }
|
| 163 |
+
100% { background-position: -200% 0; }
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
.sparkline {
|
| 167 |
+
stroke: var(--primary);
|
| 168 |
+
fill: none;
|
| 169 |
+
stroke-width: 2;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
.chart-container {
|
| 173 |
+
position: relative;
|
| 174 |
+
height: 200px;
|
| 175 |
+
width: 100%;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
.pulse {
|
| 179 |
+
animation: pulse 2s infinite;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
@keyframes pulse {
|
| 183 |
+
0% { transform: scale(1); opacity: 1; }
|
| 184 |
+
50% { transform: scale(1.05); opacity: 0.8; }
|
| 185 |
+
100% { transform: scale(1); opacity: 1; }
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
.slide-up {
|
| 189 |
+
animation: slideUp 0.3s ease-out;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
@keyframes slideUp {
|
| 193 |
+
from { transform: translateY(100%); opacity: 0; }
|
| 194 |
+
to { transform: translateY(0); opacity: 1; }
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
@media (max-width: 390px) {
|
| 198 |
+
body {
|
| 199 |
+
font-size: 14px;
|
| 200 |
+
}
|
| 201 |
+
}
|
| 202 |
+
</style>
|
| 203 |
+
</head>
|
| 204 |
+
<body>
|
| 205 |
+
<!-- Header -->
|
| 206 |
+
<header class="sticky top-0 z-50 card rounded-b-3xl mb-4">
|
| 207 |
+
<div class="flex justify-between items-center p-4">
|
| 208 |
+
<div class="flex items-center gap-2">
|
| 209 |
+
<i data-feather="activity" class="w-5 h-5 text-primary"></i>
|
| 210 |
+
<span class="font-semibold text-lg" data-translate="app-title">VitalTrack Pro</span>
|
| 211 |
+
</div>
|
| 212 |
+
<div class="flex gap-3">
|
| 213 |
+
<button onclick="toggleLanguage()" class="p-2 rounded-lg hover:bg-gray-700 transition">
|
| 214 |
+
<span id="lang-toggle" class="text-sm font-medium">TH</span>
|
| 215 |
+
</button>
|
| 216 |
+
<button onclick="toggleTheme()" class="p-2 rounded-lg hover:bg-gray-700 transition">
|
| 217 |
+
<i data-feather="moon" class="w-5 h-5"></i>
|
| 218 |
+
</button>
|
| 219 |
+
</div>
|
| 220 |
+
</div>
|
| 221 |
+
</header>
|
| 222 |
+
|
| 223 |
+
<!-- Main Content -->
|
| 224 |
+
<main class="pb-20 px-4 max-w-md mx-auto">
|
| 225 |
+
<!-- Today Tab -->
|
| 226 |
+
<div id="tab-today" class="tab-content active">
|
| 227 |
+
<div class="mb-4">
|
| 228 |
+
<h2 class="text-2xl font-bold mb-1" data-translate="today">วันนี้</h2>
|
| 229 |
+
<p class="text-sm opacity-75" id="current-date">11 พฤศจิกายน 2025</p>
|
| 230 |
+
</div>
|
| 231 |
+
|
| 232 |
+
<!-- Daily Overview Card -->
|
| 233 |
+
<div class="card mb-4">
|
| 234 |
+
<h3 class="font-semibold mb-3" data-translate="daily-overview">ภาพรวมประจำวัน</h3>
|
| 235 |
+
<div class="grid grid-cols-2 gap-3">
|
| 236 |
+
<div class="text-center p-3 rounded-lg bg-gradient-to-br from-red-500/20 to-red-600/20">
|
| 237 |
+
<div class="text-2xl font-bold text-red-400" id="strain-value">13.2</div>
|
| 238 |
+
<div class="text-xs opacity-75" data-translate="strain">ความเหนื่อย</div>
|
| 239 |
+
</div>
|
| 240 |
+
<div class="text-center p-3 rounded-lg bg-gradient-to-br from-green-500/20 to-green-600/20">
|
| 241 |
+
<div class="text-2xl font-bold text-green-400" id="recovery-value">74%</div>
|
| 242 |
+
<div class="text-xs opacity-75" data-translate="recovery">การฟื้นตัว</div>
|
| 243 |
+
</div>
|
| 244 |
+
<div class="text-center p-3 rounded-lg bg-gradient-to-br from-blue-500/20 to-blue-600/20">
|
| 245 |
+
<div class="text-2xl font-bold text-blue-400" id="sleep-value">82%</div>
|
| 246 |
+
<div class="text-xs opacity-75" data-translate="sleep">การนอนหลับ</div>
|
| 247 |
+
</div>
|
| 248 |
+
<div class="text-center p-3 rounded-lg bg-gradient-to-br from-purple-500/20 to-purple-600/20">
|
| 249 |
+
<div class="text-2xl font-bold text-purple-400" id="hrv-value">85</div>
|
| 250 |
+
<div class="text-xs opacity-75">HRV (ms)</div>
|
| 251 |
+
</div>
|
| 252 |
+
</div>
|
| 253 |
+
</div>
|
| 254 |
+
|
| 255 |
+
<!-- Donut Charts -->
|
| 256 |
+
<div class="grid grid-cols-3 gap-3 mb-4">
|
| 257 |
+
<div class="card text-center">
|
| 258 |
+
<div class="donut-chart mx-auto mb-2">
|
| 259 |
+
<svg width="120" height="120">
|
| 260 |
+
<circle cx="60" cy="60" r="50" fill="none" stroke-width="8" class="progress-ring-bg"/>
|
| 261 |
+
<circle id="strain-ring" cx="60" cy="60" r="50" fill="none" stroke-width="8" stroke="#ef4444"
|
| 262 |
+
stroke-dasharray="314" stroke-dashoffset="250" class="progress-ring progress-ring-fill"/>
|
| 263 |
+
</svg>
|
| 264 |
+
<div class="absolute inset-0 flex items-center justify-center">
|
| 265 |
+
<span class="text-xl font-bold">13.2</span>
|
| 266 |
+
</div>
|
| 267 |
+
</div>
|
| 268 |
+
<div class="text-xs" data-translate="strain">ความเหนื่อย</div>
|
| 269 |
+
</div>
|
| 270 |
+
<div class="card text-center">
|
| 271 |
+
<div class="donut-chart mx-auto mb-2">
|
| 272 |
+
<svg width="120" height="120">
|
| 273 |
+
<circle cx="60" cy="60" r="50" fill="none" stroke-width="8" class="progress-ring-bg"/>
|
| 274 |
+
<circle id="recovery-ring" cx="60" cy="60" r="50" fill="none" stroke-width="8" stroke="#22c55e"
|
| 275 |
+
stroke-dasharray="314" stroke-dashoffset="82" class="progress-ring progress-ring-fill"/>
|
| 276 |
+
</svg>
|
| 277 |
+
<div class="absolute inset-0 flex items-center justify-center">
|
| 278 |
+
<span class="text-xl font-bold">74%</span>
|
| 279 |
+
</div>
|
| 280 |
+
</div>
|
| 281 |
+
<div class="text-xs" data-translate="recovery">การฟื้นตัว</div>
|
| 282 |
+
</div>
|
| 283 |
+
<div class="card text-center">
|
| 284 |
+
<div class="donut-chart mx-auto mb-2">
|
| 285 |
+
<svg width="120" height="120">
|
| 286 |
+
<circle cx="60" cy="60" r="50" fill="none" stroke-width="8" class="progress-ring-bg"/>
|
| 287 |
+
<circle id="sleep-ring" cx="60" cy="60" r="50" fill="none" stroke-width="8" stroke="#3b82f6"
|
| 288 |
+
stroke-dasharray="314" stroke-dashoffset="57" class="progress-ring progress-ring-fill"/>
|
| 289 |
+
</svg>
|
| 290 |
+
<div class="absolute inset-0 flex items-center justify-center">
|
| 291 |
+
<span class="text-xl font-bold">82%</span>
|
| 292 |
+
</div>
|
| 293 |
+
</div>
|
| 294 |
+
<div class="text-xs" data-translate="sleep">การนอนหลับ</div>
|
| 295 |
+
</div>
|
| 296 |
+
</div>
|
| 297 |
+
|
| 298 |
+
<!-- Real-time HR -->
|
| 299 |
+
<div class="card mb-4">
|
| 300 |
+
<h3 class="font-semibold mb-3 flex items-center gap-2">
|
| 301 |
+
<i data-feather="heart" class="w-4 h-4 text-red-500 pulse"></i>
|
| 302 |
+
<span data-translate="current-hr">อัตราการเต้นหัวใจปัจจุบัน</span>
|
| 303 |
+
</h3>
|
| 304 |
+
<div class="text-3xl font-bold text-red-400 mb-2">
|
| 305 |
+
<span id="current-hr">64</span> <span class="text-sm font-normal">bpm</span>
|
| 306 |
+
</div>
|
| 307 |
+
<canvas id="hr-chart" height="80"></canvas>
|
| 308 |
+
</div>
|
| 309 |
+
|
| 310 |
+
<!-- Timeline -->
|
| 311 |
+
<div class="card mb-4">
|
| 312 |
+
<h3 class="font-semibold mb-3" data-translate="timeline">ไทม์ไลน์กิจกรรม</h3>
|
| 313 |
+
<div id="timeline" class="space-y-2">
|
| 314 |
+
<div class="flex items-center gap-3 p-2 rounded-lg hover:bg-gray-800/50 transition">
|
| 315 |
+
<i data-feather="activity" class="w-4 h-4 text-blue-400"></i>
|
| 316 |
+
<div class="flex-1">
|
| 317 |
+
<div class="font-medium text-sm">Morning Run</div>
|
| 318 |
+
<div class="text-xs opacity-75">07:00 - 07:30 • 245 kcal • Avg HR 145</div>
|
| 319 |
+
</div>
|
| 320 |
+
</div>
|
| 321 |
+
<div class="flex items-center gap-3 p-2 rounded-lg hover:bg-gray-800/50 transition">
|
| 322 |
+
<i data-feather="shopping-bag" class="w-4 h-4 text-green-400"></i>
|
| 323 |
+
<div class="flex-1">
|
| 324 |
+
<div class="font-medium text-sm">Walking</div>
|
| 325 |
+
<div class="text-xs opacity-75">12:30 - 13:00 • 85 kcal • Avg HR 95</div>
|
| 326 |
+
</div>
|
| 327 |
+
</div>
|
| 328 |
+
<div class="flex items-center gap-3 p-2 rounded-lg hover:bg-gray-800/50 transition">
|
| 329 |
+
<i data-feather="zap" class="w-4 h-4 text-purple-400"></i>
|
| 330 |
+
<div class="flex-1">
|
| 331 |
+
<div class="font-medium text-sm">Gym Session</div>
|
| 332 |
+
<div class="text-xs opacity-75">18:00 - 19:00 • 420 kcal • Avg HR 130</div>
|
| 333 |
+
</div>
|
| 334 |
+
</div>
|
| 335 |
+
</div>
|
| 336 |
+
</div>
|
| 337 |
+
|
| 338 |
+
<!-- Log Journal Button -->
|
| 339 |
+
<button onclick="openJournalModal()" class="w-full card bg-gradient-to-r from-primary to-primary-dark text-white font-semibold py-3 flex items-center justify-center gap-2 hover:opacity-90 transition">
|
| 340 |
+
<i data-feather="edit-3" class="w-4 h-4"></i>
|
| 341 |
+
<span data-translate="log-journal">บันทึก Journal</span>
|
| 342 |
+
</button>
|
| 343 |
+
</div>
|
| 344 |
+
|
| 345 |
+
<!-- Recovery Tab -->
|
| 346 |
+
<div id="tab-recovery" class="tab-content">
|
| 347 |
+
<div class="mb-4">
|
| 348 |
+
<h2 class="text-2xl font-bold mb-1" data-translate="recovery">การฟื้นตัว</h2>
|
| 349 |
+
<p class="text-sm opacity-75" data-translate="recovery-subtitle">ติดตามสถานะการฟื้นตัวของคุณ</p>
|
| 350 |
+
</div>
|
| 351 |
+
|
| 352 |
+
<!-- Recovery Score Card -->
|
| 353 |
+
<div class="card mb-4">
|
| 354 |
+
<div class="text-center py-4">
|
| 355 |
+
<div class="text-5xl font-bold text-green-400 mb-2">74</div>
|
| 356 |
+
<div class="text-lg font-medium mb-3" data-translate="recovery-score">คะแนนการฟื้นตัว</div>
|
| 357 |
+
<div class="w-full bg-gray-700 rounded-full h-4 mb-2">
|
| 358 |
+
<div class="bg-gradient-to-r from-green-500 to-green-400 h-4 rounded-full" style="width: 74%"></div>
|
| 359 |
+
</div>
|
| 360 |
+
<div class="flex justify-between text-xs opacity-75">
|
| 361 |
+
<span data-translate="poor">แย่</span>
|
| 362 |
+
<span data-translate="fair">ปานกลาง</span>
|
| 363 |
+
<span data-translate="good">ดี</span>
|
| 364 |
+
<span data-translate="excellent">ยอดเยี่ยม</span>
|
| 365 |
+
</div>
|
| 366 |
+
</div>
|
| 367 |
+
</div>
|
| 368 |
+
|
| 369 |
+
<!-- HRV Chart -->
|
| 370 |
+
<div class="card mb-4">
|
| 371 |
+
<h3 class="font-semibold mb-3">HRV (7 วัน)</h3>
|
| 372 |
+
<canvas id="hrv-chart" height="150"></canvas>
|
| 373 |
+
</div>
|
| 374 |
+
|
| 375 |
+
<!-- Resting HR Chart -->
|
| 376 |
+
<div class="card mb-4">
|
| 377 |
+
<h3 class="font-semibold mb-3" data-translate="resting-hr">อัตราการเต้นหัวใจขณะพัก</h3>
|
| 378 |
+
<canvas id="rhr-chart" height="150"></canvas>
|
| 379 |
+
</div>
|
| 380 |
+
|
| 381 |
+
<!-- Factors -->
|
| 382 |
+
<div class="card">
|
| 383 |
+
<h3 class="font-semibold mb-3" data-translate="factors">ปัจจัยที่ส่งผล</h3>
|
| 384 |
+
<div class="space-y-3">
|
| 385 |
+
<div class="flex justify-between items-center">
|
| 386 |
+
<span data-translate="sleep-performance">ประสิทธิภาพการนอน</span>
|
| 387 |
+
<span class="font-medium text-green-400">82%</span>
|
| 388 |
+
</div>
|
| 389 |
+
<div class="flex justify-between items-center">
|
| 390 |
+
<span data-translate="yesterday-strain">ความเหนื่อยเมื่อวาน</span>
|
| 391 |
+
<span class="font-medium text-yellow-400">11.8</span>
|
| 392 |
+
</div>
|
| 393 |
+
<div class="flex justify-between items-center">
|
| 394 |
+
<span data-translate="respiration-rate">อัตราการหายใจ</span>
|
| 395 |
+
<span class="font-medium">14.2 breaths/min</span>
|
| 396 |
+
</div>
|
| 397 |
+
<div class="flex justify-between items-center">
|
| 398 |
+
<span data-translate="skin-temp">อุณหภูมิผิวหนัง</span>
|
| 399 |
+
<span class="font-medium">+0.1°C</span>
|
| 400 |
+
</div>
|
| 401 |
+
</div>
|
| 402 |
+
</div>
|
| 403 |
+
</div>
|
| 404 |
+
|
| 405 |
+
<!-- Sleep Tab -->
|
| 406 |
+
<div id="tab-sleep" class="tab-content">
|
| 407 |
+
<div class="mb-4">
|
| 408 |
+
<h2 class="text-2xl font-bold mb-1" data-translate="sleep">การนอนหลับ</h2>
|
| 409 |
+
<p class="text-sm opacity-75" data-translate="sleep-subtitle">วิเคราะห์คุณภาพการนอนหลับของคุณ</p>
|
| 410 |
+
</div>
|
| 411 |
+
|
| 412 |
+
<!-- Sleep Coach Card -->
|
| 413 |
+
<div class="card mb-4">
|
| 414 |
+
<h3 class="font-semibold mb-3 flex items-center gap-2">
|
| 415 |
+
<i data-feather="moon" class="w-4 h-4 text-blue-400"></i>
|
| 416 |
+
<span data-translate="sleep-coach">Sleep Coach</span>
|
| 417 |
+
</h3>
|
| 418 |
+
<div class="grid grid-cols-2 gap-3">
|
| 419 |
+
<div class="text-center p-3 rounded-lg bg-blue-500/20">
|
| 420 |
+
<i data-feather="log-in" class="w-5 h-5 mx-auto mb-1 text-blue-400"></i>
|
| 421 |
+
<div class="text-xs opacity-75 mb-1" data-translate="bedtime">เวลาเข้านอน</div>
|
| 422 |
+
<div class="font-semibold">22:45</div>
|
| 423 |
+
</div>
|
| 424 |
+
<div class="text-center p-3 rounded-lg bg-yellow-500/20">
|
| 425 |
+
<i data-feather="log-out" class="w-5 h-5 mx-auto mb-1 text-yellow-400"></i>
|
| 426 |
+
<div class="text-xs opacity-75 mb-1" data-translate="wake-time">ตื่นนอน</div>
|
| 427 |
+
<div class="font-semibold">06:30</div>
|
| 428 |
+
</div>
|
| 429 |
+
</div>
|
| 430 |
+
<div class="mt-3 p-3 rounded-lg bg-green-500/20">
|
| 431 |
+
<div class="flex items-center gap-2 text-green-400">
|
| 432 |
+
<i data-feather="target" class="w-4 h-4"></i>
|
| 433 |
+
<span class="text-sm" data-translate="sleep-goal">เป้าหมาย: 7.5 ชั่วโมงตามความเหนื่อยวันนี้</span>
|
| 434 |
+
</div>
|
| 435 |
+
</div>
|
| 436 |
+
</div>
|
| 437 |
+
|
| 438 |
+
<!-- Sleep Stages -->
|
| 439 |
+
<div class="card mb-4">
|
| 440 |
+
<h3 class="font-semibold mb-3" data-translate="sleep-stages">ระยะการนอนหลับ</h3>
|
| 441 |
+
<canvas id="sleep-stages-chart" height="150"></canvas>
|
| 442 |
+
<div class="grid grid-cols-4 gap-2 mt-3 text-xs">
|
| 443 |
+
<div class="flex items-center gap-1">
|
| 444 |
+
<div class="w-3 h-3 bg-purple-500 rounded"></div>
|
| 445 |
+
<span>Awake</span>
|
| 446 |
+
</div>
|
| 447 |
+
<div class="flex items-center gap-1">
|
| 448 |
+
<div class="w-3 h-3 bg-blue-400 rounded"></div>
|
| 449 |
+
<span>Light</span>
|
| 450 |
+
</div>
|
| 451 |
+
<div class="flex items-center gap-1">
|
| 452 |
+
<div class="w-3 h-3 bg-blue-600 rounded"></div>
|
| 453 |
+
<span>Deep</span>
|
| 454 |
+
</div>
|
| 455 |
+
<div class="flex items-center gap-1">
|
| 456 |
+
<div class="w-3 h-3 bg-cyan-400 rounded"></div>
|
| 457 |
+
<span>REM</span>
|
| 458 |
+
</div>
|
| 459 |
+
</div>
|
| 460 |
+
</div>
|
| 461 |
+
|
| 462 |
+
<!-- Sleep Performance History -->
|
| 463 |
+
<div class="card">
|
| 464 |
+
<h3 class="font-semibold mb-3" data-translate="sleep-history">ประวัติการนอนหลับ (14 วัน)</h3>
|
| 465 |
+
<canvas id="sleep-history-chart" height="150"></canvas>
|
| 466 |
+
</div>
|
| 467 |
+
</div>
|
| 468 |
+
|
| 469 |
+
<!-- Training Tab -->
|
| 470 |
+
<div id="tab-training" class="tab-content">
|
| 471 |
+
<div class="mb-4">
|
| 472 |
+
<h2 class="text-2xl font-bold mb-1" data-translate="training">การฝึก</h2>
|
| 473 |
+
<p class="text-sm opacity-75" data-translate="training-subtitle">บันทึกและติดตามการออกกำลังกาย</p>
|
| 474 |
+
</div>
|
| 475 |
+
|
| 476 |
+
<!-- Start Workout Button -->
|
| 477 |
+
<button onclick="startWorkout()" class="w-full card bg-gradient-to-r from-red-500 to-orange-500 text-white font-semibold py-4 flex items-center justify-center gap-2 hover:opacity-90 transition mb-4">
|
| 478 |
+
<i data-feather="play-circle" class="w-6 h-6"></i>
|
| 479 |
+
<span data-translate="start-workout">เริ่ม Live Workout</span>
|
| 480 |
+
</button>
|
| 481 |
+
|
| 482 |
+
<!-- Sport Selection -->
|
| 483 |
+
<div class="card mb-4">
|
| 484 |
+
<h3 class="font-semibold mb-3" data-translate="select-sport">เลือกชนิดกีฬา</h3>
|
| 485 |
+
<div class="grid grid-cols-4 gap-2">
|
| 486 |
+
<button class="p-3 rounded-lg bg-blue-500/20 hover:bg-blue-500/30 transition flex flex-col items-center gap-1">
|
| 487 |
+
<i data-feather="activity" class="w-5 h-5 text-blue-400"></i>
|
| 488 |
+
<span class="text-xs">Run</span>
|
| 489 |
+
</button>
|
| 490 |
+
<button class="p-3 rounded-lg bg-green-500/20 hover:bg-green-500/30 transition flex flex-col items-center gap-1">
|
| 491 |
+
<i data-feather="navigation" class="w-5 h-5 text-green-400"></i>
|
| 492 |
+
<span class="text-xs">Bike</span>
|
| 493 |
+
</button>
|
| 494 |
+
<button class="p-3 rounded-lg bg-purple-500/20 hover:bg-purple-500/30 transition flex flex-col items-center gap-1">
|
| 495 |
+
<i data-feather="zap" class="w-5 h-5 text-purple-400"></i>
|
| 496 |
+
<span class="text-xs">Gym</span>
|
| 497 |
+
</button>
|
| 498 |
+
<button class="p-3 rounded-lg bg-cyan-500/20 hover:bg-cyan-500/30 transition flex flex-col items-center gap-1">
|
| 499 |
+
<i data-feather="droplet" class="w-5 h-5 text-cyan-400"></i>
|
| 500 |
+
<span class="text-xs">Swim</span>
|
| 501 |
+
</button>
|
| 502 |
+
<button class="p-3 rounded-lg bg-orange-500/20 hover:bg-orange-500/30 transition flex flex-col items-center gap-1">
|
| 503 |
+
<i data-feather="trending-up" class="w-5 h-5 text-orange-400"></i>
|
| 504 |
+
<span class="text-xs">HIIT</span>
|
| 505 |
+
</button>
|
| 506 |
+
<button class="p-3 rounded-lg bg-pink-500/20 hover:bg-pink-500/30 transition flex flex-col items-center gap-1">
|
| 507 |
+
<i data-feather="heart" class="w-5 h-5 text-pink-400"></i>
|
| 508 |
+
<span class="text-xs">Yoga</span>
|
| 509 |
+
</button>
|
| 510 |
+
<button class="p-3 rounded-lg bg-indigo-500/20 hover:bg-indigo-500/30 transition flex flex-col items-center gap-1">
|
| 511 |
+
<i data-feather="compass" class="w-5 h-5 text-indigo-400"></i>
|
| 512 |
+
<span class="text-xs">Hike</span>
|
| 513 |
+
</button>
|
| 514 |
+
<button class="p-3 rounded-lg bg-gray-500/20 hover:bg-gray-500/30 transition flex flex-col items-center gap-1">
|
| 515 |
+
<i data-feather="more-horizontal" class="w-5 h-5 text-gray-400"></i>
|
| 516 |
+
<span class="text-xs">Other</span>
|
| 517 |
+
</button>
|
| 518 |
+
</div>
|
| 519 |
+
</div>
|
| 520 |
+
|
| 521 |
+
<!-- Live Workout Display (Hidden by default) -->
|
| 522 |
+
<div id="live-workout" class="hidden card mb-4 bg-gradient-to-br from-red-500/10 to-orange-500/10">
|
| 523 |
+
<h3 class="font-semibold mb-3 text-red-400">Live Workout</h3>
|
| 524 |
+
<div class="grid grid-cols-2 gap-3 mb-3">
|
| 525 |
+
<div class="text-center p-3 rounded-lg bg-black/30">
|
| 526 |
+
<div class="text-2xl font-bold text-red-400 pulse" id="live-hr">145</div>
|
| 527 |
+
<div class="text-xs opacity-75">Current HR</div>
|
| 528 |
+
</div>
|
| 529 |
+
<div class="text-center p-3 rounded-lg bg-black/30">
|
| 530 |
+
<div class="text-2xl font-bold text-orange-400" id="live-time">00:00</div>
|
| 531 |
+
<div class="text-xs opacity-75">Duration</div>
|
| 532 |
+
</div>
|
| 533 |
+
<div class="text-center p-3 rounded-lg bg-black/30">
|
| 534 |
+
<div class="text-2xl font-bold text-yellow-400" id="live-kcal">0</div>
|
| 535 |
+
<div class="text-xs opacity-75">Calories</div>
|
| 536 |
+
</div>
|
| 537 |
+
<div class="text-center p-3 rounded-lg bg-black/30">
|
| 538 |
+
<div class="text-2xl font-bold text-green-400" id="live-strain">0.0</div>
|
| 539 |
+
<div class="text-xs opacity-75">Strain</div>
|
| 540 |
+
</div>
|
| 541 |
+
</div>
|
| 542 |
+
<canvas id="live-hr-chart" height="100"></canvas>
|
| 543 |
+
<button onclick="endWorkout()" class="w-full mt-3 bg-red-500 text-white font-semibold py-2 rounded-lg hover:bg-red-600 transition">
|
| 544 |
+
End Workout
|
| 545 |
+
</button>
|
| 546 |
+
</div>
|
| 547 |
+
|
| 548 |
+
<!-- Recent Workouts -->
|
| 549 |
+
<div class="card">
|
| 550 |
+
<h3 class="font-semibold mb-3" data-translate="recent-workouts">การฝึกล่าสุด</h3>
|
| 551 |
+
<div id="workout-list" class="space-y-2">
|
| 552 |
+
<!-- Workouts will be populated here -->
|
| 553 |
+
</div>
|
| 554 |
+
</div>
|
| 555 |
+
</div>
|
| 556 |
+
|
| 557 |
+
<!-- Trends Tab -->
|
| 558 |
+
<div id="tab-trends" class="tab-content">
|
| 559 |
+
<div class="mb-4">
|
| 560 |
+
<h2 class="text-2xl font-bold mb-1" data-translate="trends">แนวโน้ม</h2>
|
| 561 |
+
<p class="text-sm opacity-75" data-translate="trends-subtitle">วิเคราะห์ข้อมูลระยะยาว</p>
|
| 562 |
+
</div>
|
| 563 |
+
|
| 564 |
+
<!-- Time Period Selector -->
|
| 565 |
+
<div class="card mb-4">
|
| 566 |
+
<div class="flex gap-2">
|
| 567 |
+
<button onclick="setTrendPeriod('7D')" class="flex-1 py-2 px-4 rounded-lg bg-primary/20 text-primary font-medium">7D</button>
|
| 568 |
+
<button onclick="setTrendPeriod('30D')" class="flex-1 py-2 px-4 rounded-lg hover:bg-gray-700/30 transition font-medium">30D</button>
|
| 569 |
+
<button onclick="setTrendPeriod('90D')" class="flex-1 py-2 px-4 rounded-lg hover:bg-gray-700/30 transition font-medium">90D</button>
|
| 570 |
+
</div>
|
| 571 |
+
</div>
|
| 572 |
+
|
| 573 |
+
<!-- Combined Metrics Chart -->
|
| 574 |
+
<div class="card mb-4">
|
| 575 |
+
<h3 class="font-semibold mb-3">Strain, Recovery & Sleep</h3>
|
| 576 |
+
<canvas id="combined-chart" height="200"></canvas>
|
| 577 |
+
</div>
|
| 578 |
+
|
| 579 |
+
<!-- HRV vs RHR Chart -->
|
| 580 |
+
<div class="card mb-4">
|
| 581 |
+
<h3 class="font-semibold mb-3">HRV vs Resting HR</h3>
|
| 582 |
+
<canvas id="hrv-rhr-chart" height="200"></canvas>
|
| 583 |
+
</div>
|
| 584 |
+
|
| 585 |
+
<!-- Weekly Summary -->
|
| 586 |
+
<div class="card">
|
| 587 |
+
<h3 class="font-semibold mb-3" data-translate="weekly-report">สรุปประจำสัปดาห์</h3>
|
| 588 |
+
<div class="grid grid-cols-2 gap-3">
|
| 589 |
+
<div class="text-center p-3 rounded-lg bg-primary/20">
|
| 590 |
+
<div class="text-xl font-bold text-primary">8.5</div>
|
| 591 |
+
<div class="text-xs opacity-75">Avg Strain</div>
|
| 592 |
+
</div>
|
| 593 |
+
<div class="text-center p-3 rounded-lg bg-green-500/20">
|
| 594 |
+
<div class="text-xl font-bold text-green-400">72%</div>
|
| 595 |
+
<div class="text-xs opacity-75">Avg Recovery</div>
|
| 596 |
+
</div>
|
| 597 |
+
<div class="text-center p-3 rounded-lg bg-blue-500/20">
|
| 598 |
+
<div class="text-xl font-bold text-blue-400">84%</div>
|
| 599 |
+
<div class="text-xs opacity-75">Avg Sleep</div>
|
| 600 |
+
</div>
|
| 601 |
+
<div class="text-center p-3 rounded-lg bg-purple-500/20">
|
| 602 |
+
<div class="text-xl font-bold text-purple-400">2,850</div>
|
| 603 |
+
<div class="text-xs opacity-75">Total Calories</div>
|
| 604 |
+
</div>
|
| 605 |
+
</div>
|
| 606 |
+
</div>
|
| 607 |
+
</div>
|
| 608 |
+
</main>
|
| 609 |
+
|
| 610 |
+
<!-- Bottom Navigation -->
|
| 611 |
+
<nav class="bottom-nav">
|
| 612 |
+
<div class="flex justify-around items-center max-w-md mx-auto">
|
| 613 |
+
<div class="nav-item active" onclick="switchTab('today')">
|
| 614 |
+
<i data-feather="home" class="w-5 h-5"></i>
|
| 615 |
+
<span class="text-xs mt-1" data-translate="nav-today">วันนี้</span>
|
| 616 |
+
</div>
|
| 617 |
+
<div class="nav-item" onclick="switchTab('recovery')">
|
| 618 |
+
<i data-feather="heart" class="w-5 h-5"></i>
|
| 619 |
+
<span class="text-xs mt-1" data-translate="nav-recovery">ฟื้นตัว</span>
|
| 620 |
+
</div>
|
| 621 |
+
<div class="nav-item" onclick="switchTab('sleep')">
|
| 622 |
+
<i data-feather="moon" class="w-5 h-5"></i>
|
| 623 |
+
<span class="text-xs mt-1" data-translate="nav-sleep">นอน</span>
|
| 624 |
+
</div>
|
| 625 |
+
<div class="nav-item" onclick="switchTab('training')">
|
| 626 |
+
<i data-feather="activity" class="w-5 h-5"></i>
|
| 627 |
+
<span class="text-xs mt-1" data-translate="nav-training">ฝึก</span>
|
| 628 |
+
</div>
|
| 629 |
+
<div class="nav-item" onclick="switchTab('trends')">
|
| 630 |
+
<i data-feather="trending-up" class="w-5 h-5"></i>
|
| 631 |
+
<span class="text-xs mt-1" data-translate="nav-trends">แนวโน้ม</span>
|
| 632 |
+
</div>
|
| 633 |
+
</div>
|
| 634 |
+
</nav>
|
| 635 |
+
|
| 636 |
+
<!-- Journal Modal -->
|
| 637 |
+
<div id="journal-modal" class="modal">
|
| 638 |
+
<div class="modal-content slide-up">
|
| 639 |
+
<div class="p-6">
|
| 640 |
+
<div class="flex justify-between items-center mb-4">
|
| 641 |
+
<h3 class="text-xl font-bold" data-translate="log-journal">บันทึก Journal</h3>
|
| 642 |
+
<button onclick="closeJournalModal()" class="p-2 hover:bg-gray-700/50 rounded-lg transition">
|
| 643 |
+
<i data-feather="x" class="w-5 h-5"></i>
|
| 644 |
+
</button>
|
| 645 |
+
</div>
|
| 646 |
+
<div class="space-y-4">
|
| 647 |
+
<!-- Categories -->
|
| 648 |
+
<div>
|
| 649 |
+
<h4 class="font-semibold mb-2" data-translate="nutrition">โภชนาการ</h4>
|
| 650 |
+
<div class="grid grid-cols-2 gap-2">
|
| 651 |
+
<label class="flex items-center gap-2 p-2 rounded-lg hover:bg-gray-700/30 cursor-pointer">
|
| 652 |
+
<input type="checkbox" class="form-checkbox text-primary">
|
| 653 |
+
<span class="text-sm">Caffeine</span>
|
| 654 |
+
</label>
|
| 655 |
+
<label class="flex items-center gap-2 p-2 rounded-lg hover:bg-gray-700/30 cursor-pointer">
|
| 656 |
+
<input type="checkbox" class="form-checkbox text-primary">
|
| 657 |
+
<span class="text-sm">Alcohol</span>
|
| 658 |
+
</label>
|
| 659 |
+
<label class="flex items-center gap-2 p-2 rounded-lg hover:bg-gray-700/30 cursor-pointer">
|
| 660 |
+
<input type="checkbox" class="form-checkbox text-primary">
|
| 661 |
+
<span class="text-sm">Late meal</span>
|
| 662 |
+
</label>
|
| 663 |
+
<label class="flex items-center gap-2 p-2 rounded-lg hover:bg-gray-700/30 cursor-pointer">
|
| 664 |
+
<input type="checkbox" class="form-checkbox text-primary">
|
| 665 |
+
<span class="text-sm">Supplements</span>
|
| 666 |
+
</label>
|
| 667 |
+
</div>
|
| 668 |
+
</div>
|
| 669 |
+
<div>
|
| 670 |
+
<h4 class="font-semibold mb-2" data-translate="lifestyle">ไลฟ์สไตล์</h4>
|
| 671 |
+
<div class="grid grid-cols-2 gap-2">
|
| 672 |
+
<label class="flex items-center gap-2 p-2 rounded-lg hover:bg-gray-700/30 cursor-pointer">
|
| 673 |
+
<input type="checkbox" class="form-checkbox text-primary">
|
| 674 |
+
<span class="text-sm">Travel</span>
|
| 675 |
+
</label>
|
| 676 |
+
<label class="flex items-center gap-2 p-2 rounded-lg hover:bg-gray-700/30 cursor-pointer">
|
| 677 |
+
<input type="checkbox" class="form-checkbox text-primary">
|
| 678 |
+
<span class="text-sm">Sick</span>
|
| 679 |
+
</label>
|
| 680 |
+
<label class="flex items-center gap-2 p-2 rounded-lg hover:bg-gray-700/30 cursor-pointer">
|
| 681 |
+
<input type="checkbox" class="form-checkbox text-primary">
|
| 682 |
+
<span class="text-sm">Stress</span>
|
| 683 |
+
</label>
|
| 684 |
+
<label class="flex items-center gap-2 p-2 rounded-lg hover:bg-gray-700/30 cursor-pointer">
|
| 685 |
+
<input type="checkbox" class="form-checkbox text-primary">
|
| 686 |
+
<span class="text-sm">Meditation</span>
|
| 687 |
+
</label>
|
| 688 |
+
</div>
|
| 689 |
+
</div>
|
| 690 |
+
<div>
|
| 691 |
+
<h4 class="font-semibold mb-2" data-translate="recovery-tools">เครื่องมือฟื้นตัว</h4>
|
| 692 |
+
<div class="grid grid-cols-2 gap-2">
|
| 693 |
+
<label class="flex items-center gap-2 p-2 rounded-lg hover:bg-gray-700/30 cursor-pointer">
|
| 694 |
+
<input type="checkbox" class="form-checkbox text-primary">
|
| 695 |
+
<span class="text-sm">Sauna</span>
|
| 696 |
+
</label>
|
| 697 |
+
<label class="flex items-center gap-2 p-2 rounded-lg hover:bg-gray-700/30 cursor-pointer">
|
| 698 |
+
<input type="checkbox" class="form-checkbox text-primary">
|
| 699 |
+
<span class="text-sm">Cold plunge</span>
|
| 700 |
+
</label>
|
| 701 |
+
<label class="flex items-center gap-2 p-2 rounded-lg hover:bg-gray-700/30 cursor-pointer">
|
| 702 |
+
<input type="checkbox" class="form-checkbox text-primary">
|
| 703 |
+
<span class="text-sm">Massage</span>
|
| 704 |
+
</label>
|
| 705 |
+
<label class="flex items-center gap-2 p-2 rounded-lg hover:bg-gray-700/30 cursor-pointer">
|
| 706 |
+
<input type="checkbox" class="form-checkbox text-primary">
|
| 707 |
+
<span class="text-sm">Stretching</span>
|
| 708 |
+
</label>
|
| 709 |
+
</div>
|
| 710 |
+
</div>
|
| 711 |
+
<div>
|
| 712 |
+
<label class="block">
|
| 713 |
+
<span class="font-semibold mb-2 block" data-translate="mood">อารมณ์</span>
|
| 714 |
+
<select class="w-full p-2 rounded-lg bg-gray-700/50 border border-gray-600">
|
| 715 |
+
<option value="excellent" data-translate="excellent">ยอดเยี่ยม</option>
|
| 716 |
+
<option value="good" data-translate="good">ดี</option>
|
| 717 |
+
<option value="fair" data-translate="fair">ปานกลาง</option>
|
| 718 |
+
<option value="poor" data-translate="poor">แย่</option>
|
| 719 |
+
</select>
|
| 720 |
+
</label>
|
| 721 |
+
</div>
|
| 722 |
+
<button onclick="saveJournal()" class="w-full bg-primary text-white font-semibold py-3 rounded-lg hover:bg-primary-dark transition">
|
| 723 |
+
<span data-translate="save">บันทึก</span>
|
| 724 |
+
</button>
|
| 725 |
+
</div>
|
| 726 |
+
</div>
|
| 727 |
+
</div>
|
| 728 |
+
</div>
|
| 729 |
+
|
| 730 |
+
<!-- Settings Modal -->
|
| 731 |
+
<div id="settings-modal" class="modal">
|
| 732 |
+
<div class="modal-content slide-up">
|
| 733 |
+
<div class="p-6">
|
| 734 |
+
<div class="flex justify-between items-center mb-4">
|
| 735 |
+
<h3 class="text-xl font-bold" data-translate="settings">การตั้งค่า</h3>
|
| 736 |
+
<button onclick="closeSettingsModal()" class="p-2 hover:bg-gray-700/50 rounded-lg transition">
|
| 737 |
+
<i data-feather="x" class="w-5 h-5"></i>
|
| 738 |
+
</button>
|
| 739 |
+
</div>
|
| 740 |
+
<div class="space-y-4">
|
| 741 |
+
<div>
|
| 742 |
+
<label class="block font-semibold mb-2" data-translate="units">หน่วย</label>
|
| 743 |
+
<select class="w-full p-2 rounded-lg bg-gray-700/50 border border-gray-600">
|
| 744 |
+
<option value="metric">Metric (km, kg)</option>
|
| 745 |
+
<option value="imperial">Imperial (mi, lbs)</option>
|
| 746 |
+
</select>
|
| 747 |
+
</div>
|
| 748 |
+
<div>
|
| 749 |
+
<label class="block font-semibold mb-2" data-translate="export-data">ส่งออกข้อมูล</label>
|
| 750 |
+
<button onclick="exportData()" class="w-full p-2 rounded-lg bg-gray-700/50 border border-gray-600 text-left hover:bg-gray-700/70 transition">
|
| 751 |
+
<i data-feather="download" class="inline w-4 h-4 mr-2"></i>
|
| 752 |
+
Download CSV
|
| 753 |
+
</button>
|
| 754 |
+
</div>
|
| 755 |
+
<div>
|
| 756 |
+
<button onclick="resetData()" class="w-full p-2 rounded-lg bg-red-500/20 border border-red-500 text-red-400 hover:bg-red-500/30 transition">
|
| 757 |
+
<i data-feather="trash-2" class="inline w-4 h-4 mr-2"></i>
|
| 758 |
+
<span data-translate="reset-data">รีเซ็ตข้อมูลจำลอง</span>
|
| 759 |
+
</button>
|
| 760 |
+
</div>
|
| 761 |
+
</div>
|
| 762 |
+
</div>
|
| 763 |
+
</div>
|
| 764 |
+
</div>
|
| 765 |
+
|
| 766 |
+
<script>
|
| 767 |
+
// Mock Data
|
| 768 |
+
const mockData = {
|
| 769 |
+
profile: {
|
| 770 |
+
name: "Demo User",
|
| 771 |
+
age: 32,
|
| 772 |
+
gender: "unspecified"
|
| 773 |
+
},
|
| 774 |
+
today: {
|
| 775 |
+
date: "2025-11-11",
|
| 776 |
+
strain: 13.2,
|
| 777 |
+
recovery: 74,
|
| 778 |
+
sleep_score: 82,
|
| 779 |
+
hr_current: 64,
|
| 780 |
+
hrv_ms: 85,
|
| 781 |
+
rhr_bpm: 52,
|
| 782 |
+
resp_rate: 14.2,
|
| 783 |
+
skin_temp_delta: 0.1
|
| 784 |
+
},
|
| 785 |
+
sleep: {
|
| 786 |
+
coach_recommended_bedtime: "22:45",
|
| 787 |
+
coach_recommended_waketime: "06:30",
|
| 788 |
+
stages: [
|
| 789 |
+
{t: "22:50", stage: "Light", duration: 50},
|
| 790 |
+
{t: "23:40", stage: "Deep", duration: 90},
|
| 791 |
+
{t: "01:10", stage: "REM", duration: 50},
|
| 792 |
+
{t: "02:00", stage: "Light", duration: 80},
|
| 793 |
+
{t: "03:20", stage: "Deep", duration: 140},
|
| 794 |
+
{t: "05:40", stage: "REM", duration: 50},
|
| 795 |
+
{t: "06:30", stage: "Awake", duration: 0}
|
| 796 |
+
],
|
| 797 |
+
history: generateSleepHistory(14)
|
| 798 |
+
},
|
| 799 |
+
recovery_history: generateRecoveryHistory(30),
|
| 800 |
+
strain_history: generateStrainHistory(30),
|
| 801 |
+
workouts: generateWorkouts(10),
|
| 802 |
+
journal_logs: [],
|
| 803 |
+
hrv_data: generateHRVData(14),
|
| 804 |
+
rhr_data: generateRHRData(14)
|
| 805 |
+
};
|
| 806 |
+
|
| 807 |
+
// Language data
|
| 808 |
+
const translations = {
|
| 809 |
+
th: {
|
| 810 |
+
"app-title": "VitalTrack Pro",
|
| 811 |
+
"today": "วันนี้",
|
| 812 |
+
"recovery": "การฟื้นตัว",
|
| 813 |
+
"sleep": "การนอนหลับ",
|
| 814 |
+
"training": "การฝึก",
|
| 815 |
+
"trends": "แนวโน้ม",
|
| 816 |
+
"nav-today": "วันนี้",
|
| 817 |
+
"nav-recovery": "ฟื้นตัว",
|
| 818 |
+
"nav-sleep": "นอน",
|
| 819 |
+
"nav-training": "ฝึก",
|
| 820 |
+
"nav-trends": "แนวโน้ม",
|
| 821 |
+
"daily-overview": "ภาพรวมประจำวัน",
|
| 822 |
+
"strain": "ความเหนื่อย",
|
| 823 |
+
"current-hr": "อัตราการเต้นหัวใจปัจจุบัน",
|
| 824 |
+
"timeline": "ไทม์ไลน์กิจกรรม",
|
| 825 |
+
"log-journal": "บันทึก Journal",
|
| 826 |
+
"recovery-score": "คะแนนการฟื้นตัว",
|
| 827 |
+
"poor": "แย่",
|
| 828 |
+
"fair": "ปานกลาง",
|
| 829 |
+
"good": "ดี",
|
| 830 |
+
"excellent": "ยอดเยี่ยม",
|
| 831 |
+
"resting-hr": "อัตราการเต้นหัวใจขณะพัก",
|
| 832 |
+
"factors": "ปัจจัยที่ส่งผล",
|
| 833 |
+
"sleep-performance": "ประสิทธิภาพการนอน",
|
| 834 |
+
"yesterday-strain": "ความเหนื่อยเมื่อวาน",
|
| 835 |
+
"respiration-rate": "อัตราการหายใจ",
|
| 836 |
+
"skin-temp": "อุณหภูมิผิวหนัง",
|
| 837 |
+
"sleep-coach": "Sleep Coach",
|
| 838 |
+
"bedtime": "เวลาเข้านอน",
|
| 839 |
+
"wake-time": "ตื่นนอน",
|
| 840 |
+
"sleep-goal": "เป้าหมาย: 7.5 ชั่วโมงตามความเหนื่อยวันนี้",
|
| 841 |
+
"sleep-stages": "ระยะการนอนหลับ",
|
| 842 |
+
"sleep-history": "ประวัติการนอนหลับ (14 วัน)",
|
| 843 |
+
"start-workout": "เริ่ม Live Workout",
|
| 844 |
+
"select-sport": "เลือกชนิดกีฬา",
|
| 845 |
+
"recent-workouts": "การฝึกล่าสุด",
|
| 846 |
+
"weekly-report": "สรุปประจำสัปดาห์",
|
| 847 |
+
"nutrition": "โภชนาการ",
|
| 848 |
+
"lifestyle": "ไลฟ์สไตล์",
|
| 849 |
+
"recovery-tools": "เครื่องมือฟื้นตัว",
|
| 850 |
+
"mood": "อารมณ์",
|
| 851 |
+
"save": "บันทึก",
|
| 852 |
+
"settings": "การตั้งค่า",
|
| 853 |
+
"units": "หน่วย",
|
| 854 |
+
"export-data": "ส่งออกข้อมูล",
|
| 855 |
+
"reset-data": "รีเซ็ตข้อมูลจำลอง"
|
| 856 |
+
},
|
| 857 |
+
en: {
|
| 858 |
+
"app-title": "VitalTrack Pro",
|
| 859 |
+
"today": "Today",
|
| 860 |
+
"recovery": "Recovery",
|
| 861 |
+
"sleep": "Sleep",
|
| 862 |
+
"training": "Training",
|
| 863 |
+
"trends": "Trends",
|
| 864 |
+
"nav-today": "Today",
|
| 865 |
+
"nav-recovery": "Recovery",
|
| 866 |
+
"nav-sleep": "Sleep",
|
| 867 |
+
"nav-training": "Training",
|
| 868 |
+
"nav-trends": "Trends",
|
| 869 |
+
"daily-overview": "Daily Overview",
|
| 870 |
+
"strain": "Strain",
|
| 871 |
+
"current-hr": "Current Heart Rate",
|
| 872 |
+
"timeline": "Activity Timeline",
|
| 873 |
+
"log-journal": "Log Journal",
|
| 874 |
+
"recovery-score": "Recovery Score",
|
| 875 |
+
"poor": "Poor",
|
| 876 |
+
"fair": "Fair",
|
| 877 |
+
"good": "Good",
|
| 878 |
+
"excellent": "Excellent",
|
| 879 |
+
"resting-hr": "Resting Heart Rate",
|
| 880 |
+
"factors": "Factors",
|
| 881 |
+
"sleep-performance": "Sleep Performance",
|
| 882 |
+
"yesterday-strain": "Yesterday's Strain",
|
| 883 |
+
"respiration-rate": "Respiration Rate",
|
| 884 |
+
"skin-temp": "Skin Temperature",
|
| 885 |
+
"sleep-coach": "Sleep Coach",
|
| 886 |
+
"bedtime": "Bedtime",
|
| 887 |
+
"wake-time": "Wake Time",
|
| 888 |
+
"sleep-goal": "Goal: 7.5 hours based on today's strain",
|
| 889 |
+
"sleep-stages": "Sleep Stages",
|
| 890 |
+
"sleep-history": "Sleep History (14 days)",
|
| 891 |
+
"start-workout": "Start Live Workout",
|
| 892 |
+
"select-sport": "Select Sport",
|
| 893 |
+
"recent-workouts": "Recent Workouts",
|
| 894 |
+
"weekly-report": "Weekly Summary",
|
| 895 |
+
"nutrition": "Nutrition",
|
| 896 |
+
"lifestyle": "Lifestyle",
|
| 897 |
+
"recovery-tools": "Recovery Tools",
|
| 898 |
+
"mood": "Mood",
|
| 899 |
+
"save": "Save",
|
| 900 |
+
"settings": "Settings",
|
| 901 |
+
"units": "Units",
|
| 902 |
+
"export-data": "Export Data",
|
| 903 |
+
"reset-data": "Reset Mock Data"
|
| 904 |
+
}
|
| 905 |
+
};
|
| 906 |
+
|
| 907 |
+
// Global state
|
| 908 |
+
let currentLang = 'th';
|
| 909 |
+
let isDarkMode = true;
|
| 910 |
+
let workoutInterval = null;
|
| 911 |
+
let workoutStartTime = null;
|
| 912 |
+
let liveHRData = [];
|
| 913 |
+
let hrChartInstance = null;
|
| 914 |
+
|
| 915 |
+
// Generate mock data functions
|
| 916 |
+
function generateSleepHistory(days) {
|
| 917 |
+
const history = [];
|
| 918 |
+
for (let i = days - 1; i >= 0; i--) {
|
| 919 |
+
const date = new Date();
|
| 920 |
+
date.setDate(date.getDate() - i);
|
| 921 |
+
history.push({
|
| 922 |
+
date: date.toISOString().split('T')[0],
|
| 923 |
+
duration: 7 + Math.random() * 2,
|
| 924 |
+
efficiency: 75 + Math.random() * 20,
|
| 925 |
+
deep: Math.random() * 2,
|
| 926 |
+
rem: Math.random() * 2,
|
| 927 |
+
light: 4 + Math.random() * 2
|
| 928 |
+
});
|
| 929 |
+
}
|
| 930 |
+
return history;
|
| 931 |
+
}
|
| 932 |
+
|
| 933 |
+
function generateRecoveryHistory(days) {
|
| 934 |
+
const history = [];
|
| 935 |
+
for (let i = days - 1; i >= 0; i--) {
|
| 936 |
+
const date = new Date();
|
| 937 |
+
date.setDate(date.getDate() - i);
|
| 938 |
+
history.push({
|
| 939 |
+
date: date.toISOString().split('T')[0],
|
| 940 |
+
recovery: 60 + Math.random() * 30,
|
| 941 |
+
rhr: 45 + Math.random() * 20,
|
| 942 |
+
hrv: 60 + Math.random() * 60
|
| 943 |
+
});
|
| 944 |
+
}
|
| 945 |
+
return history;
|
| 946 |
+
}
|
| 947 |
+
|
| 948 |
+
function generateStrainHistory(days) {
|
| 949 |
+
const history = [];
|
| 950 |
+
for (let i = days - 1; i >= 0; i--) {
|
| 951 |
+
const date = new Date();
|
| 952 |
+
date.setDate(date.getDate() - i);
|
| 953 |
+
history.push({
|
| 954 |
+
date: date.toISOString().split('T')[0],
|
| 955 |
+
strain: 5 + Math.random() * 15
|
| 956 |
+
});
|
| 957 |
+
}
|
| 958 |
+
return history;
|
| 959 |
+
}
|
| 960 |
+
|
| 961 |
+
function generateWorkouts(count) {
|
| 962 |
+
const workouts = [];
|
| 963 |
+
const sports = ['Run', 'Bike', 'Gym', 'Swim', 'HIIT', 'Yoga'];
|
| 964 |
+
for (let i = 0; i < count; i++) {
|
| 965 |
+
const date = new Date();
|
| 966 |
+
date.setDate(date.getDate() - i);
|
| 967 |
+
workouts.push({
|
| 968 |
+
date: date.toISOString().split('T')[0],
|
| 969 |
+
sport: sports[Math.floor(Math.random() * sports.length)],
|
| 970 |
+
duration_min: 30 + Math.random() * 60,
|
| 971 |
+
kcal: 200 + Math.random() * 400,
|
| 972 |
+
avg_hr: 100 + Math.random() * 60,
|
| 973 |
+
max_hr: 150 + Math.random() * 30,
|
| 974 |
+
strain: 5 + Math.random() * 10
|
| 975 |
+
});
|
| 976 |
+
}
|
| 977 |
+
return workouts;
|
| 978 |
+
}
|
| 979 |
+
|
| 980 |
+
function generateHRVData(days) {
|
| 981 |
+
const data = [];
|
| 982 |
+
for (let i = days - 1; i >= 0; i--) {
|
| 983 |
+
data.push(60 + Math.random() * 60);
|
| 984 |
+
}
|
| 985 |
+
return data;
|
| 986 |
+
}
|
| 987 |
+
|
| 988 |
+
function generateRHRData(days) {
|
| 989 |
+
const data = [];
|
| 990 |
+
for (let i = days - 1; i >= 0; i--) {
|
| 991 |
+
data.push(45 + Math.random() * 20);
|
| 992 |
+
}
|
| 993 |
+
return data;
|
| 994 |
+
}
|
| 995 |
+
|
| 996 |
+
// Initialize app
|
| 997 |
+
function initApp() {
|
| 998 |
+
feather.replace();
|
| 999 |
+
initializeCharts();
|
| 1000 |
+
updateDateTime();
|
| 1001 |
+
setInterval(updateDateTime, 60000);
|
| 1002 |
+
setInterval(updateLiveHR, 1000);
|
| 1003 |
+
renderWorkoutList();
|
| 1004 |
+
}
|
| 1005 |
+
|
| 1006 |
+
// Update date/time
|
| 1007 |
+
function updateDateTime() {
|
| 1008 |
+
const now = new Date();
|
| 1009 |
+
const options = { year: 'numeric', month: 'long', day: 'numeric' };
|
| 1010 |
+
const dateStr = now.toLocaleDateString(currentLang === 'th' ? 'th-TH' : 'en-US', options);
|
| 1011 |
+
document.getElementById('current-date').textContent = dateStr;
|
| 1012 |
+
}
|
| 1013 |
+
|
| 1014 |
+
// Tab switching
|
| 1015 |
+
function switchTab(tabName) {
|
| 1016 |
+
// Hide all tabs
|
| 1017 |
+
document.querySelectorAll('.tab-content').forEach(tab => {
|
| 1018 |
+
tab.classList.remove('active');
|
| 1019 |
+
});
|
| 1020 |
+
|
| 1021 |
+
// Show selected tab
|
| 1022 |
+
document.getElementById(`tab-${tabName}`).classList.add('active');
|
| 1023 |
+
|
| 1024 |
+
// Update nav
|
| 1025 |
+
document.querySelectorAll('.nav-item').forEach(item => {
|
| 1026 |
+
item.classList.remove('active');
|
| 1027 |
+
});
|
| 1028 |
+
event.currentTarget.classList.add('active');
|
| 1029 |
+
|
| 1030 |
+
// Reinitialize charts if needed
|
| 1031 |
+
if (tabName === 'recovery') {
|
| 1032 |
+
drawRecoveryCharts();
|
| 1033 |
+
} else if (tabName === 'sleep') {
|
| 1034 |
+
drawSleepCharts();
|
| 1035 |
+
} else if (tabName === 'trends') {
|
| 1036 |
+
drawTrendsCharts();
|
| 1037 |
+
}
|
| 1038 |
+
|
| 1039 |
+
feather.replace();
|
| 1040 |
+
}
|
| 1041 |
+
|
| 1042 |
+
// Theme toggle
|
| 1043 |
+
function toggleTheme() {
|
| 1044 |
+
isDarkMode = !isDarkMode;
|
| 1045 |
+
document.body.classList.toggle('light-mode');
|
| 1046 |
+
localStorage.setItem('theme', isDarkMode ? 'dark' : 'light');
|
| 1047 |
+
|
| 1048 |
+
// Update icon
|
| 1049 |
+
const icon = document.querySelector('button[onclick="toggleTheme()"] i');
|
| 1050 |
+
icon.setAttribute('data-feather', isDarkMode ? 'moon' : 'sun');
|
| 1051 |
+
feather.replace();
|
| 1052 |
+
}
|
| 1053 |
+
|
| 1054 |
+
// Language toggle
|
| 1055 |
+
function toggleLanguage() {
|
| 1056 |
+
currentLang = currentLang === 'th' ? 'en' : 'th';
|
| 1057 |
+
localStorage.setItem('language', currentLang);
|
| 1058 |
+
document.getElementById('lang-toggle').textContent = currentLang.toUpperCase();
|
| 1059 |
+
|
| 1060 |
+
// Update all translatable elements
|
| 1061 |
+
document.querySelectorAll('[data-translate]').forEach(element => {
|
| 1062 |
+
const key = element.getAttribute('data-translate');
|
| 1063 |
+
if (translations[currentLang][key]) {
|
| 1064 |
+
element.textContent = translations[currentLang][key];
|
| 1065 |
+
}
|
| 1066 |
+
});
|
| 1067 |
+
}
|
| 1068 |
+
|
| 1069 |
+
// Modal functions
|
| 1070 |
+
function openJournalModal() {
|
| 1071 |
+
document.getElementById('journal-modal').classList.add('active');
|
| 1072 |
+
}
|
| 1073 |
+
|
| 1074 |
+
function closeJournalModal() {
|
| 1075 |
+
document.getElementById('journal-modal').classList.remove('active');
|
| 1076 |
+
}
|
| 1077 |
+
|
| 1078 |
+
function openSettingsModal() {
|
| 1079 |
+
document.getElementById('settings-modal').classList.add('active');
|
| 1080 |
+
}
|
| 1081 |
+
|
| 1082 |
+
function closeSettingsModal() {
|
| 1083 |
+
document.getElementById('settings-modal').classList.remove('active');
|
| 1084 |
+
}
|
| 1085 |
+
|
| 1086 |
+
// Save journal
|
| 1087 |
+
function saveJournal() {
|
| 1088 |
+
const journalEntry = {
|
| 1089 |
+
date: new Date().toISOString(),
|
| 1090 |
+
mood: document.querySelector('select').value,
|
| 1091 |
+
entries: []
|
| 1092 |
+
};
|
| 1093 |
+
|
| 1094 |
+
document.querySelectorAll('#journal-modal input[type="checkbox"]:checked').forEach(checkbox => {
|
| 1095 |
+
journalEntry.entries.push(checkbox.nextElementSibling.textContent);
|
| 1096 |
+
});
|
| 1097 |
+
|
| 1098 |
+
mockData.journal_logs.push(journalEntry);
|
| 1099 |
+
closeJournalModal();
|
| 1100 |
+
|
| 1101 |
+
// Show success message
|
| 1102 |
+
showToast('Journal saved successfully!');
|
| 1103 |
+
}
|
| 1104 |
+
|
| 1105 |
+
// Workout functions
|
| 1106 |
+
function startWorkout() {
|
| 1107 |
+
document.getElementById('live-workout').classList.remove('hidden');
|
| 1108 |
+
workoutStartTime = Date.now();
|
| 1109 |
+
liveHRData = [];
|
| 1110 |
+
|
| 1111 |
+
workoutInterval = setInterval(() => {
|
| 1112 |
+
updateLiveWorkout();
|
| 1113 |
+
}, 1000);
|
| 1114 |
+
}
|
| 1115 |
+
|
| 1116 |
+
function endWorkout() {
|
| 1117 |
+
if (workoutInterval) {
|
| 1118 |
+
clearInterval(workoutInterval);
|
| 1119 |
+
workoutInterval = null;
|
| 1120 |
+
}
|
| 1121 |
+
|
| 1122 |
+
// Save workout
|
| 1123 |
+
const workout = {
|
| 1124 |
+
date: new Date().toISOString().split('T')[0],
|
| 1125 |
+
sport: 'Workout',
|
| 1126 |
+
duration_min: Math.floor((Date.now() - workoutStartTime) / 60000),
|
| 1127 |
+
kcal: parseInt(document.getElementById('live-kcal').textContent),
|
| 1128 |
+
avg_hr: Math.floor(liveHRData.reduce((a, b) => a + b, 0) / liveHRData.length),
|
| 1129 |
+
max_hr: Math.max(...liveHRData),
|
| 1130 |
+
strain: parseFloat(document.getElementById('live-strain').textContent)
|
| 1131 |
+
};
|
| 1132 |
+
|
| 1133 |
+
mockData.workouts.unshift(workout);
|
| 1134 |
+
renderWorkoutList();
|
| 1135 |
+
|
| 1136 |
+
document.getElementById('live-workout').classList.add('hidden');
|
| 1137 |
+
showToast('Workout completed!');
|
| 1138 |
+
}
|
| 1139 |
+
|
| 1140 |
+
function updateLiveWorkout() {
|
| 1141 |
+
const elapsed = Math.floor((Date.now() - workoutStartTime) / 1000);
|
| 1142 |
+
const minutes = Math.floor(elapsed / 60);
|
| 1143 |
+
const seconds = elapsed % 60;
|
| 1144 |
+
document.getElementById('live-time').textContent =
|
| 1145 |
+
`${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
|
| 1146 |
+
|
| 1147 |
+
// Update calories (rough estimate)
|
| 1148 |
+
const calories = Math.floor(elapsed * 0.15);
|
| 1149 |
+
document.getElementById('live-kcal').textContent = calories;
|
| 1150 |
+
|
| 1151 |
+
// Update strain
|
| 1152 |
+
const strain = (elapsed / 60000) * 2;
|
| 1153 |
+
document.getElementById('live-strain').textContent = strain.toFixed(1);
|
| 1154 |
+
|
| 1155 |
+
// Update HR with simulation
|
| 1156 |
+
const hr = 120 + Math.floor(Math.random() * 40);
|
| 1157 |
+
document.getElementById('live-hr').textContent = hr;
|
| 1158 |
+
liveHRData.push(hr);
|
| 1159 |
+
|
| 1160 |
+
// Update live HR chart
|
| 1161 |
+
drawLiveHRChart();
|
| 1162 |
+
}
|
| 1163 |
+
|
| 1164 |
+
// Render workout list
|
| 1165 |
+
function renderWorkoutList() {
|
| 1166 |
+
const workoutList = document.getElementById('workout-list');
|
| 1167 |
+
workoutList.innerHTML = '';
|
| 1168 |
+
|
| 1169 |
+
mockData.workouts.slice(0, 5).forEach(workout => {
|
| 1170 |
+
const div = document.createElement('div');
|
| 1171 |
+
div.className = 'flex items-center gap-3 p-3 rounded-lg hover:bg-gray-800/50 transition';
|
| 1172 |
+
div.innerHTML = `
|
| 1173 |
+
<i data-feather="activity" class="w-4 h-4 text-blue-400"></i>
|
| 1174 |
+
<div class="flex-1">
|
| 1175 |
+
<div class="font-medium text-sm">${workout.sport}</div>
|
| 1176 |
+
<div class="text-xs opacity-75">${workout.duration_min} min • ${workout.kcal} kcal • Avg HR ${workout.avg_hr}</div>
|
| 1177 |
+
</div>
|
| 1178 |
+
<div class="text-sm font-semibold text-purple-400">${workout.strain.toFixed(1)}</div>
|
| 1179 |
+
`;
|
| 1180 |
+
workoutList.appendChild(div);
|
| 1181 |
+
});
|
| 1182 |
+
|
| 1183 |
+
feather.replace();
|
| 1184 |
+
}
|
| 1185 |
+
|
| 1186 |
+
// Chart functions
|
| 1187 |
+
function initializeCharts() {
|
| 1188 |
+
// HR Chart
|
| 1189 |
+
drawHRChart();
|
| 1190 |
+
}
|
| 1191 |
+
|
| 1192 |
+
function drawHRChart() {
|
| 1193 |
+
const canvas = document.getElementById('hr-chart');
|
| 1194 |
+
if (!canvas) return;
|
| 1195 |
+
|
| 1196 |
+
const ctx = canvas.getContext('2d');
|
| 1197 |
+
canvas.width = canvas.offsetWidth;
|
| 1198 |
+
canvas.height = 80;
|
| 1199 |
+
|
| 1200 |
+
// Generate random HR data
|
| 1201 |
+
const data = [];
|
| 1202 |
+
for (let i = 0; i < 50; i++) {
|
| 1203 |
+
data.push(60 + Math.random() * 20);
|
| 1204 |
+
}
|
| 1205 |
+
|
| 1206 |
+
// Draw line chart
|
| 1207 |
+
ctx.strokeStyle = '#ef4444';
|
| 1208 |
+
ctx.lineWidth = 2;
|
| 1209 |
+
ctx.beginPath();
|
| 1210 |
+
|
| 1211 |
+
const step = canvas.width / (data.length - 1);
|
| 1212 |
+
data.forEach((value, index) => {
|
| 1213 |
+
const x = index * step;
|
| 1214 |
+
const y = canvas.height - (value - 60) * 3;
|
| 1215 |
+
|
| 1216 |
+
if (index === 0) {
|
| 1217 |
+
ctx.moveTo(x, y);
|
| 1218 |
+
} else {
|
| 1219 |
+
ctx.lineTo(x, y);
|
| 1220 |
+
}
|
| 1221 |
+
});
|
| 1222 |
+
|
| 1223 |
+
ctx.stroke();
|
| 1224 |
+
}
|
| 1225 |
+
|
| 1226 |
+
function drawLiveHRChart() {
|
| 1227 |
+
const canvas = document.getElementById('live-hr-chart');
|
| 1228 |
+
if (!canvas) return;
|
| 1229 |
+
|
| 1230 |
+
const ctx = canvas.getContext('2d');
|
| 1231 |
+
canvas.width = canvas.offsetWidth;
|
| 1232 |
+
canvas.height = 100;
|
| 1233 |
+
|
| 1234 |
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
| 1235 |
+
|
| 1236 |
+
// Draw line chart
|
| 1237 |
+
ctx.strokeStyle = '#ef4444';
|
| 1238 |
+
ctx.lineWidth = 2;
|
| 1239 |
+
ctx.beginPath();
|
| 1240 |
+
|
| 1241 |
+
const step = canvas.width / (liveHRData.length - 1);
|
| 1242 |
+
liveHRData.forEach((value, index) => {
|
| 1243 |
+
const x = index * step;
|
| 1244 |
+
const y = canvas.height - (value - 100) * 1.5;
|
| 1245 |
+
|
| 1246 |
+
if (index === 0) {
|
| 1247 |
+
ctx.moveTo(x, y);
|
| 1248 |
+
} else {
|
| 1249 |
+
ctx.lineTo(x, y);
|
| 1250 |
+
}
|
| 1251 |
+
});
|
| 1252 |
+
|
| 1253 |
+
ctx.stroke();
|
| 1254 |
+
}
|
| 1255 |
+
|
| 1256 |
+
function drawRecoveryCharts() {
|
| 1257 |
+
drawHRVChart();
|
| 1258 |
+
drawRHRChart();
|
| 1259 |
+
}
|
| 1260 |
+
|
| 1261 |
+
function drawHRVChart() {
|
| 1262 |
+
const canvas = document.getElementById('hrv-chart');
|
| 1263 |
+
if (!canvas) return;
|
| 1264 |
+
|
| 1265 |
+
const ctx = canvas.getContext('2d');
|
| 1266 |
+
canvas.width = canvas.offsetWidth;
|
| 1267 |
+
canvas.height = 150;
|
| 1268 |
+
|
| 1269 |
+
ctx.strokeStyle = '#10b981';
|
| 1270 |
+
ctx.lineWidth = 2;
|
| 1271 |
+
ctx.beginPath();
|
| 1272 |
+
|
| 1273 |
+
const step = canvas.width / (mockData.hrv_data.length - 1);
|
| 1274 |
+
mockData.hrv_data.forEach((value, index) => {
|
| 1275 |
+
const x = index * step;
|
| 1276 |
+
const y = canvas.height - (value - 60);
|
| 1277 |
+
|
| 1278 |
+
if (index === 0) {
|
| 1279 |
+
ctx.moveTo(x, y);
|
| 1280 |
+
} else {
|
| 1281 |
+
ctx.lineTo(x, y);
|
| 1282 |
+
}
|
| 1283 |
+
});
|
| 1284 |
+
|
| 1285 |
+
ctx.stroke();
|
| 1286 |
+
}
|
| 1287 |
+
|
| 1288 |
+
function drawRHRChart() {
|
| 1289 |
+
const canvas = document.getElementById('rhr-chart');
|
| 1290 |
+
if (!canvas) return;
|
| 1291 |
+
|
| 1292 |
+
const ctx = canvas.getContext('2d');
|
| 1293 |
+
canvas.width = canvas.offsetWidth;
|
| 1294 |
+
canvas.height = 150;
|
| 1295 |
+
|
| 1296 |
+
const barWidth = canvas.width / mockData.rhr_data.length - 2;
|
| 1297 |
+
|
| 1298 |
+
mockData.rhr_data.forEach((value, index) => {
|
| 1299 |
+
const x = index * (barWidth + 2);
|
| 1300 |
+
const height = value * 2;
|
| 1301 |
+
const y = canvas.height - height;
|
| 1302 |
+
|
| 1303 |
+
ctx.fillStyle = '#f59e0b';
|
| 1304 |
+
ctx.fillRect(x, y, barWidth, height);
|
| 1305 |
+
});
|
| 1306 |
+
}
|
| 1307 |
+
|
| 1308 |
+
function drawSleepCharts() {
|
| 1309 |
+
drawSleepStagesChart();
|
| 1310 |
+
drawSleepHistoryChart();
|
| 1311 |
+
}
|
| 1312 |
+
|
| 1313 |
+
function drawSleepStagesChart() {
|
| 1314 |
+
const canvas = document.getElementById('sleep-stages-chart');
|
| 1315 |
+
if (!canvas) return;
|
| 1316 |
+
|
| 1317 |
+
const ctx = canvas.getContext('2d');
|
| 1318 |
+
canvas.width = canvas.offsetWidth;
|
| 1319 |
+
canvas.height = 150;
|
| 1320 |
+
|
| 1321 |
+
const stages = mockData.sleep.stages;
|
| 1322 |
+
let currentX = 0;
|
| 1323 |
+
|
| 1324 |
+
const colors = {
|
| 1325 |
+
'Awake': '#a855f7',
|
| 1326 |
+
'Light': '#60a5fa',
|
| 1327 |
+
'Deep': '#2563eb',
|
| 1328 |
+
'REM': '#06b6d4'
|
| 1329 |
+
};
|
| 1330 |
+
|
| 1331 |
+
stages.forEach(stage => {
|
| 1332 |
+
const width = (stage.duration / 360) * canvas.width;
|
| 1333 |
+
ctx.fillStyle = colors[stage.stage];
|
| 1334 |
+
ctx.fillRect(currentX, 0, width, canvas.height);
|
| 1335 |
+
currentX += width;
|
| 1336 |
+
});
|
| 1337 |
+
}
|
| 1338 |
+
|
| 1339 |
+
function drawSleepHistoryChart() {
|
| 1340 |
+
const canvas = document.getElementById('sleep-history-chart');
|
| 1341 |
+
if (!canvas) return;
|
| 1342 |
+
|
| 1343 |
+
const ctx = canvas.getContext('2d');
|
| 1344 |
+
canvas.width = canvas.offsetWidth;
|
| 1345 |
+
canvas.height = 150;
|
| 1346 |
+
|
| 1347 |
+
const data = mockData.sleep.history;
|
| 1348 |
+
const barWidth = canvas.width / data.length - 2;
|
| 1349 |
+
|
| 1350 |
+
data.forEach((day, index) => {
|
| 1351 |
+
const x = index * (barWidth + 2);
|
| 1352 |
+
const height = day.efficiency;
|
| 1353 |
+
const y = canvas.height - height;
|
| 1354 |
+
|
| 1355 |
+
ctx.fillStyle = '#3b82f6';
|
| 1356 |
+
ctx.fillRect(x, y, barWidth, height);
|
| 1357 |
+
});
|
| 1358 |
+
}
|
| 1359 |
+
|
| 1360 |
+
function drawTrendsCharts() {
|
| 1361 |
+
drawCombinedChart();
|
| 1362 |
+
drawHRVRHRChart();
|
| 1363 |
+
}
|
| 1364 |
+
|
| 1365 |
+
function drawCombinedChart() {
|
| 1366 |
+
const canvas = document.getElementById('combined-chart');
|
| 1367 |
+
if (!canvas) return;
|
| 1368 |
+
|
| 1369 |
+
const ctx = canvas.getContext('2d');
|
| 1370 |
+
canvas.width = canvas.offsetWidth;
|
| 1371 |
+
canvas.height = 200;
|
| 1372 |
+
|
| 1373 |
+
// Draw strain line
|
| 1374 |
+
ctx.strokeStyle = '#ef4444';
|
| 1375 |
+
ctx.lineWidth = 2;
|
| 1376 |
+
ctx.beginPath();
|
| 1377 |
+
|
| 1378 |
+
const step = canvas.width / (mockData.strain_history.length - 1);
|
| 1379 |
+
mockData.strain_history.forEach((day, index) => {
|
| 1380 |
+
const x = index * step;
|
| 1381 |
+
const y = canvas.height - day.strain * 10;
|
| 1382 |
+
|
| 1383 |
+
if (index === 0) {
|
| 1384 |
+
ctx.moveTo(x, y);
|
| 1385 |
+
} else {
|
| 1386 |
+
ctx.lineTo(x, y);
|
| 1387 |
+
}
|
| 1388 |
+
});
|
| 1389 |
+
ctx.stroke();
|
| 1390 |
+
|
| 1391 |
+
// Draw recovery line
|
| 1392 |
+
ctx.strokeStyle = '#22c55e';
|
| 1393 |
+
ctx.lineWidth = 2;
|
| 1394 |
+
ctx.beginPath();
|
| 1395 |
+
|
| 1396 |
+
mockData.recovery_history.slice(0, 30).forEach((day, index) => {
|
| 1397 |
+
const x = index * step;
|
| 1398 |
+
const y = canvas.height - day.recovery * 1.5;
|
| 1399 |
+
|
| 1400 |
+
if (index === 0) {
|
| 1401 |
+
ctx.moveTo(x, y);
|
| 1402 |
+
} else {
|
| 1403 |
+
ctx.lineTo(x, y);
|
| 1404 |
+
}
|
| 1405 |
+
});
|
| 1406 |
+
ctx.stroke();
|
| 1407 |
+
}
|
| 1408 |
+
|
| 1409 |
+
function drawHRVRHRChart() {
|
| 1410 |
+
const canvas = document.getElementById('hrv-rhr-chart');
|
| 1411 |
+
if (!canvas) return;
|
| 1412 |
+
|
| 1413 |
+
const ctx = canvas.getContext('2d');
|
| 1414 |
+
canvas.width = canvas.offsetWidth;
|
| 1415 |
+
canvas.height = 200;
|
| 1416 |
+
|
| 1417 |
+
// Draw scatter plot correlation
|
| 1418 |
+
mockData.recovery_history.forEach((day, index) => {
|
| 1419 |
+
const x = (day.hrv / 120) * canvas.width;
|
| 1420 |
+
const y = canvas.height - (day.rhr / 65) * canvas.height;
|
| 1421 |
+
|
| 1422 |
+
ctx.fillStyle = 'rgba(16, 185, 129, 0.6)';
|
| 1423 |
+
ctx.beginPath();
|
| 1424 |
+
ctx.arc(x, y, 4, 0, Math.PI * 2);
|
| 1425 |
+
ctx.fill();
|
| 1426 |
+
});
|
| 1427 |
+
}
|
| 1428 |
+
|
| 1429 |
+
function setTrendPeriod(period) {
|
| 1430 |
+
// Update button styles
|
| 1431 |
+
document.querySelectorAll('.flex.gap-2 button').forEach(btn => {
|
| 1432 |
+
btn.classList.remove('bg-primary/20', 'text-primary');
|
| 1433 |
+
btn.classList.add('hover:bg-gray-700/30');
|
| 1434 |
+
});
|
| 1435 |
+
event.target.classList.add('bg-primary/20', 'text-primary');
|
| 1436 |
+
event.target.classList.remove('hover:bg-gray-700/30');
|
| 1437 |
+
|
| 1438 |
+
// Redraw charts with new period
|
| 1439 |
+
drawTrendsCharts();
|
| 1440 |
+
}
|
| 1441 |
+
|
| 1442 |
+
// Update live HR
|
| 1443 |
+
function updateLiveHR() {
|
| 1444 |
+
const hr = 55 + Math.floor(Math.random() * 20);
|
| 1445 |
+
document.getElementById('current-hr').textContent = hr;
|
| 1446 |
+
document.getElementById('hr_current') && (document.getElementById('hr_current').textContent = hr);
|
| 1447 |
+
}
|
| 1448 |
+
|
| 1449 |
+
// Export data
|
| 1450 |
+
function exportData() {
|
| 1451 |
+
const dataStr = JSON.stringify(mockData, null, 2);
|
| 1452 |
+
const dataBlob = new Blob([dataStr], {type: 'application/json'});
|
| 1453 |
+
const url = URL.createObjectURL(dataBlob);
|
| 1454 |
+
const link = document.createElement('a');
|
| 1455 |
+
link.href = url;
|
| 1456 |
+
link.download = 'vitaltrack-data.json';
|
| 1457 |
+
link.click();
|
| 1458 |
+
showToast('Data exported successfully!');
|
| 1459 |
+
}
|
| 1460 |
+
|
| 1461 |
+
// Reset data
|
| 1462 |
+
function resetData() {
|
| 1463 |
+
if (confirm('Are you sure you want to reset all mock data?')) {
|
| 1464 |
+
location.reload();
|
| 1465 |
+
}
|
| 1466 |
+
}
|
| 1467 |
+
|
| 1468 |
+
// Toast notification
|
| 1469 |
+
function showToast(message) {
|
| 1470 |
+
const toast = document.createElement('div');
|
| 1471 |
+
toast.className = 'fixed top-20 left-1/2 transform -translate-x-1/2 bg-green-500 text-white px-4 py-2 rounded-lg shadow-lg z-50';
|
| 1472 |
+
toast.textContent = message;
|
| 1473 |
+
document.body.appendChild(toast);
|
| 1474 |
+
|
| 1475 |
+
setTimeout(() => {
|
| 1476 |
+
toast.remove();
|
| 1477 |
+
}, 3000);
|
| 1478 |
+
}
|
| 1479 |
+
|
| 1480 |
+
// Load saved preferences
|
| 1481 |
+
function loadPreferences() {
|
| 1482 |
+
const savedTheme = localStorage.getItem('theme');
|
| 1483 |
+
if (savedTheme === 'light') {
|
| 1484 |
+
toggleTheme();
|
| 1485 |
+
}
|
| 1486 |
+
|
| 1487 |
+
const savedLang = localStorage.getItem('language');
|
| 1488 |
+
if (savedLang) {
|
| 1489 |
+
currentLang = savedLang;
|
| 1490 |
+
document.getElementById('lang-toggle').textContent = currentLang.toUpperCase();
|
| 1491 |
+
toggleLanguage();
|
| 1492 |
+
}
|
| 1493 |
+
}
|
| 1494 |
+
|
| 1495 |
+
// Initialize on load
|
| 1496 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 1497 |
+
loadPreferences();
|
| 1498 |
+
initApp();
|
| 1499 |
+
});
|
| 1500 |
+
|
| 1501 |
+
// Handle resize
|
| 1502 |
+
window.addEventListener('resize', () => {
|
| 1503 |
+
drawHRChart();
|
| 1504 |
+
if (document.getElementById('tab-recovery').classList.contains('active')) {
|
| 1505 |
+
drawRecoveryCharts();
|
| 1506 |
+
} else if (document.getElementById('tab-sleep').classList.contains('active')) {
|
| 1507 |
+
drawSleepCharts();
|
| 1508 |
+
} else if (document.getElementById('tab-trends').classList.contains('active')) {
|
| 1509 |
+
drawTrendsCharts();
|
| 1510 |
+
}
|
| 1511 |
+
});
|
| 1512 |
+
</script>
|
| 1513 |
+
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
|
| 1514 |
+
</body>
|
| 1515 |
+
</html>
|