Spaces:
Running
Running
ช่วยแก้ code ต่อ และทำเว็บให้สมบรูณ์ที
Browse files- activity.html +342 -0
- components/ai-coach-card.js +340 -6
- login.html +122 -0
- manifest.json +29 -0
- nutrition.html +321 -0
- profile.html +295 -0
- service-worker.js +108 -0
- sleep.html +259 -0
activity.html
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
```html
|
| 2 |
+
<!DOCTYPE html>
|
| 3 |
+
<html lang="th" class="dark">
|
| 4 |
+
<head>
|
| 5 |
+
<meta charset="UTF-8">
|
| 6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
| 7 |
+
<title>ออกกำลังกาย - ชีพจร</title>
|
| 8 |
+
<link rel="icon" type="image/x-icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🌿</text></svg>">
|
| 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://cdn.jsdelivr.net/npm/chart.js"></script>
|
| 12 |
+
<link rel="stylesheet" href="style.css">
|
| 13 |
+
</head>
|
| 14 |
+
<body class="bg-gray-900 text-white font-sans pb-20">
|
| 15 |
+
<!-- Main Container -->
|
| 16 |
+
<div class="min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900">
|
| 17 |
+
<!-- Header -->
|
| 18 |
+
<header class="px-4 pt-12 pb-6">
|
| 19 |
+
<div class="flex items-center justify-between">
|
| 20 |
+
<div>
|
| 21 |
+
<h1 class="text-2xl font-bold bg-gradient-to-r from-orange-400 to-red-500 bg-clip-text text-transparent">
|
| 22 |
+
ออกกำลังกาย
|
| 23 |
+
</h1>
|
| 24 |
+
<p class="text-gray-400 text-sm mt-1">พร้อมที่จะเผาผลาญแคลอรีหรือยัง? 🔥</p>
|
| 25 |
+
</div>
|
| 26 |
+
<button onclick="window.location.href='index.html'" class="w-10 h-10 rounded-full bg-gray-800 flex items-center justify-center">
|
| 27 |
+
<i data-feather="arrow-left" class="w-5 h-5"></i>
|
| 28 |
+
</button>
|
| 29 |
+
</div>
|
| 30 |
+
</header>
|
| 31 |
+
|
| 32 |
+
<!-- Today's Activity -->
|
| 33 |
+
<section class="px-4 mb-6">
|
| 34 |
+
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
|
| 35 |
+
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
|
| 36 |
+
<i data-feather="activity" class="w-5 h-5 text-orange-400"></i>
|
| 37 |
+
กิจกรรมวันนี้
|
| 38 |
+
</h3>
|
| 39 |
+
|
| 40 |
+
<div class="grid grid-cols-2 gap-4 mb-4">
|
| 41 |
+
<div class="text-center">
|
| 42 |
+
<p class="text-3xl font-bold text-orange-400">1,247</p>
|
| 43 |
+
<p class="text-xs text-gray-400">แคลอรีเผาผลาญ</p>
|
| 44 |
+
</div>
|
| 45 |
+
<div class="text-center">
|
| 46 |
+
<p class="text-3xl font-bold text-blue-400">8,247</p>
|
| 47 |
+
<p class="text-xs text-gray-400">จำนวนก้าว</p>
|
| 48 |
+
</div>
|
| 49 |
+
</div>
|
| 50 |
+
|
| 51 |
+
<div class="bg-gray-800/50 rounded-xl p-3">
|
| 52 |
+
<div class="flex items-center justify-between mb-2">
|
| 53 |
+
<span class="text-sm text-gray-400">เป้าหมายรายวัน</span>
|
| 54 |
+
<span class="text-sm font-medium">82%</span>
|
| 55 |
+
</div>
|
| 56 |
+
<div class="bg-gray-700 rounded-full h-3">
|
| 57 |
+
<div class="bg-gradient-to-r from-orange-400 to-red-500 h-3 rounded-full" style="width: 82%"></div>
|
| 58 |
+
</div>
|
| 59 |
+
</div>
|
| 60 |
+
</div>
|
| 61 |
+
</section>
|
| 62 |
+
|
| 63 |
+
<!-- Workout Logger -->
|
| 64 |
+
<section class="px-4 mb-6">
|
| 65 |
+
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
|
| 66 |
+
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
|
| 67 |
+
<i data-feather="play-circle" class="w-5 h-5 text-green-400"></i>
|
| 68 |
+
เริ่มออกกำลังกาย
|
| 69 |
+
</h3>
|
| 70 |
+
|
| 71 |
+
<div class="grid grid-cols-2 gap-3">
|
| 72 |
+
<button class="workout-type-btn p-4 bg-gradient-to-r from-red-500 to-pink-600 rounded-xl text-center" data-workout="boxing">
|
| 73 |
+
<div class="text-2xl mb-1">🥊</div>
|
| 74 |
+
<div class="text-sm font-medium">มวยไทย</div>
|
| 75 |
+
<div class="text-xs text-gray-200">45 นาที</div>
|
| 76 |
+
</button>
|
| 77 |
+
|
| 78 |
+
<button class="workout-type-btn p-4 bg-gradient-to-r from-blue-500 to-indigo-600 rounded-xl text-center" data-workout="yoga">
|
| 79 |
+
<div class="text-2xl mb-1">🧘</div>
|
| 80 |
+
<div class="text-sm font-medium">โยคะ</div>
|
| 81 |
+
<div class="text-xs text-gray-200">30 นาที</div>
|
| 82 |
+
</button>
|
| 83 |
+
|
| 84 |
+
<button class="workout-type-btn p-4 bg-gradient-to-r from-green-500 to-emerald-600 rounded-xl text-center" data-workout="running">
|
| 85 |
+
<div class="text-2xl mb-1">🏃</div>
|
| 86 |
+
<div class="text-sm font-medium">วิ่ง</div>
|
| 87 |
+
<div class="text-xs text-gray-200">30 นาที</div>
|
| 88 |
+
</button>
|
| 89 |
+
|
| 90 |
+
<button class="workout-type-btn p-4 bg-gradient-to-r from-purple-500 to-pink-600 rounded-xl text-center" data-workout="strength">
|
| 91 |
+
<div class="text-2xl mb-1">💪</div>
|
| 92 |
+
<div class="text-sm font-medium">เวทเทรนนิ่ง</div>
|
| 93 |
+
<div class="text-xs text-gray-200">40 นาที</div>
|
| 94 |
+
</button>
|
| 95 |
+
</div>
|
| 96 |
+
</div>
|
| 97 |
+
</section>
|
| 98 |
+
|
| 99 |
+
<!-- Recent Workouts -->
|
| 100 |
+
<section class="px-4 mb-6">
|
| 101 |
+
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
|
| 102 |
+
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
|
| 103 |
+
<i data-feather="calendar" class="w-5 h-5 text-green-400"></i>
|
| 104 |
+
ประวัติการออกกำลังกาย
|
| 105 |
+
</h3>
|
| 106 |
+
|
| 107 |
+
<div class="space-y-3" id="workoutHistory">
|
| 108 |
+
<div class="p-3 bg-gray-800/30 rounded-xl border border-gray-700/30">
|
| 109 |
+
<div class="flex items-center justify-between">
|
| 110 |
+
<div class="flex items-center gap-3">
|
| 111 |
+
<div class="w-10 h-10 bg-red-500 rounded-lg flex items-center justify-center">
|
| 112 |
+
<span class="text-lg">🥊</span>
|
| 113 |
+
</div>
|
| 114 |
+
<div>
|
| 115 |
+
<p class="font-medium text-sm">มวยไทย</p>
|
| 116 |
+
<p class="text-xs text-gray-400">เมื่อวาน • 45 นาที</p>
|
| 117 |
+
</div>
|
| 118 |
+
</div>
|
| 119 |
+
<div class="text-right">
|
| 120 |
+
<p class="text-sm font-medium text-orange-400">-520 แคล</p>
|
| 121 |
+
<p class="text-xs text-gray-400">Heart Rate: 145 bpm</p>
|
| 122 |
+
</div>
|
| 123 |
+
</div>
|
| 124 |
+
</div>
|
| 125 |
+
|
| 126 |
+
<div class="p-3 bg-gray-800/30 rounded-xl border border-gray-700/30">
|
| 127 |
+
<div class="flex items-center justify-between">
|
| 128 |
+
<div class="flex items-center gap-3">
|
| 129 |
+
<div class="w-10 h-10 bg-blue-500 rounded-lg flex items-center justify-center">
|
| 130 |
+
<span class="text-lg">🧘</span>
|
| 131 |
+
</div>
|
| 132 |
+
<div>
|
| 133 |
+
<p class="font-medium text-sm">โยคะคลายเครียด</p>
|
| 134 |
+
<p class="text-xs text-gray-400">2 วันก่อน • 30 นาที</p>
|
| 135 |
+
</div>
|
| 136 |
+
</div>
|
| 137 |
+
<div class="text-right">
|
| 138 |
+
<p class="text-sm font-medium text-blue-400">-180 แคล</p>
|
| 139 |
+
<p class="text-xs text-gray-400">Heart Rate: 85 bpm</p>
|
| 140 |
+
</div>
|
| 141 |
+
</div>
|
| 142 |
+
</div>
|
| 143 |
+
</div>
|
| 144 |
+
</div>
|
| 145 |
+
</section>
|
| 146 |
+
|
| 147 |
+
<!-- Heart Rate Zones -->
|
| 148 |
+
<section class="px-4 mb-6">
|
| 149 |
+
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
|
| 150 |
+
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
|
| 151 |
+
<i data-feather="heart" class="w-5 h-5 text-red-400"></i>
|
| 152 |
+
Heart Rate Zones วันนี้
|
| 153 |
+
</h3>
|
| 154 |
+
|
| 155 |
+
<div class="space-y-2">
|
| 156 |
+
<div class="flex items-center gap-3">
|
| 157 |
+
<div class="w-4 h-4 bg-gray-500 rounded"></div>
|
| 158 |
+
<div class="flex-1">
|
| 159 |
+
<div class="flex justify-between text-xs mb-1">
|
| 160 |
+
<span>พักผ่อน (50-60%)</span>
|
| 161 |
+
<span>2.5 ชม.</span>
|
| 162 |
+
</div>
|
| 163 |
+
<div class="bg-gray-700 rounded-full h-2">
|
| 164 |
+
<div class="bg-gray-500 h-2 rounded-full" style="width: 35%"></div>
|
| 165 |
+
</div>
|
| 166 |
+
</div>
|
| 167 |
+
</div>
|
| 168 |
+
|
| 169 |
+
<div class="flex items-center gap-3">
|
| 170 |
+
<div class="w-4 h-4 bg-blue-500 rounded"></div>
|
| 171 |
+
<div class="flex-1">
|
| 172 |
+
<div class="flex justify-between text-xs mb-1">
|
| 173 |
+
<span>เบา (60-70%)</span>
|
| 174 |
+
<span>3.2 ชม.</span>
|
| 175 |
+
</div>
|
| 176 |
+
<div class="bg-gray-700 rounded-full h-2">
|
| 177 |
+
<div class="bg-blue-500 h-2 rounded-full" style="width: 45%"></div>
|
| 178 |
+
</div>
|
| 179 |
+
</div>
|
| 180 |
+
</div>
|
| 181 |
+
|
| 182 |
+
<div class="flex items-center gap-3">
|
| 183 |
+
<div class="w-4 h-4 bg-green-500 rounded"></div>
|
| 184 |
+
<div class="flex-1">
|
| 185 |
+
<div class="flex justify-between text-xs mb-1">
|
| 186 |
+
<span>กลาง (70-85%)</span>
|
| 187 |
+
<span>1.8 ชม.</span>
|
| 188 |
+
</div>
|
| 189 |
+
<div class="bg-gray-700 rounded-full h-2">
|
| 190 |
+
<div class="bg-green-500 h-2 rounded-full" style="width: 25%"></div>
|
| 191 |
+
</div>
|
| 192 |
+
</div>
|
| 193 |
+
</div>
|
| 194 |
+
|
| 195 |
+
<div class="flex items-center gap-3">
|
| 196 |
+
<div class="w-4 h-4 bg-red-500 rounded"></div>
|
| 197 |
+
<div class="flex-1">
|
| 198 |
+
<div class="flex justify-between text-xs mb-1">
|
| 199 |
+
<span>หนัก (85-95%)</span>
|
| 200 |
+
<span>45 นาที</span>
|
| 201 |
+
</div>
|
| 202 |
+
<div class="bg-gray-700 rounded-full h-2">
|
| 203 |
+
<div class="bg-red-500 h-2 rounded-full" style="width: 15%"></div>
|
| 204 |
+
</div>
|
| 205 |
+
</div>
|
| 206 |
+
</div>
|
| 207 |
+
</div>
|
| 208 |
+
</div>
|
| 209 |
+
</section>
|
| 210 |
+
</div>
|
| 211 |
+
|
| 212 |
+
<!-- Bottom Navigation -->
|
| 213 |
+
<main-navbar></main-navbar>
|
| 214 |
+
|
| 215 |
+
<!-- Workout Modal -->
|
| 216 |
+
<div id="workoutModal" class="fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4 hidden">
|
| 217 |
+
<div class="glass-card rounded-2xl p-6 max-w-sm w-full border border-gray-700/50">
|
| 218 |
+
<div class="text-center">
|
| 219 |
+
<div class="text-4xl mb-3" id="workoutEmoji">🥊</div>
|
| 220 |
+
<h3 class="text-xl font-bold mb-2" id="workoutName">มวยไทย</h3>
|
| 221 |
+
<p class="text-gray-400 mb-6" id="workoutDuration">45 นาที</p>
|
| 222 |
+
|
| 223 |
+
<div class="space-y-4">
|
| 224 |
+
<button onclick="startWorkout()" class="w-full bg-gradient-to-r from-green-500 to-emerald-600 py-3 rounded-xl font-medium transition-all hover:scale-[1.02]">
|
| 225 |
+
เริ่มออกกำลังกาย
|
| 226 |
+
</button>
|
| 227 |
+
<button onclick="closeWorkoutModal()" class="w-full bg-gray-700 hover:bg-gray-600 py-3 rounded-xl font-medium transition-colors">
|
| 228 |
+
ยกเลิก
|
| 229 |
+
</button>
|
| 230 |
+
</div>
|
| 231 |
+
</div>
|
| 232 |
+
</div>
|
| 233 |
+
</div>
|
| 234 |
+
|
| 235 |
+
<!-- Scripts -->
|
| 236 |
+
<script src="components/navbar.js"></script>
|
| 237 |
+
<script src="script.js"></script>
|
| 238 |
+
<script>
|
| 239 |
+
let selectedWorkout = null;
|
| 240 |
+
|
| 241 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 242 |
+
// Set active page in navbar
|
| 243 |
+
const navbar = document.querySelector('main-navbar');
|
| 244 |
+
if (navbar) {
|
| 245 |
+
navbar.setActivePage('activity');
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
// Workout type buttons
|
| 249 |
+
document.querySelectorAll('.workout-type-btn').forEach(btn => {
|
| 250 |
+
btn.addEventListener('click', function() {
|
| 251 |
+
const type = this.dataset.workout;
|
| 252 |
+
openWorkoutModal(type);
|
| 253 |
+
});
|
| 254 |
+
});
|
| 255 |
+
});
|
| 256 |
+
|
| 257 |
+
function openWorkoutModal(type) {
|
| 258 |
+
const workouts = {
|
| 259 |
+
boxing: { name: 'มวยไทย', duration: '45 นาที', emoji: '🥊' },
|
| 260 |
+
yoga: { name: 'โยคะ', duration: '30 นาที', emoji: '🧘' },
|
| 261 |
+
running: { name: 'วิ่ง', duration: '30 นาที', emoji: '🏃' },
|
| 262 |
+
strength: { name: 'เวทเทรนนิ่ง', duration: '40 นาที', emoji: '💪' }
|
| 263 |
+
};
|
| 264 |
+
|
| 265 |
+
selectedWorkout = workouts[type];
|
| 266 |
+
|
| 267 |
+
document.getElementById('workoutEmoji').textContent = selectedWorkout.emoji;
|
| 268 |
+
document.getElementById('workoutName').textContent = selectedWorkout.name;
|
| 269 |
+
document.getElementById('workoutDuration').textContent = selectedWorkout.duration;
|
| 270 |
+
document.getElementById('workoutModal').classList.remove('hidden');
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
function closeWorkoutModal() {
|
| 274 |
+
document.getElementById('workoutModal').classList.add('hidden');
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
function startWorkout() {
|
| 278 |
+
if (!selectedWorkout) return;
|
| 279 |
+
|
| 280 |
+
showNotification(`เริ่ม ${selectedWorkout.name} ${selectedWorkout.duration} สำเร็จ!`, 'success');
|
| 281 |
+
closeWorkoutModal();
|
| 282 |
+
|
| 283 |
+
// Simulate workout session
|
| 284 |
+
simulateWorkoutSession(selectedWorkout);
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
function simulateWorkoutSession(workout) {
|
| 288 |
+
const modal = document.createElement('div');
|
| 289 |
+
modal.className = 'fixed inset-0 bg-black/80 z-50 flex items-center justify-center p-4';
|
| 290 |
+
modal.innerHTML = `
|
| 291 |
+
<div class="glass-card rounded-2xl p-6 max-w-md w-full border border-gray-700/50 text-center">
|
| 292 |
+
<div class="text-6xl mb-4">${workout.emoji}</div>
|
| 293 |
+
<h3 class="text-2xl font-bold mb-2">${workout.name}</h3>
|
| 294 |
+
<div class="text-4xl font-mono text-green-400 my-6" id="workoutTimer">00:00</div>
|
| 295 |
+
<div class="text-sm text-gray-400 mb-4">Heart Rate: <span id="hrValue">85</span> bpm</div>
|
| 296 |
+
<button onclick="endWorkout(this)" class="w-full bg-red-500 hover:bg-red-600 py-3 rounded-xl font-medium transition-colors">
|
| 297 |
+
หยุดออกกำลังกาย
|
| 298 |
+
</button>
|
| 299 |
+
</div>
|
| 300 |
+
`;
|
| 301 |
+
|
| 302 |
+
document.body.appendChild(modal);
|
| 303 |
+
|
| 304 |
+
// Start timer
|
| 305 |
+
let seconds = 0;
|
| 306 |
+
const timer = setInterval(() => {
|
| 307 |
+
seconds++;
|
| 308 |
+
const mins = Math.floor(seconds / 60);
|
| 309 |
+
const secs = seconds % 60;
|
| 310 |
+
modal.querySelector('#workoutTimer').textContent =
|
| 311 |
+
`${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
|
| 312 |
+
|
| 313 |
+
// Simulate HR
|
| 314 |
+
const hr = 85 + Math.floor(Math.random() * 60);
|
| 315 |
+
modal.querySelector('#hrValue').textContent = hr;
|
| 316 |
+
}, 1000);
|
| 317 |
+
|
| 318 |
+
modal.addEventListener('remove', () => clearInterval(timer));
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
function endWorkout(btn) {
|
| 322 |
+
const modal = btn.closest('.fixed');
|
| 323 |
+
showNotification('ออกกำลังกายเสร็จสิ้น! เยี่ยมมากค่ะ', 'success');
|
| 324 |
+
modal.remove();
|
| 325 |
+
|
| 326 |
+
// Update stats
|
| 327 |
+
updateActivityStats();
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
function updateActivityStats() {
|
| 331 |
+
// Simulate updating stats
|
| 332 |
+
const caloriesElement = document.querySelector('.text-3xl.font-bold.text-orange-400');
|
| 333 |
+
if (caloriesElement) {
|
| 334 |
+
const currentCalories = parseInt(caloriesElement.textContent);
|
| 335 |
+
caloriesElement.textContent = currentCalories + 250;
|
| 336 |
+
}
|
| 337 |
+
}
|
| 338 |
+
</script>
|
| 339 |
+
<script>feather.replace();</script>
|
| 340 |
+
</body>
|
| 341 |
+
</html>
|
| 342 |
+
>>>>>>> REPLACE
|
components/ai-coach-card.js
CHANGED
|
@@ -150,9 +150,343 @@ class AICoachCard extends HTMLElement {
|
|
| 150 |
display: inline-flex;
|
| 151 |
gap: 0.2rem;
|
| 152 |
}
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
+
gap: 0.2rem;
|
| 156 |
+
margin-left: 0.25rem;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
.typing-dot {
|
| 160 |
+
width: 4px;
|
| 161 |
+
height: 4px;
|
| 162 |
+
background: #34d399;
|
| 163 |
+
border-radius: 50%;
|
| 164 |
+
animation: typingDot 1.4s infinite;
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
.typing-dot:nth-child(2) {
|
| 168 |
+
animation-delay: 0.2s;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
.typing-dot:nth-child(3) {
|
| 172 |
+
animation-delay: 0.4s;
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
@keyframes typingDot {
|
| 176 |
+
0%, 60%, 100% {
|
| 177 |
+
transform: translateY(0);
|
| 178 |
+
}
|
| 179 |
+
30% {
|
| 180 |
+
transform: translateY(-10px);
|
| 181 |
+
}
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
.coach-message.typing::after {
|
| 185 |
+
content: '';
|
| 186 |
+
display: inline-block;
|
| 187 |
+
width: 2px;
|
| 188 |
+
height: 1em;
|
| 189 |
+
background: #34d399;
|
| 190 |
+
margin-left: 2px;
|
| 191 |
+
animation: blink 1s infinite;
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
@keyframes blink {
|
| 195 |
+
0%, 50% { opacity: 1; }
|
| 196 |
+
51%, 100% { opacity: 0; }
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
.pulse-ring {
|
| 200 |
+
position: absolute;
|
| 201 |
+
top: 0;
|
| 202 |
+
left: 0;
|
| 203 |
+
right: 0;
|
| 204 |
+
bottom: 0;
|
| 205 |
+
border-radius: 1.25rem;
|
| 206 |
+
border: 2px solid transparent;
|
| 207 |
+
animation: pulse-ring 2s cubic-bezier(0.455, 0.03, 0.515, 0.955) infinite;
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
@keyframes pulse-ring {
|
| 211 |
+
0% {
|
| 212 |
+
transform: scale(0.9);
|
| 213 |
+
border-color: rgba(52, 211, 153, 0.6);
|
| 214 |
+
}
|
| 215 |
+
100% {
|
| 216 |
+
transform: scale(1.05);
|
| 217 |
+
border-color: transparent;
|
| 218 |
+
}
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
.typing-indicator {
|
| 222 |
+
position: absolute;
|
| 223 |
+
bottom: 0.5rem;
|
| 224 |
+
right: 0.5rem;
|
| 225 |
+
font-size: 0.6rem;
|
| 226 |
+
color: #34d399;
|
| 227 |
+
opacity: 0;
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
.typing-indicator.active {
|
| 231 |
+
opacity: 1;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
.typing-indicator::after {
|
| 235 |
+
content: 'กำลังพิมพ์';
|
| 236 |
+
animation: typingText 2s infinite;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
@keyframes typingText {
|
| 240 |
+
0% { content: 'กำลังพิมพ์'; }
|
| 241 |
+
33% { content: 'กำลังพิมพ์.'; }
|
| 242 |
+
66% { content: 'กำลังพิมพ์..'; }
|
| 243 |
+
100% { content: 'กำลังพิมพ์...'; }
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
.coach-timestamp {
|
| 247 |
+
font-size: 0.6rem;
|
| 248 |
+
color: #6b7280;
|
| 249 |
+
position: absolute;
|
| 250 |
+
bottom: 0.5rem;
|
| 251 |
+
right: 0.5rem;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
.action-buttons {
|
| 255 |
+
display: flex;
|
| 256 |
+
gap: 0.5rem;
|
| 257 |
+
margin-top: 0.75rem;
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
.action-btn {
|
| 261 |
+
flex: 1;
|
| 262 |
+
padding: 0.4rem 0.75rem;
|
| 263 |
+
background: rgba(52, 211, 153, 0.1);
|
| 264 |
+
border: 1px solid rgba(52, 211, 153, 0.3);
|
| 265 |
+
border-radius: 0.5rem;
|
| 266 |
+
color: #34d399;
|
| 267 |
+
font-size: 0.7rem;
|
| 268 |
+
font-weight: 500;
|
| 269 |
+
cursor: pointer;
|
| 270 |
+
transition: all 0.3s ease;
|
| 271 |
+
font-family: 'Prompt', sans-serif;
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
.action-btn:hover {
|
| 275 |
+
background: rgba(52, 211, 153, 0.2);
|
| 276 |
+
transform: translateY(-1px);
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
.action-btn.secondary {
|
| 280 |
+
color: #a78bfa;
|
| 281 |
+
border-color: rgba(167, 139, 250, 0.3);
|
| 282 |
+
background: rgba(167, 139, 250, 0.1);
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
.action-btn.secondary:hover {
|
| 286 |
+
background: rgba(167, 139, 250, 0.2);
|
| 287 |
+
}
|
| 288 |
+
</style>
|
| 289 |
+
|
| 290 |
+
<div class="coach-card">
|
| 291 |
+
<div class="pulse-ring"></div>
|
| 292 |
+
|
| 293 |
+
<div class="coach-header">
|
| 294 |
+
<div class="coach-info">
|
| 295 |
+
<div class="coach-title">
|
| 296 |
+
<div class="coach-avatar">
|
| 297 |
+
<svg class="coach-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
| 298 |
+
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z"/>
|
| 299 |
+
<path d="M8 14s1.5 2 4 2 4-2 4-2"/>
|
| 300 |
+
<line x1="9" y1="9" x2="9.01" y2="9"/>
|
| 301 |
+
<line x1="15" y1="9" x2="15.01" y2="9"/>
|
| 302 |
+
</svg>
|
| 303 |
+
</div>
|
| 304 |
+
<div class="coach-title-text">
|
| 305 |
+
<div class="coach-name">AI Coach พิมพ์</div>
|
| 306 |
+
<div class="coach-badge">อัจฉริยะ</div>
|
| 307 |
+
</div>
|
| 308 |
+
</div>
|
| 309 |
+
</div>
|
| 310 |
+
<div class="coach-actions-container">
|
| 311 |
+
<div class="typing-indicator" id="typingIndicator"></div>
|
| 312 |
+
<div class="coach-timestamp" id="timestamp"></div>
|
| 313 |
+
</div>
|
| 314 |
+
</div>
|
| 315 |
+
|
| 316 |
+
<div class="coach-message ${this.isTyping ? 'typing' : ''}" id="message">
|
| 317 |
+
${this.currentMessage}
|
| 318 |
+
</div>
|
| 319 |
+
|
| 320 |
+
<div class="action-buttons" id="actionButtons"></div>
|
| 321 |
+
</div>
|
| 322 |
+
`;
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
// Public API method
|
| 326 |
+
updateMessage(message, actions = []) {
|
| 327 |
+
this.currentMessage = message;
|
| 328 |
+
this.isTyping = true;
|
| 329 |
+
this.render();
|
| 330 |
+
|
| 331 |
+
// Simulate typing delay
|
| 332 |
+
setTimeout(() => {
|
| 333 |
+
this.isTyping = false;
|
| 334 |
+
this.render();
|
| 335 |
+
this.updateTimestamp();
|
| 336 |
+
this.renderActions(actions);
|
| 337 |
+
}, 1000 + Math.random() * 1500);
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
renderActions(actions) {
|
| 341 |
+
const container = this.shadowRoot.getElementById('actionButtons');
|
| 342 |
+
if (actions.length === 0) {
|
| 343 |
+
container.innerHTML = '';
|
| 344 |
+
return;
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
container.innerHTML = actions.map(action => `
|
| 348 |
+
<button class="action-btn ${action.type || ''}" data-action="${action.id}">
|
| 349 |
+
${action.label}
|
| 350 |
+
</button>
|
| 351 |
+
`).join('');
|
| 352 |
+
|
| 353 |
+
// Add event listeners
|
| 354 |
+
container.querySelectorAll('.action-btn').forEach(btn => {
|
| 355 |
+
btn.addEventListener('click', (e) => {
|
| 356 |
+
const actionId = e.target.dataset.action;
|
| 357 |
+
this.handleAction(actionId);
|
| 358 |
+
});
|
| 359 |
+
});
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
updateTimestamp() {
|
| 363 |
+
const now = new Date();
|
| 364 |
+
const timestamp = this.shadowRoot.getElementById('timestamp');
|
| 365 |
+
timestamp.textContent = `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}`;
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
generateSmartMessage() {
|
| 369 |
+
const templates = [
|
| 370 |
+
{
|
| 371 |
+
condition: () => AppState.currentUser.recovery > 80,
|
| 372 |
+
message: "วันนี้คุณฟื้นตัวเต็มที่! เหมาะสำหรับการออกกำลังกายระดับกลาง-หนัก",
|
| 373 |
+
actions: [
|
| 374 |
+
{ id: 'workout', label: 'เริ่มออกกำลัง', type: 'primary' },
|
| 375 |
+
{ id: 'nutrition', label: 'วางแผนมื้ออาหาร', type: 'secondary' }
|
| 376 |
+
]
|
| 377 |
+
},
|
| 378 |
+
{
|
| 379 |
+
condition: () => AppState.currentUser.recovery < 50,
|
| 380 |
+
message: "วันนี้ร่างกายของคุณยังฟื้นตัวไม่เต็มที่ ควรพักผ่อนเพิ่มเติม",
|
| 381 |
+
actions: [
|
| 382 |
+
{ id: 'meditation', label: 'นั่งสมาธิ', type: 'primary' },
|
| 383 |
+
{ id: 'sleep', label: 'ดูคุณภาพการนอน', type: 'secondary' }
|
| 384 |
+
]
|
| 385 |
+
},
|
| 386 |
+
{
|
| 387 |
+
condition: () => AppState.currentUser.strain > 15,
|
| 388 |
+
message: "ความเครียดสะสมอยู่ในระดับสูง แนะนำให้ทำกิจกรรมผ่อนคลาย",
|
| 389 |
+
actions: [
|
| 390 |
+
{ id: 'breathing', label: 'หายใจลึกๆ', type: 'primary' },
|
| 391 |
+
{ id: 'yoga', label: 'โยคะคลายเครียด', type: 'secondary' }
|
| 392 |
+
]
|
| 393 |
+
}
|
| 394 |
+
];
|
| 395 |
+
|
| 396 |
+
const match = templates.find(t => t.condition());
|
| 397 |
+
if (match) {
|
| 398 |
+
this.updateMessage(match.message, match.actions);
|
| 399 |
+
}
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
handleAction(actionId) {
|
| 403 |
+
switch(actionId) {
|
| 404 |
+
case 'workout':
|
| 405 |
+
window.location.href = 'activity.html';
|
| 406 |
+
break;
|
| 407 |
+
case 'nutrition':
|
| 408 |
+
window.location.href = 'nutrition.html';
|
| 409 |
+
break;
|
| 410 |
+
case 'meditation':
|
| 411 |
+
showNotification('กำลังเปิดการฝึกสมาธิ...', 'success');
|
| 412 |
+
break;
|
| 413 |
+
case 'sleep':
|
| 414 |
+
window.location.href = 'sleep.html';
|
| 415 |
+
break;
|
| 416 |
+
case 'breathing':
|
| 417 |
+
this.startBreathingExercise();
|
| 418 |
+
break;
|
| 419 |
+
case 'yoga':
|
| 420 |
+
showNotification('กำลังเปิดวิดีโอโยคะ...', 'success');
|
| 421 |
+
break;
|
| 422 |
+
default:
|
| 423 |
+
showNotification('ฟีเจอร์นี้กำลังพัฒนา...', 'info');
|
| 424 |
+
}
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
startBreathingExercise() {
|
| 428 |
+
const modal = document.createElement('div');
|
| 429 |
+
modal.className = 'fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4';
|
| 430 |
+
modal.innerHTML = `
|
| 431 |
+
<div class="glass-card rounded-2xl p-6 max-w-sm w-full border border-gray-700/50">
|
| 432 |
+
<h3 class="text-xl font-bold mb-4 text-center">ฝึกหายใจลึกๆ</h3>
|
| 433 |
+
<div class="w-32 h-32 mx-auto mb-4 rounded-full bg-gradient-to-r from-blue-400 to-indigo-500 flex items-center justify-center" id="breathingCircle">
|
| 434 |
+
<span class="text-white font-bold text-lg" id="breathingText">เริ่ม</span>
|
| 435 |
+
</div>
|
| 436 |
+
<p class="text-center text-sm text-gray-400 mb-4">หายใจเข้าลึกๆ 4 วินาที กลั้น 4 วินาที หายใจออก 4 วินาที</p>
|
| 437 |
+
<button onclick="this.closest('.fixed').remove()" class="w-full bg-gray-700 hover:bg-gray-600 py-3 rounded-xl font-medium transition-colors">
|
| 438 |
+
หยุด
|
| 439 |
+
</button>
|
| 440 |
+
</div>
|
| 441 |
+
`;
|
| 442 |
+
|
| 443 |
+
document.body.appendChild(modal);
|
| 444 |
+
|
| 445 |
+
// Breathing animation logic would go here
|
| 446 |
+
this.runBreathingCycle(modal);
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
runBreathingCycle(modal) {
|
| 450 |
+
const circle = modal.querySelector('#breathingCircle');
|
| 451 |
+
const text = modal.querySelector('#breathingText');
|
| 452 |
+
const phases = ['หายใจเข้า', 'กลั้น', 'หายใจออก', 'กลั้น'];
|
| 453 |
+
let phase = 0;
|
| 454 |
+
|
| 455 |
+
const interval = setInterval(() => {
|
| 456 |
+
text.textContent = phases[phase];
|
| 457 |
+
circle.style.transform = phase === 0 ? 'scale(1.3)' : phase === 2 ? 'scale(0.8)' : 'scale(1)';
|
| 458 |
+
phase = (phase + 1) % 4;
|
| 459 |
+
}, 4000);
|
| 460 |
+
|
| 461 |
+
modal.addEventListener('remove', () => clearInterval(interval));
|
| 462 |
+
}
|
| 463 |
+
|
| 464 |
+
connectedCallback() {
|
| 465 |
+
this.attachShadow({ mode: 'open' });
|
| 466 |
+
this.currentMessage = this.defaultMessage;
|
| 467 |
+
this.isTyping = false;
|
| 468 |
+
this.render();
|
| 469 |
+
this.updateTimestamp();
|
| 470 |
+
this.startTypingAnimation();
|
| 471 |
+
this.setupEventListeners();
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
startTypingAnimation() {
|
| 475 |
+
// Simulate AI thinking periodically
|
| 476 |
+
setInterval(() => {
|
| 477 |
+
if (Math.random() > 0.7) {
|
| 478 |
+
this.generateSmartMessage();
|
| 479 |
+
}
|
| 480 |
+
}, 30000); // Every 30 seconds
|
| 481 |
+
}
|
| 482 |
+
|
| 483 |
+
setupEventListeners() {
|
| 484 |
+
// Listen for health data updates
|
| 485 |
+
window.addEventListener('health-data-updated', (e) => {
|
| 486 |
+
this.generateSmartMessage();
|
| 487 |
+
});
|
| 488 |
+
}
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
// Register the custom element
|
| 492 |
+
customElements.define('ai-coach-card', AICoachCard);
|
login.html
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
```html
|
| 2 |
+
<!DOCTYPE html>
|
| 3 |
+
<html lang="th" class="dark">
|
| 4 |
+
<head>
|
| 5 |
+
<meta charset="UTF-8">
|
| 6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
| 7 |
+
<title>เข้าสู่ระบบ - ชีพจร</title>
|
| 8 |
+
<link rel="icon" type="image/x-icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🌿</text></svg>">
|
| 9 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 10 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 11 |
+
<link rel="stylesheet" href="style.css">
|
| 12 |
+
</head>
|
| 13 |
+
<body class="bg-gray-900 text-white font-sans">
|
| 14 |
+
<!-- Main Container -->
|
| 15 |
+
<div class="min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900 flex items-center justify-center p-4">
|
| 16 |
+
<!-- Login Card -->
|
| 17 |
+
<div class="glass-card rounded-2xl p-6 w-full max-w-sm border border-gray-700/50">
|
| 18 |
+
<!-- Logo -->
|
| 19 |
+
<div class="text-center mb-8">
|
| 20 |
+
<div class="w-20 h-20 mx-auto mb-4 bg-gradient-to-r from-green-400 to-emerald-500 rounded-full flex items-center justify-center">
|
| 21 |
+
<span class="text-3xl">🌿</span>
|
| 22 |
+
</div>
|
| 23 |
+
<h1 class="text-2xl font-bold bg-gradient-to-r from-green-400 to-emerald-500 bg-clip-text text-transparent">
|
| 24 |
+
ชีพจร
|
| 25 |
+
</h1>
|
| 26 |
+
<p class="text-gray-400 text-sm mt-1">แดชบอร์ดสุขภาพส่วนตัวของคุณ</p>
|
| 27 |
+
</div>
|
| 28 |
+
|
| 29 |
+
<!-- Login Form -->
|
| 30 |
+
<form id="loginForm" class="space-y-4">
|
| 31 |
+
<div>
|
| 32 |
+
<label class="block text-sm font-medium mb-2">อีเมล</label>
|
| 33 |
+
<input type="email" id="email" class="w-full px-4 py-3 bg-gray-800 border border-gray-700 rounded-xl text-white placeholder-gray-400 focus:outline-none focus:border-green-400" placeholder="your@email.com" required>
|
| 34 |
+
</div>
|
| 35 |
+
|
| 36 |
+
<div>
|
| 37 |
+
<label class="block text-sm font-medium mb-2">รหัสผ่าน</label>
|
| 38 |
+
<input type="password" id="password" class="w-full px-4 py-3 bg-gray-800 border border-gray-700 rounded-xl text-white placeholder-gray-400 focus:outline-none focus:border-green-400" placeholder="••••••••" required>
|
| 39 |
+
</div>
|
| 40 |
+
|
| 41 |
+
<div class="flex items-center justify-between">
|
| 42 |
+
<label class="flex items-center gap-2">
|
| 43 |
+
<input type="checkbox" class="w-4 h-4 rounded border-gray-600 text-green-600 focus:ring-green-500">
|
| 44 |
+
<span class="text-sm text-gray-300">จำฉันไว้</span>
|
| 45 |
+
</label>
|
| 46 |
+
<a href="#" onclick="showComingSoon()" class="text-sm text-green-400 hover:underline">ลืมรหัสผ่าน?</a>
|
| 47 |
+
</div>
|
| 48 |
+
|
| 49 |
+
<button type="submit" class="w-full bg-gradient-to-r from-green-500 to-emerald-600 py-3 rounded-xl font-medium transition-all hover:scale-[1.02]">
|
| 50 |
+
เข้าสู่ระบบ
|
| 51 |
+
</button>
|
| 52 |
+
</form>
|
| 53 |
+
|
| 54 |
+
<!-- Social Login -->
|
| 55 |
+
<div class="mt-6">
|
| 56 |
+
<div class="relative">
|
| 57 |
+
<div class="absolute inset-0 flex items-center">
|
| 58 |
+
<div class="w-full border-t border-gray-700"></div>
|
| 59 |
+
</div>
|
| 60 |
+
<div class="relative text-center">
|
| 61 |
+
<span class="px-2 bg-gray-900 text-sm text-gray-400">หรือเข้าสู่ระบบด้วย</span>
|
| 62 |
+
</div>
|
| 63 |
+
</div>
|
| 64 |
+
|
| 65 |
+
<div class="mt-4 grid grid-cols-2 gap-3">
|
| 66 |
+
<button onclick="socialLogin('google')" class="w-full flex items-center justify-center gap-2 py-2 bg-gray-800 border border-gray-700 rounded-xl hover:bg-gray-700 transition-colors">
|
| 67 |
+
<span class="text-sm">G</span>
|
| 68 |
+
<span class="text-sm">Google</span>
|
| 69 |
+
</button>
|
| 70 |
+
<button onclick="socialLogin('apple')" class="w-full flex items-center justify-center gap-2 py-2 bg-gray-800 border border-gray-700 rounded-xl hover:bg-gray-700 transition-colors">
|
| 71 |
+
<i data-feather="apple" class="w-4 h-4"></i>
|
| 72 |
+
<span class="text-sm">Apple</span>
|
| 73 |
+
</button>
|
| 74 |
+
</div>
|
| 75 |
+
</div>
|
| 76 |
+
|
| 77 |
+
<!-- Sign Up Link -->
|
| 78 |
+
<div class="text-center mt-6">
|
| 79 |
+
<p class="text-sm text-gray-400">
|
| 80 |
+
ยังไม่มีบัญชี?
|
| 81 |
+
<a href="#" onclick="showComingSoon()" class="text-green-400 hover:underline">สมัครสมาชิก</a>
|
| 82 |
+
</p>
|
| 83 |
+
</div>
|
| 84 |
+
</div>
|
| 85 |
+
</div>
|
| 86 |
+
|
| 87 |
+
<script src="script.js"></script>
|
| 88 |
+
<script>
|
| 89 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 90 |
+
// Check if user is already logged in
|
| 91 |
+
const currentUser = localStorage.getItem('currentUser');
|
| 92 |
+
if (currentUser) {
|
| 93 |
+
window.location.href = 'index.html';
|
| 94 |
+
return;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
// Handle login form
|
| 98 |
+
document.getElementById('loginForm').addEventListener('submit', function(e) {
|
| 99 |
+
e.preventDefault();
|
| 100 |
+
|
| 101 |
+
const email = document.getElementById('email').value;
|
| 102 |
+
const password = document.getElementById('password').value;
|
| 103 |
+
|
| 104 |
+
// Simulate login
|
| 105 |
+
login(email, password);
|
| 106 |
+
});
|
| 107 |
+
});
|
| 108 |
+
|
| 109 |
+
function login(email, password) {
|
| 110 |
+
showNotification('กำลังเข้าสู่ระบบ...', 'info');
|
| 111 |
+
|
| 112 |
+
// Simulate API call
|
| 113 |
+
setTimeout(() => {
|
| 114 |
+
// Mock user data
|
| 115 |
+
const user = {
|
| 116 |
+
id: 'user_' + Date.now(),
|
| 117 |
+
email: email,
|
| 118 |
+
name: 'คุณพิมพ์',
|
| 119 |
+
createdAt: new Date().toISOString()
|
| 120 |
+
};
|
| 121 |
+
|
| 122 |
+
localStorage.setItem('currentUser',
|
manifest.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
```json
|
| 2 |
+
{
|
| 3 |
+
"name": "ชีพจร - แดชบอร์ดสุขภาพ",
|
| 4 |
+
"short_name": "ชีพจร",
|
| 5 |
+
"description": "ติดตามสุขภาพของคุณด้วย AI Coach อัจฉริยะ",
|
| 6 |
+
"start_url": "/index.html",
|
| 7 |
+
"display": "standalone",
|
| 8 |
+
"background_color": "#111827",
|
| 9 |
+
"theme_color": "#34d399",
|
| 10 |
+
"orientation": "portrait-primary",
|
| 11 |
+
"icons": [
|
| 12 |
+
{
|
| 13 |
+
"src": "data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 192 192%22><text y=%22160%22 font-size=%22160%22>🌿</text></svg>",
|
| 14 |
+
"sizes": "192x192",
|
| 15 |
+
"type": "image/svg+xml",
|
| 16 |
+
"purpose": "any maskable"
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
"src": "data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 512 512%22><text y=%22420%22 font-size=%22400%22>🌿</text></svg>",
|
| 20 |
+
"sizes": "512x512",
|
| 21 |
+
"type": "image/svg+xml",
|
| 22 |
+
"purpose": "any maskable"
|
| 23 |
+
}
|
| 24 |
+
],
|
| 25 |
+
"categories": ["health", "fitness", "lifestyle"],
|
| 26 |
+
"lang": "th",
|
| 27 |
+
"dir": "ltr"
|
| 28 |
+
}
|
| 29 |
+
```
|
nutrition.html
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
```html
|
| 2 |
+
<!DOCTYPE html>
|
| 3 |
+
<html lang="th" class="dark">
|
| 4 |
+
<head>
|
| 5 |
+
<meta charset="UTF-8">
|
| 6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
| 7 |
+
<title>โภชนาการ - ชีพจร</title>
|
| 8 |
+
<link rel="icon" type="image/x-icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🌿</text></svg>">
|
| 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://cdn.jsdelivr.net/npm/chart.js"></script>
|
| 12 |
+
<link rel="stylesheet" href="style.css">
|
| 13 |
+
</head>
|
| 14 |
+
<body class="bg-gray-900 text-white font-sans pb-20">
|
| 15 |
+
<!-- Main Container -->
|
| 16 |
+
<div class="min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900">
|
| 17 |
+
<!-- Header -->
|
| 18 |
+
<header class="px-4 pt-12 pb-6">
|
| 19 |
+
<div class="flex items-center justify-between">
|
| 20 |
+
<div>
|
| 21 |
+
<h1 class="text-2xl font-bold bg-gradient-to-r from-purple-400 to-pink-500 bg-clip-text text-transparent">
|
| 22 |
+
โภชนาการ
|
| 23 |
+
</h1>
|
| 24 |
+
<p class="text-gray-400 text-sm mt-1">ติดตามการรับประทานอาหารของคุณ 🍎</p>
|
| 25 |
+
</div>
|
| 26 |
+
<button onclick="window.location.href='index.html'" class="w-10 h-10 rounded-full bg-gray-800 flex items-center justify-center">
|
| 27 |
+
<i data-feather="arrow-left" class="w-5 h-5"></i>
|
| 28 |
+
</button>
|
| 29 |
+
</div>
|
| 30 |
+
</header>
|
| 31 |
+
|
| 32 |
+
<!-- Daily Nutrition Overview -->
|
| 33 |
+
<section class="px-4 mb-6">
|
| 34 |
+
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
|
| 35 |
+
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
|
| 36 |
+
<i data-feather="pie-chart" class="w-5 h-5 text-purple-400"></i>
|
| 37 |
+
ภาพรวมวันนี้
|
| 38 |
+
</h3>
|
| 39 |
+
|
| 40 |
+
<div class="grid grid-cols-3 gap-4 mb-4">
|
| 41 |
+
<div class="text-center">
|
| 42 |
+
<p class="text-2xl font-bold text-orange-400">1,847</p>
|
| 43 |
+
<p class="text-xs text-gray-400">แคลอรี</p>
|
| 44 |
+
</div>
|
| 45 |
+
<div class="text-center">
|
| 46 |
+
<p class="text-2xl font-bold text-blue-400">92g</p>
|
| 47 |
+
<p class="text-xs text-gray-400">โปรตีน</p>
|
| 48 |
+
</div>
|
| 49 |
+
<div class="text-center">
|
| 50 |
+
<p class="text-2xl font-bold text-green-400">35g</p>
|
| 51 |
+
<p class="text-xs text-gray-400">ใยอาหาร</p>
|
| 52 |
+
</div>
|
| 53 |
+
</div>
|
| 54 |
+
|
| 55 |
+
<div class="bg-gray-800/50 rounded-xl p-3">
|
| 56 |
+
<div class="flex justify-between text-sm mb-2">
|
| 57 |
+
<span>เป้าหมาย: 2,200 แคลอรี</span>
|
| 58 |
+
<span>73%</span>
|
| 59 |
+
</div>
|
| 60 |
+
<div class="bg-gray-700 rounded-full h-3">
|
| 61 |
+
<div class="bg-gradient-to-r from-purple-500 to-pink-600 h-3 rounded-full" style="width: 73%"></div>
|
| 62 |
+
</div>
|
| 63 |
+
</div>
|
| 64 |
+
</div>
|
| 65 |
+
</section>
|
| 66 |
+
|
| 67 |
+
<!-- Macro Distribution -->
|
| 68 |
+
<section class="px-4 mb-6">
|
| 69 |
+
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
|
| 70 |
+
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
|
| 71 |
+
<i data-feather="percent" class="w-5 h-5 text-yellow-400"></i>
|
| 72 |
+
สัดส่วนสารอาหาร
|
| 73 |
+
</h3>
|
| 74 |
+
<canvas id="macroChart" height="200"></canvas>
|
| 75 |
+
</div>
|
| 76 |
+
</section>
|
| 77 |
+
|
| 78 |
+
<!-- Meal Timeline -->
|
| 79 |
+
<section class="px-4 mb-6">
|
| 80 |
+
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
|
| 81 |
+
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
|
| 82 |
+
<i data-feather="clock" class="w-5 h-5 text-green-400"></i>
|
| 83 |
+
มื้ออาหารวันนี้
|
| 84 |
+
</h3>
|
| 85 |
+
|
| 86 |
+
<div class="space-y-4" id="mealTimeline">
|
| 87 |
+
<div class="flex gap-3">
|
| 88 |
+
<div class="flex-shrink-0 w-16 h-16 bg-gradient-to-r from-yellow-400 to-orange-500 rounded-xl flex items-center justify-center text-xl">
|
| 89 |
+
🌅
|
| 90 |
+
</div>
|
| 91 |
+
<div class="flex-1">
|
| 92 |
+
<div class="flex justify-between items-start mb-1">
|
| 93 |
+
<h4 class="font-medium">มื้อเช้า</h4>
|
| 94 |
+
<span class="text-sm text-gray-400">07:30</span>
|
| 95 |
+
</div>
|
| 96 |
+
<p class="text-sm text-gray-300 mb-1">ข้าวต้มหมู + ไข่ลวก</p>
|
| 97 |
+
<p class="text-xs text-orange-400">580 แคลอรี</p>
|
| 98 |
+
</div>
|
| 99 |
+
</div>
|
| 100 |
+
|
| 101 |
+
<div class="flex gap-3">
|
| 102 |
+
<div class="flex-shrink-0 w-16 h-16 bg-gradient-to-r from-red-500 to-pink-600 rounded-xl flex items-center justify-center text-xl">
|
| 103 |
+
☀️
|
| 104 |
+
</div>
|
| 105 |
+
<div class="flex-1">
|
| 106 |
+
<div class="flex justify-between items-start mb-1">
|
| 107 |
+
<h4 class="font-medium">มื้อเที่ยง</h4>
|
| 108 |
+
<span class="text-sm text-gray-400">12:15</span>
|
| 109 |
+
</div>
|
| 110 |
+
<p class="text-sm text-gray-300 mb-1">ส้มตำไทย + ไก่ย่าง</p>
|
| 111 |
+
<p class="text-xs text-orange-400">450 แคลอรี</p>
|
| 112 |
+
</div>
|
| 113 |
+
</div>
|
| 114 |
+
|
| 115 |
+
<div class="flex gap-3">
|
| 116 |
+
<div class="flex-shrink-0 w-16 h-16 bg-gradient-to-r from-blue-500 to-indigo-600 rounded-xl flex items-center justify-center text-xl">
|
| 117 |
+
🌙
|
| 118 |
+
</div>
|
| 119 |
+
<div class="flex-1">
|
| 120 |
+
<div class="flex justify-between items-start mb-1">
|
| 121 |
+
<h4 class="font-medium">มื้อเย็น</h4>
|
| 122 |
+
<span class="text-sm text-gray-400">18:30</span>
|
| 123 |
+
</div>
|
| 124 |
+
<p class="text-sm text-gray-300 mb-1">ยังไม่บันทึก</p>
|
| 125 |
+
<button class="text-xs text-blue-400 hover:underline">+ เพิ่มมื้อเย็น</button>
|
| 126 |
+
</div>
|
| 127 |
+
</div>
|
| 128 |
+
</div>
|
| 129 |
+
</section>
|
| 130 |
+
|
| 131 |
+
<!-- Enhanced Meal Logger -->
|
| 132 |
+
<meal-logger-enhanced></meal-logger-enhanced>
|
| 133 |
+
|
| 134 |
+
<!-- Water Intake -->
|
| 135 |
+
<section class="px-4 mb-6">
|
| 136 |
+
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
|
| 137 |
+
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
|
| 138 |
+
<i data-feather="droplet" class="w-5 h-5 text-cyan-400"></i>
|
| 139 |
+
การดื่มน้ำ
|
| 140 |
+
</h3>
|
| 141 |
+
|
| 142 |
+
<div class="flex items-center justify-between mb-4">
|
| 143 |
+
<div class="text-center">
|
| 144 |
+
<p class="text-2xl font-bold text-cyan-400">1.8L</p>
|
| 145 |
+
<p class="text-xs text-gray-400">ดื่มไปแล้ว</p>
|
| 146 |
+
</div>
|
| 147 |
+
<div class="text-center">
|
| 148 |
+
<p class="text-2xl font-bold text-gray-400">2.5L</p>
|
| 149 |
+
<p class="text-xs text-gray-400">เป้าหมาย</p>
|
| 150 |
+
</div>
|
| 151 |
+
</div>
|
| 152 |
+
|
| 153 |
+
<div class="grid grid-cols-4 gap-2 mb-4">
|
| 154 |
+
<div class="aspect-square bg-cyan-500 rounded-lg flex items-center justify-center">
|
| 155 |
+
<i data-feather="check" class="w-4 h-4 text-white"></i>
|
| 156 |
+
</div>
|
| 157 |
+
<div class="aspect-square bg-cyan-500 rounded-lg flex items-center justify-center">
|
| 158 |
+
<i data-feather="check" class="w-4 h-4 text-white"></i>
|
| 159 |
+
</div>
|
| 160 |
+
<div class="aspect-square bg-cyan-500 rounded-lg flex items-center justify-center">
|
| 161 |
+
<i data-feather="check" class="w-4 h-4 text-white"></i>
|
| 162 |
+
</div>
|
| 163 |
+
<div class="aspect-square bg-gray-700 rounded-lg flex items-center justify-center">
|
| 164 |
+
<span class="text-xs text-gray-400">4</span>
|
| 165 |
+
</div>
|
| 166 |
+
</div>
|
| 167 |
+
|
| 168 |
+
<button class="w-full bg-gradient-to-r from-cyan-500 to-blue-600 py-2 rounded-lg text-sm font-medium" onclick="logWater()">
|
| 169 |
+
<i data-feather="plus" class="w-4 h-4 inline mr-1"></i>
|
| 170 |
+
เพิ่มแก้วน้ำ (250ml)
|
| 171 |
+
</button>
|
| 172 |
+
</div>
|
| 173 |
+
</section>
|
| 174 |
+
|
| 175 |
+
<!-- Nutrition Insights -->
|
| 176 |
+
<section class="px-4 mb-6">
|
| 177 |
+
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
|
| 178 |
+
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
|
| 179 |
+
<i data-feather="info" class="w-5 h-5 text-yellow-400"></i>
|
| 180 |
+
คำแนะนำโภชนาการ
|
| 181 |
+
</h3>
|
| 182 |
+
|
| 183 |
+
<div class="space-y-3">
|
| 184 |
+
<div class="p-3 bg-green-500/10 border border-green-500/30 rounded-xl">
|
| 185 |
+
<div class="flex items-center gap-3">
|
| 186 |
+
<div class="w-8 h-8 bg-green-500 rounded-lg flex items-center justify-center">
|
| 187 |
+
<i data-feather="check-circle" class="w-4 h-4 text-white"></i>
|
| 188 |
+
</div>
|
| 189 |
+
<div class="flex-1">
|
| 190 |
+
<p class="text-sm font-medium">โปรตีนเพียงพอ</p>
|
| 191 |
+
<p class="text-xs text-gray-400">คุณได้รับโปรตีนครบตามเป้าหมายแล้ว</p>
|
| 192 |
+
</div>
|
| 193 |
+
</div>
|
| 194 |
+
</div>
|
| 195 |
+
|
| 196 |
+
<div class="p-3 bg-orange-500/10 border border-orange-500/30 rounded-xl">
|
| 197 |
+
<div class="flex items-center gap-3">
|
| 198 |
+
<div class="w-8 h-8 bg-orange-500 rounded-lg flex items-center justify-center">
|
| 199 |
+
<i data-feather="alert-circle" class="w-4 h-4 text-white"></i>
|
| 200 |
+
</div>
|
| 201 |
+
<div class="flex-1">
|
| 202 |
+
<p class="text-sm font-medium">ใยอาหารต่ำ</p>
|
| 203 |
+
<p class="text-xs text-gray-400">ควรทานผักเพิ่มขึ้นอีก 15g</p>
|
| 204 |
+
</div>
|
| 205 |
+
</div>
|
| 206 |
+
</div>
|
| 207 |
+
</div>
|
| 208 |
+
</div>
|
| 209 |
+
</section>
|
| 210 |
+
</div>
|
| 211 |
+
|
| 212 |
+
<!-- Bottom Navigation -->
|
| 213 |
+
<main-navbar></main-navbar>
|
| 214 |
+
|
| 215 |
+
<!-- Scripts -->
|
| 216 |
+
<script src="components/navbar.js"></script>
|
| 217 |
+
<script src="components/meal-logger-enhanced.js"></script>
|
| 218 |
+
<script src="script.js"></script>
|
| 219 |
+
<script>
|
| 220 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 221 |
+
// Set active page in navbar
|
| 222 |
+
const navbar = document.querySelector('main-navbar');
|
| 223 |
+
if (navbar) {
|
| 224 |
+
navbar.setActivePage('nutrition');
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
// Macro distribution chart
|
| 228 |
+
const ctx = document.getElementById('macroChart');
|
| 229 |
+
if (ctx) {
|
| 230 |
+
new Chart(ctx, {
|
| 231 |
+
type: 'doughnut',
|
| 232 |
+
data: {
|
| 233 |
+
labels: ['คาร์โบไฮเดรต', 'โปรตีน', 'ไขมัน', 'ใยอาหาร'],
|
| 234 |
+
datasets: [{
|
| 235 |
+
data: [45, 25, 25, 5],
|
| 236 |
+
backgroundColor: [
|
| 237 |
+
'#f59e0b',
|
| 238 |
+
'#3b82f6',
|
| 239 |
+
'#10b981',
|
| 240 |
+
'#8b5cf6'
|
| 241 |
+
],
|
| 242 |
+
borderWidth: 0
|
| 243 |
+
}]
|
| 244 |
+
},
|
| 245 |
+
options: {
|
| 246 |
+
responsive: true,
|
| 247 |
+
maintainAspectRatio: false,
|
| 248 |
+
plugins: {
|
| 249 |
+
legend: {
|
| 250 |
+
position: 'bottom',
|
| 251 |
+
labels: {
|
| 252 |
+
padding: 15,
|
| 253 |
+
font: { size: 12, family: 'Prompt' },
|
| 254 |
+
color: '#e5e7eb'
|
| 255 |
+
}
|
| 256 |
+
}
|
| 257 |
+
}
|
| 258 |
+
}
|
| 259 |
+
});
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
// Load meals from localStorage
|
| 263 |
+
loadMealsFromStorage();
|
| 264 |
+
});
|
| 265 |
+
|
| 266 |
+
function logWater() {
|
| 267 |
+
const waterGrid = document.querySelector('.grid.grid-cols-4');
|
| 268 |
+
const emptyGlass = waterGrid.querySelector('.bg-gray-700');
|
| 269 |
+
|
| 270 |
+
if (emptyGlass) {
|
| 271 |
+
emptyGlass.className = 'aspect-square bg-cyan-500 rounded-lg flex items-center justify-center';
|
| 272 |
+
emptyGlass.innerHTML = '<i data-feather="check" class="w-4 h-4 text-white"></i>';
|
| 273 |
+
feather.replace();
|
| 274 |
+
|
| 275 |
+
showNotification('บันทึกการดื่มน้ำ 250ml สำเร็จ!', 'success');
|
| 276 |
+
|
| 277 |
+
// Update total
|
| 278 |
+
const currentText = document.querySelector('.text-2xl.font-bold.text-cyan-400').textContent;
|
| 279 |
+
const current = parseFloat(currentText);
|
| 280 |
+
document.querySelector('.text-2xl.font-bold.text-cyan-400').textContent = (current + 0.25).toFixed(1) + 'L';
|
| 281 |
+
} else {
|
| 282 |
+
showNotification('คุณดื่มน้ำครบเป้าหมายแล้ววันนี้! 🎉', 'success');
|
| 283 |
+
}
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
function loadMealsFromStorage() {
|
| 287 |
+
const meals = JSON.parse(localStorage.getItem('todayMeals') || '[]');
|
| 288 |
+
const timeline = document.getElementById('mealTimeline');
|
| 289 |
+
|
| 290 |
+
// Update timeline with saved meals
|
| 291 |
+
if (meals.length > 0) {
|
| 292 |
+
// Clear existing meals except the "dinner" placeholder
|
| 293 |
+
const existingMeals = timeline.querySelectorAll('.flex.gap-3:not(:last-child)');
|
| 294 |
+
existingMeals.forEach(meal => meal.remove());
|
| 295 |
+
|
| 296 |
+
// Add saved meals
|
| 297 |
+
meals.forEach((meal, index) => {
|
| 298 |
+
const mealElement = document.createElement('div');
|
| 299 |
+
mealElement.className = 'flex gap-3';
|
| 300 |
+
mealElement.innerHTML = `
|
| 301 |
+
<div class="flex-shrink-0 w-16 h-16 bg-gradient-to-r from-orange-500 to-red-600 rounded-xl flex items-center justify-center text-xl">
|
| 302 |
+
${meal.mealType === 'เช้า' ? '🌅' : meal.mealType === 'เที่ยง' ? '☀️' : '🌙'}
|
| 303 |
+
</div>
|
| 304 |
+
<div class="flex-1">
|
| 305 |
+
<div class="flex justify-between items-start mb-1">
|
| 306 |
+
<h4 class="font-medium">มื้อ${meal.mealType}</h4>
|
| 307 |
+
<span class="text-sm text-gray-400">${new Date(meal.timestamp).toLocaleTimeString('th-TH', { hour: '2-digit', minute: '2-digit' })}</span>
|
| 308 |
+
</div>
|
| 309 |
+
<p class="text-sm text-gray-300 mb-1">${meal.name}</p>
|
| 310 |
+
<p class="text-xs text-orange-400">${meal.calories} แคลอรี</p>
|
| 311 |
+
</div>
|
| 312 |
+
`;
|
| 313 |
+
timeline.insertBefore(mealElement, timeline.firstChild);
|
| 314 |
+
});
|
| 315 |
+
}
|
| 316 |
+
}
|
| 317 |
+
</script>
|
| 318 |
+
<script>feather.replace();</script>
|
| 319 |
+
</body>
|
| 320 |
+
</html>
|
| 321 |
+
>>>>>>> REPLACE
|
profile.html
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
```html
|
| 2 |
+
<!DOCTYPE html>
|
| 3 |
+
<html lang="th" class="dark">
|
| 4 |
+
<head>
|
| 5 |
+
<meta charset="UTF-8">
|
| 6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
| 7 |
+
<title>โปรไฟล์ - ชีพจร</title>
|
| 8 |
+
<link rel="icon" type="image/x-icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🌿</text></svg>">
|
| 9 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 10 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 11 |
+
<link rel="stylesheet" href="style.css">
|
| 12 |
+
</head>
|
| 13 |
+
<body class="bg-gray-900 text-white font-sans pb-20">
|
| 14 |
+
<!-- Main Container -->
|
| 15 |
+
<div class="min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900">
|
| 16 |
+
<!-- Header -->
|
| 17 |
+
<header class="px-4 pt-12 pb-6">
|
| 18 |
+
<div class="flex items-center justify-between">
|
| 19 |
+
<div>
|
| 20 |
+
<h1 class="text-2xl font-bold bg-gradient-to-r from-indigo-400 to-purple-500 bg-clip-text text-transparent">
|
| 21 |
+
โปรไฟล์
|
| 22 |
+
</h1>
|
| 23 |
+
<p class="text-gray-400 text-sm mt-1">จัดการข้อมูลและการตั้งค่าของคุณ 👤</p>
|
| 24 |
+
</div>
|
| 25 |
+
<button onclick="window.location.href='index.html'" class="w-10 h-10 rounded-full bg-gray-800 flex items-center justify-center">
|
| 26 |
+
<i data-feather="arrow-left" class="w-5 h-5"></i>
|
| 27 |
+
</button>
|
| 28 |
+
</div>
|
| 29 |
+
</header>
|
| 30 |
+
|
| 31 |
+
<!-- User Profile -->
|
| 32 |
+
<section class="px-4 mb-6">
|
| 33 |
+
<div class="glass-card rounded-2xl p-6 border border-gray-700/50 text-center">
|
| 34 |
+
<div class="w-24 h-24 mx-auto mb-4 relative">
|
| 35 |
+
<div class="w-full h-full rounded-full bg-gradient-to-r from-green-400 to-emerald-500 p-0.5">
|
| 36 |
+
<img src="http://static.photos/people/200x200/42" alt="Profile" class="w-full h-full rounded-full object-cover border-2 border-gray-900">
|
| 37 |
+
</div>
|
| 38 |
+
<div class="absolute -bottom-1 -right-1 w-6 h-6 bg-green-400 rounded-full border-2 border-gray-900 flex items-center justify-center">
|
| 39 |
+
<i data-feather="check" class="w-3 h-3 text-gray-900"></i>
|
| 40 |
+
</div>
|
| 41 |
+
</div>
|
| 42 |
+
<h2 class="text-xl font-bold mb-1">คุณพิมพ์</h2>
|
| 43 |
+
<p class="text-gray-400 text-sm mb-4">สมาชิกตั้งแต่ มกราคม 2024</p>
|
| 44 |
+
|
| 45 |
+
<div class="grid grid-cols-3 gap-4 text-center">
|
| 46 |
+
<div>
|
| 47 |
+
<p class="text-lg font-bold text-green-400">127</p>
|
| 48 |
+
<p class="text-xs text-gray-400">วันติดต่อกัน</p>
|
| 49 |
+
</div>
|
| 50 |
+
<div>
|
| 51 |
+
<p class="text-lg font-bold text-blue-400">2,847</p>
|
| 52 |
+
<p class="text-xs text-gray-400">คะแนนรวม</p>
|
| 53 |
+
</div>
|
| 54 |
+
<div>
|
| 55 |
+
<p class="text-lg font-bold text-purple-400">15</p>
|
| 56 |
+
<p class="text-xs text-gray-400">ความท้าทาย</p>
|
| 57 |
+
</div>
|
| 58 |
+
</div>
|
| 59 |
+
</div>
|
| 60 |
+
</section>
|
| 61 |
+
|
| 62 |
+
<!-- Health Goals -->
|
| 63 |
+
<section class="px-4 mb-6">
|
| 64 |
+
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
|
| 65 |
+
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
|
| 66 |
+
<i data-feather="target" class="w-5 h-5 text-red-400"></i>
|
| 67 |
+
เป้าหมายสุขภาพ
|
| 68 |
+
</h3>
|
| 69 |
+
|
| 70 |
+
<div class="space-y-4">
|
| 71 |
+
<div>
|
| 72 |
+
<div class="flex justify-between text-sm mb-2">
|
| 73 |
+
<span>น้ำหนักเป้าหมาย</span>
|
| 74 |
+
<span class="text-green-400">55 kg</span>
|
| 75 |
+
</div>
|
| 76 |
+
<div class="bg-gray-700 rounded-full h-2">
|
| 77 |
+
<div class="bg-gradient-to-r from-green-400 to-emerald-500 h-2 rounded-full" style="width: 75%"></div>
|
| 78 |
+
</div>
|
| 79 |
+
<p class="text-xs text-gray-400 mt-1">คงเหลือ 3 kg • 2 เดือน</p>
|
| 80 |
+
</div>
|
| 81 |
+
|
| 82 |
+
<div>
|
| 83 |
+
<div class="flex justify-between text-sm mb-2">
|
| 84 |
+
<span>ออกกำลังกายรายสัปดาห์</span>
|
| 85 |
+
<span class="text-blue-400">4/5 วัน</span>
|
| 86 |
+
</div>
|
| 87 |
+
<div class="bg-gray-700 rounded-full h-2">
|
| 88 |
+
<div class="bg-gradient-to-r from-blue-400 to-indigo-500 h-2 rounded-full" style="width: 80%"></div>
|
| 89 |
+
</div>
|
| 90 |
+
</div>
|
| 91 |
+
|
| 92 |
+
<div>
|
| 93 |
+
<div class="flex justify-between text-sm mb-2">
|
| 94 |
+
<span>การนอนให้ครบ 7 ชม.</span>
|
| 95 |
+
<span class="text-purple-400">5/7 วัน</span>
|
| 96 |
+
</div>
|
| 97 |
+
<div class="bg-gray-700 rounded-full h-2">
|
| 98 |
+
<div class="bg-gradient-to-r from-purple-500 to-pink-600 h-2 rounded-full" style="width: 71%"></div>
|
| 99 |
+
</div>
|
| 100 |
+
</div>
|
| 101 |
+
</div>
|
| 102 |
+
</div>
|
| 103 |
+
</section>
|
| 104 |
+
|
| 105 |
+
<!-- Settings -->
|
| 106 |
+
<section class="px-4 mb-6">
|
| 107 |
+
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
|
| 108 |
+
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
|
| 109 |
+
<i data-feather="settings" class="w-5 h-5 text-gray-400"></i>
|
| 110 |
+
การตั้งค่า
|
| 111 |
+
</h3>
|
| 112 |
+
|
| 113 |
+
<div class="space-y-3">
|
| 114 |
+
<button class="w-full flex items-center justify-between p-3 bg-gray-800/30 rounded-xl hover:bg-gray-700/50 transition-colors" onclick="showComingSoon()">
|
| 115 |
+
<div class="flex items-center gap-3">
|
| 116 |
+
<i data-feather="bell" class="w-5 h-5 text-yellow-400"></i>
|
| 117 |
+
<span class="text-sm font-medium">การแจ้งเตือน</span>
|
| 118 |
+
</div>
|
| 119 |
+
<i data-feather="chevron-right" class="w-4 h-4 text-gray-400"></i>
|
| 120 |
+
</button>
|
| 121 |
+
|
| 122 |
+
<button class="w-full flex items-center justify-between p-3 bg-gray-800/30 rounded-xl hover:bg-gray-700/50 transition-colors" onclick="showComingSoon()">
|
| 123 |
+
<div class="flex items-center gap-3">
|
| 124 |
+
<i data-feather="shield" class="w-5 h-5 text-green-400"></i>
|
| 125 |
+
<span class="text-sm font-medium">ความเป็นส่วนตัว</span>
|
| 126 |
+
</div>
|
| 127 |
+
<i data-feather="chevron-right" class="w-4 h-4 text-gray-400"></i>
|
| 128 |
+
</button>
|
| 129 |
+
|
| 130 |
+
<button class="w-full flex items-center justify-between p-3 bg-gray-800/30 rounded-xl hover:bg-gray-700/50 transition-colors" onclick="showComingSoon()">
|
| 131 |
+
<div class="flex items-center gap-3">
|
| 132 |
+
<i data-feather="smartphone" class="w-5 h-5 text-blue-400"></i>
|
| 133 |
+
<span class="text-sm font-medium">อุปกรณ์ที่เชื่อมต่อ</span>
|
| 134 |
+
</div>
|
| 135 |
+
<i data-feather="chevron-right" class="w-4 h-4 text-gray-400"></i>
|
| 136 |
+
</button>
|
| 137 |
+
|
| 138 |
+
<button class="w-full flex items-center justify-between p-3 bg-gray-800/30 rounded-xl hover:bg-gray-700/50 transition-colors" onclick="showComingSoon()">
|
| 139 |
+
<div class="flex items-center gap-3">
|
| 140 |
+
<i data-feather="download" class="w-5 h-5 text-purple-400"></i>
|
| 141 |
+
<span class="text-sm font-medium">สำรองข้อมูล</span>
|
| 142 |
+
</div>
|
| 143 |
+
<i data-feather="chevron-right" class="w-4 h-4 text-gray-400"></i>
|
| 144 |
+
</button>
|
| 145 |
+
</div>
|
| 146 |
+
</div>
|
| 147 |
+
</section>
|
| 148 |
+
|
| 149 |
+
<!-- Data Export -->
|
| 150 |
+
<section class="px-4 mb-6">
|
| 151 |
+
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
|
| 152 |
+
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
|
| 153 |
+
<i data-feather="upload" class="w-5 h-5 text-indigo-400"></i>
|
| 154 |
+
ข้อมูลของฉัน
|
| 155 |
+
</h3>
|
| 156 |
+
|
| 157 |
+
<p class="text-sm text-gray-400 mb-4">ส่งออกข้อมูลสุขภาพของคุณเพื่อวิเคราะห์เพิ่มเติม</p>
|
| 158 |
+
|
| 159 |
+
<div class="flex gap-3">
|
| 160 |
+
<button onclick="exportData('csv')" class="flex-1 bg-gradient-to-r from-indigo-500 to-purple-600 py-3 rounded-xl text-sm font-medium transition-all hover:scale-[1.02]">
|
| 161 |
+
<i data-feather="file-text" class="w-4 h-4 inline mr-1"></i>
|
| 162 |
+
CSV
|
| 163 |
+
</button>
|
| 164 |
+
<button onclick="exportData('pdf')" class="flex-1 bg-gradient-to-r from-pink-500 to-rose-600 py-3 rounded-xl text-sm font-medium transition-all hover:scale-[1.02]">
|
| 165 |
+
<i data-feather="file" class="w-4 h-4 inline mr-1"></i>
|
| 166 |
+
PDF
|
| 167 |
+
</button>
|
| 168 |
+
</div>
|
| 169 |
+
</div>
|
| 170 |
+
</section>
|
| 171 |
+
|
| 172 |
+
<!-- About & Support -->
|
| 173 |
+
<section class="px-4 mb-6">
|
| 174 |
+
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
|
| 175 |
+
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
|
| 176 |
+
<i data-feather="help-circle" class="w-5 h-5 text-cyan-400"></i>
|
| 177 |
+
เกี่ยวกับ
|
| 178 |
+
</h3>
|
| 179 |
+
|
| 180 |
+
<div class="space-y-3">
|
| 181 |
+
<button class="w-full flex items-center justify-between p-3 bg-gray-800/30 rounded-xl hover:bg-gray-700/50 transition-colors" onclick="showComingSoon()">
|
| 182 |
+
<div class="flex items-center gap-3">
|
| 183 |
+
<i data-feather="info" class="w-5 h-5 text-gray-400"></i>
|
| 184 |
+
<span class="text-sm font-medium">เกี่ยวกับ ชีพจร</span>
|
| 185 |
+
</div>
|
| 186 |
+
<i data-feather="chevron-right" class="w-4 h-4 text-gray-400"></i>
|
| 187 |
+
</button>
|
| 188 |
+
|
| 189 |
+
<button class="w-full flex items-center justify-between p-3 bg-gray-800/30 rounded-xl hover:bg-gray-700/50 transition-colors" onclick="showComingSoon()">
|
| 190 |
+
<div class="flex items-center gap-3">
|
| 191 |
+
<i data-feather="life-buoy" class="w-5 h-5 text-cyan-400"></i>
|
| 192 |
+
<span class="text-sm font-medium">ศูนย์ช่วยเหลือ</span>
|
| 193 |
+
</div>
|
| 194 |
+
<i data-feather="chevron-right" class="w-4 h-4 text-gray-400"></i>
|
| 195 |
+
</button>
|
| 196 |
+
|
| 197 |
+
<button class="w-full flex items-center justify-between p-3 bg-gray-800/30 rounded-xl hover:bg-gray-700/50 transition-colors" onclick="showComingSoon()">
|
| 198 |
+
<div class="flex items-center gap-3">
|
| 199 |
+
<i data-feather="star" class="w-5 h-5 text-yellow-400"></i>
|
| 200 |
+
<span class="text-sm font-medium">ให้คะแนนแอป</span>
|
| 201 |
+
</div>
|
| 202 |
+
<i data-feather="chevron-right" class="w-4 h-4 text-gray-400"></i>
|
| 203 |
+
</button>
|
| 204 |
+
</div>
|
| 205 |
+
</div>
|
| 206 |
+
</section>
|
| 207 |
+
|
| 208 |
+
<!-- Logout -->
|
| 209 |
+
<section class="px-4 mb-6">
|
| 210 |
+
<button onclick="logout()" class="w-full bg-red-500/20 border border-red-500/30 text-red-400 py-3 rounded-xl font-medium hover:bg-red-500/30 transition-colors">
|
| 211 |
+
<i data-feather="log-out" class="w-4 h-4 inline mr-2"></i>
|
| 212 |
+
ออกจากระบบ
|
| 213 |
+
</button>
|
| 214 |
+
</section>
|
| 215 |
+
</div>
|
| 216 |
+
|
| 217 |
+
<!-- Bottom Navigation -->
|
| 218 |
+
<main-navbar></main-navbar>
|
| 219 |
+
|
| 220 |
+
<!-- Scripts -->
|
| 221 |
+
<script src="components/navbar.js"></script>
|
| 222 |
+
<script src="script.js"></script>
|
| 223 |
+
<script>
|
| 224 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 225 |
+
// Set active page in navbar
|
| 226 |
+
const navbar = document.querySelector('main-navbar');
|
| 227 |
+
if (navbar) {
|
| 228 |
+
navbar.setActivePage('profile');
|
| 229 |
+
}
|
| 230 |
+
});
|
| 231 |
+
|
| 232 |
+
function showComingSoon() {
|
| 233 |
+
showNotification('ฟีเจอร์นี้กำลังพัฒนา เร็วๆ นี้!', 'info');
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
function exportData(format) {
|
| 237 |
+
showNotification(`กำลังส่งออกข้อมูลเป็น ${format.toUpperCase()}...`, 'info');
|
| 238 |
+
|
| 239 |
+
setTimeout(() => {
|
| 240 |
+
showNotification(`ส่งออกข้อมูล ${format.toUpperCase()} สำเร็จ!`, 'success');
|
| 241 |
+
|
| 242 |
+
// Simulate download
|
| 243 |
+
const blob = new Blob(['ข้อมูลสุขภาพของคุณ...'], { type: format === 'csv' ? 'text/csv' : 'application/pdf' });
|
| 244 |
+
const url = URL.createObjectURL(blob);
|
| 245 |
+
const a = document.createElement('a');
|
| 246 |
+
a.href = url;
|
| 247 |
+
a.download = `health-data-${new Date().toISOString().split('T')[0]}.${format}`;
|
| 248 |
+
a.click();
|
| 249 |
+
URL.revokeObjectURL(url);
|
| 250 |
+
}, 2000);
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
function logout() {
|
| 254 |
+
const modal = document.createElement('div');
|
| 255 |
+
modal.className = 'fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4';
|
| 256 |
+
modal.innerHTML = `
|
| 257 |
+
<div class="glass-card rounded-2xl p-6 max-w-sm w-full border border-gray-700/50">
|
| 258 |
+
<div class="text-center">
|
| 259 |
+
<div class="w-16 h-16 bg-red-500 rounded-full mx-auto mb-4 flex items-center justify-center">
|
| 260 |
+
<i data-feather="log-out" class="w-8 h-8 text-white"></i>
|
| 261 |
+
</div>
|
| 262 |
+
<h3 class="text-xl font-bold mb-2">ยืนยันการออกจากระบบ</h3>
|
| 263 |
+
<p class="text-gray-400 mb-6">คุณต้องการออกจากระบบใช่ไหม?</p>
|
| 264 |
+
|
| 265 |
+
<div class="flex gap-3">
|
| 266 |
+
<button onclick="this.closest('.fixed').remove()" class="flex-1 bg-gray-700 hover:bg-gray-600 py-3 rounded-xl font-medium transition-colors">
|
| 267 |
+
ยกเลิก
|
| 268 |
+
</button>
|
| 269 |
+
<button onclick="confirmLogout()" class="flex-1 bg-red-500 hover:bg-red-600 py-3 rounded-xl font-medium transition-colors">
|
| 270 |
+
ออกจากระบบ
|
| 271 |
+
</button>
|
| 272 |
+
</div>
|
| 273 |
+
</div>
|
| 274 |
+
</div>
|
| 275 |
+
`;
|
| 276 |
+
|
| 277 |
+
document.body.appendChild(modal);
|
| 278 |
+
feather.replace();
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
function confirmLogout() {
|
| 282 |
+
// Clear user data
|
| 283 |
+
localStorage.clear();
|
| 284 |
+
|
| 285 |
+
showNotification('ออกจากระบบสำเร็จ', 'success');
|
| 286 |
+
|
| 287 |
+
setTimeout(() => {
|
| 288 |
+
window.location.href = 'login.html';
|
| 289 |
+
}, 1500);
|
| 290 |
+
}
|
| 291 |
+
</script>
|
| 292 |
+
<script>feather.replace();</script>
|
| 293 |
+
</body>
|
| 294 |
+
</html>
|
| 295 |
+
>>>>>>> REPLACE
|
service-worker.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const CACHE_NAME = 'chipat-health-v1.0.0';
|
| 2 |
+
const urlsToCache = [
|
| 3 |
+
'/',
|
| 4 |
+
'/index.html',
|
| 5 |
+
'/sleep.html',
|
| 6 |
+
'/activity.html',
|
| 7 |
+
'/nutrition.html',
|
| 8 |
+
'/profile.html',
|
| 9 |
+
'/style.css',
|
| 10 |
+
'/script.js',
|
| 11 |
+
'/components/navbar.js',
|
| 12 |
+
'/components/ai-coach-card.js',
|
| 13 |
+
'/components/hardware-status.js',
|
| 14 |
+
'/components/vital-circle.js',
|
| 15 |
+
'/components/mood-logger.js',
|
| 16 |
+
'/components/meal-logger-enhanced.js',
|
| 17 |
+
'https://cdn.tailwindcss.com',
|
| 18 |
+
'https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js',
|
| 19 |
+
'https://cdn.jsdelivr.net/npm/chart.js'
|
| 20 |
+
];
|
| 21 |
+
|
| 22 |
+
// Install event
|
| 23 |
+
self.addEventListener('install', (event) => {
|
| 24 |
+
event.waitUntil(
|
| 25 |
+
caches.open(CACHE_NAME)
|
| 26 |
+
.then((cache) => {
|
| 27 |
+
console.log('กำลังเปิด cache');
|
| 28 |
+
return cache.addAll(urlsToCache);
|
| 29 |
+
})
|
| 30 |
+
);
|
| 31 |
+
});
|
| 32 |
+
|
| 33 |
+
// Fetch event
|
| 34 |
+
self.addEventListener('fetch', (event) => {
|
| 35 |
+
event.respondWith(
|
| 36 |
+
caches.match(event.request)
|
| 37 |
+
.then((response) => {
|
| 38 |
+
// Cache hit - return response
|
| 39 |
+
if (response) {
|
| 40 |
+
return response;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
return fetch(event.request).then(
|
| 44 |
+
(response) => {
|
| 45 |
+
// Check if we received a valid response
|
| 46 |
+
if (!response || response.status !== 200 || response.type !== 'basic') {
|
| 47 |
+
return response;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
// Clone the response
|
| 51 |
+
const responseToCache = response.clone();
|
| 52 |
+
|
| 53 |
+
caches.open(CACHE_NAME)
|
| 54 |
+
.then((cache) => {
|
| 55 |
+
cache.put(event.request, responseToCache);
|
| 56 |
+
});
|
| 57 |
+
|
| 58 |
+
return response;
|
| 59 |
+
}
|
| 60 |
+
);
|
| 61 |
+
})
|
| 62 |
+
);
|
| 63 |
+
});
|
| 64 |
+
|
| 65 |
+
// Activate event
|
| 66 |
+
self.addEventListener('activate', (event) => {
|
| 67 |
+
event.waitUntil(
|
| 68 |
+
caches.keys().then((cacheNames) => {
|
| 69 |
+
return Promise.all(
|
| 70 |
+
cacheNames.map((cacheName) => {
|
| 71 |
+
if (cacheName !== CACHE_NAME) {
|
| 72 |
+
return caches.delete(cacheName);
|
| 73 |
+
}
|
| 74 |
+
})
|
| 75 |
+
);
|
| 76 |
+
})
|
| 77 |
+
);
|
| 78 |
+
});
|
| 79 |
+
|
| 80 |
+
// Background sync for health data
|
| 81 |
+
self.addEventListener('sync', (event) => {
|
| 82 |
+
if (event.tag === 'health-data-sync') {
|
| 83 |
+
event.waitUntil(syncHealthData());
|
| 84 |
+
}
|
| 85 |
+
});
|
| 86 |
+
|
| 87 |
+
async function syncHealthData() {
|
| 88 |
+
try {
|
| 89 |
+
// Get pending data from IndexedDB
|
| 90 |
+
const pendingData = await getPendingHealthData();
|
| 91 |
+
|
| 92 |
+
for (const data of pendingData) {
|
| 93 |
+
// Send to server (in real app)
|
| 94 |
+
await fetch('/api/health-data', {
|
| 95 |
+
method: 'POST',
|
| 96 |
+
headers: { 'Content-Type': 'application/json' },
|
| 97 |
+
body: JSON.stringify(data)
|
| 98 |
+
});
|
| 99 |
+
|
| 100 |
+
// Remove from pending queue
|
| 101 |
+
await removePendingData(data.id);
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
console.log('ซิงค์ข้อมูลสุขภาพสำเร็จ');
|
| 105 |
+
} catch (error) {
|
| 106 |
+
console.error('ซิงค์ข้อมูลล้มเหลว:', error);
|
| 107 |
+
}
|
| 108 |
+
}
|
sleep.html
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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F-8">
|
| 6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
| 7 |
+
<title>การนอน - ชีพจร</title>
|
| 8 |
+
<link rel="icon" type="image/x-icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🌿</text></svg>">
|
| 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://cdn.jsdelivr.net/npm/chart.js"></script>
|
| 12 |
+
<link rel="stylesheet" href="style.css">
|
| 13 |
+
</head>
|
| 14 |
+
<body class="bg-gray-900 text-white font-sans pb-20">
|
| 15 |
+
<!-- Main Container -->
|
| 16 |
+
<div class="min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900">
|
| 17 |
+
<!-- Header -->
|
| 18 |
+
<header class="px-4 pt-12 pb-6">
|
| 19 |
+
<div class="flex items-center justify-between">
|
| 20 |
+
<div>
|
| 21 |
+
<h1 class="text-2xl font-bold bg-gradient-to-r from-blue-400 to-indigo-500 bg-clip-text text-transparent">
|
| 22 |
+
การนอนหลับ
|
| 23 |
+
</h1>
|
| 24 |
+
<p class="text-gray-400 text-sm mt-1">วิเคราะห์คุณภาพการนอนของคุณ 🌙</p>
|
| 25 |
+
</div>
|
| 26 |
+
<button onclick="window.location.href='index.html'" class="w-10 h-10 rounded-full bg-gray-800 flex items-center justify-center">
|
| 27 |
+
<i data-feather="arrow-left" class="w-5 h-5"></i>
|
| 28 |
+
</button>
|
| 29 |
+
</div>
|
| 30 |
+
</header>
|
| 31 |
+
|
| 32 |
+
<!-- Sleep Score -->
|
| 33 |
+
<section class="px-4 mb-6">
|
| 34 |
+
<div class="glass-card rounded-2xl p-6 border border-gray-700/50 text-center">
|
| 35 |
+
<div class="w-24 h-24 mx-auto mb-4 relative">
|
| 36 |
+
<vital-circle
|
| 37 |
+
type="sleep"
|
| 38 |
+
value="78"
|
| 39 |
+
color="from-blue-400 to-indigo-500"
|
| 40 |
+
label="คะแนนการนอน">
|
| 41 |
+
</vital-circle>
|
| 42 |
+
</div>
|
| 43 |
+
<p class="text-gray-400 text-sm">คุณภาพการนอนอยู่ในระดับดี</p>
|
| 44 |
+
<p class="text-xs text-gray-500 mt-1">อัพเดทล่าสุด: 07:00 น.</p>
|
| 45 |
+
</div>
|
| 46 |
+
</section>
|
| 47 |
+
|
| 48 |
+
<!-- Sleep Stages Chart -->
|
| 49 |
+
<section class="px-4 mb-6">
|
| 50 |
+
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
|
| 51 |
+
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
|
| 52 |
+
<i data-feather="bar-chart-2" class="w-5 h-5 text-blue-400"></i>
|
| 53 |
+
ระยะการนอนเมื่อคืน
|
| 54 |
+
</h3>
|
| 55 |
+
<canvas id="sleepStagesChart" height="200"></canvas>
|
| 56 |
+
|
| 57 |
+
<div class="grid grid-cols-3 gap-3 mt-4 text-center">
|
| 58 |
+
<div>
|
| 59 |
+
<p class="text-xs text-gray-400">ลึก</p>
|
| 60 |
+
<p class="text-lg font-bold text-blue-400">2.5 ชม.</p>
|
| 61 |
+
</div>
|
| 62 |
+
<div>
|
| 63 |
+
<p class="text-xs text-gray-400">REM</p>
|
| 64 |
+
<p class="text-lg font-bold text-purple-400">1.8 ชม.</p>
|
| 65 |
+
</div>
|
| 66 |
+
<div>
|
| 67 |
+
<p class="text-xs text-gray-400">ตื้น</p>
|
| 68 |
+
<p class="text-lg font-bold text-gray-400">3.2 ชม.</p>
|
| 69 |
+
</div>
|
| 70 |
+
</div>
|
| 71 |
+
</div>
|
| 72 |
+
</section>
|
| 73 |
+
|
| 74 |
+
<!-- Sleep Trends -->
|
| 75 |
+
<section class="px-4 mb-6">
|
| 76 |
+
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
|
| 77 |
+
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
|
| 78 |
+
<i data-feather="trending-up" class="w-5 h-5 text-green-400"></i>
|
| 79 |
+
เทรนด์การนอน 7 วัน
|
| 80 |
+
</h3>
|
| 81 |
+
<canvas id="sleepTrendChart" height="120"></canvas>
|
| 82 |
+
</div>
|
| 83 |
+
</section>
|
| 84 |
+
|
| 85 |
+
<!-- Sleep Insights -->
|
| 86 |
+
<section class="px-4 mb-6">
|
| 87 |
+
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
|
| 88 |
+
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
|
| 89 |
+
<i data-feather="lightbulb" class="w-5 h-5 text-yellow-400"></i>
|
| 90 |
+
ข้อมูลเชิงลึก
|
| 91 |
+
</h3>
|
| 92 |
+
|
| 93 |
+
<div class="space-y-3">
|
| 94 |
+
<div class="p-3 bg-blue-500/10 border border-blue-500/30 rounded-xl">
|
| 95 |
+
<div class="flex items-center gap-3">
|
| 96 |
+
<div class="w-8 h-8 bg-blue-500 rounded-lg flex items-center justify-center">
|
| 97 |
+
<i data-feather="clock" class="w-4 h-4 text-white"></i>
|
| 98 |
+
</div>
|
| 99 |
+
<div class="flex-1">
|
| 100 |
+
<p class="text-sm font-medium">เวลานอนสม่ำเสมอ</p>
|
| 101 |
+
<p class="text-xs text-gray-400">คุณนอนตรงเวลา 6 จาก 7 วันล่าสุด</p>
|
| 102 |
+
</div>
|
| 103 |
+
<span class="text-xs text-green-400">ดีมาก</span>
|
| 104 |
+
</div>
|
| 105 |
+
</div>
|
| 106 |
+
|
| 107 |
+
<div class="p-3 bg-orange-500/10 border border-orange-500/30 rounded-xl">
|
| 108 |
+
<div class="flex items-center gap-3">
|
| 109 |
+
<div class="w-8 h-8 bg-orange-500 rounded-lg flex items-center justify-center">
|
| 110 |
+
<i data-feather="coffee" class="w-4 h-4 text-white"></i>
|
| 111 |
+
</div>
|
| 112 |
+
<div class="flex-1">
|
| 113 |
+
<p class="text-sm font-medium">คาเฟอีนก่อนนอน</p>
|
| 114 |
+
<p class="text-xs text-gray-400">พบว่าดื่มกาแฟหลัง 15:00 วันนี้</p>
|
| 115 |
+
</div>
|
| 116 |
+
<span class="text-xs text-orange-400">ควรหลีกเลี่ยง</span>
|
| 117 |
+
</div>
|
| 118 |
+
</div>
|
| 119 |
+
</div>
|
| 120 |
+
</div>
|
| 121 |
+
</section>
|
| 122 |
+
|
| 123 |
+
<!-- Bedtime Routine -->
|
| 124 |
+
<section class="px-4 mb-6">
|
| 125 |
+
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
|
| 126 |
+
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
|
| 127 |
+
<i data-feather="moon" class="w-5 h-5 text-indigo-400"></i>
|
| 128 |
+
กิจวัตรก่อนนอน
|
| 129 |
+
</h3>
|
| 130 |
+
|
| 131 |
+
<div class="space-y-2">
|
| 132 |
+
<label class="flex items-center gap-3 p-2 rounded-lg hover:bg-gray-800/30">
|
| 133 |
+
<input type="checkbox" class="w-4 h-4 text-blue-600 rounded">
|
| 134 |
+
<span class="text-sm">งดหน้าจอ 1 ชม. ก่อนนอน</span>
|
| 135 |
+
</label>
|
| 136 |
+
<label class="flex items-center gap-3 p-2 rounded-lg hover:bg-gray-800/30">
|
| 137 |
+
<input type="checkbox" class="w-4 h-4 text-blue-600 rounded">
|
| 138 |
+
<span class="text-sm">ดื่มนมอุ่น</span>
|
| 139 |
+
</label>
|
| 140 |
+
<label class="flex items-center gap-3 p-2 rounded-lg hover:bg-gray-800/30">
|
| 141 |
+
<input type="checkbox" class="w-4 h-4 text-blue-600 rounded">
|
| 142 |
+
<span class="text-sm">อ่านหนังสือ 15 นาที</span>
|
| 143 |
+
</label>
|
| 144 |
+
<label class="flex items-center gap-3 p-2 rounded-lg hover:bg-gray-800/30">
|
| 145 |
+
<input type="checkbox" class="w-4 h-4 text-blue-600 rounded">
|
| 146 |
+
<span class="text-sm">ฝึกสมาธิ 5 นาที</span>
|
| 147 |
+
</label>
|
| 148 |
+
</div>
|
| 149 |
+
</div>
|
| 150 |
+
</section>
|
| 151 |
+
</div>
|
| 152 |
+
|
| 153 |
+
<!-- Bottom Navigation -->
|
| 154 |
+
<main-navbar></main-navbar>
|
| 155 |
+
|
| 156 |
+
<!-- Scripts -->
|
| 157 |
+
<script src="components/navbar.js"></script>
|
| 158 |
+
<script src="components/vital-circle.js"></script>
|
| 159 |
+
<script src="script.js"></script>
|
| 160 |
+
<script>
|
| 161 |
+
// Initialize sleep charts
|
| 162 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 163 |
+
// Sleep Stages Chart
|
| 164 |
+
const stagesCtx = document.getElementById('sleepStagesChart');
|
| 165 |
+
if (stagesCtx) {
|
| 166 |
+
new Chart(stagesCtx, {
|
| 167 |
+
type: 'doughnut',
|
| 168 |
+
data: {
|
| 169 |
+
labels: ['หลับลึก', 'หลับ REM', 'หลับตื้น', 'ตื่น'],
|
| 170 |
+
datasets: [{
|
| 171 |
+
data: [25, 22, 45, 8],
|
| 172 |
+
backgroundColor: [
|
| 173 |
+
'#3b82f6',
|
| 174 |
+
'#a855f7',
|
| 175 |
+
'#9ca3af',
|
| 176 |
+
'#ef4444'
|
| 177 |
+
],
|
| 178 |
+
borderWidth: 0
|
| 179 |
+
}]
|
| 180 |
+
},
|
| 181 |
+
options: {
|
| 182 |
+
responsive: true,
|
| 183 |
+
maintainAspectRatio: false,
|
| 184 |
+
plugins: {
|
| 185 |
+
legend: {
|
| 186 |
+
position: 'bottom',
|
| 187 |
+
labels: {
|
| 188 |
+
padding: 15,
|
| 189 |
+
font: { size: 12, family: 'Prompt' },
|
| 190 |
+
color: '#e5e7eb'
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
});
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
// Sleep Trend Chart
|
| 199 |
+
const trendCtx = document.getElementById('sleepTrendChart');
|
| 200 |
+
if (trendCtx) {
|
| 201 |
+
new Chart(trendCtx, {
|
| 202 |
+
type: 'line',
|
| 203 |
+
data: {
|
| 204 |
+
labels: ['จ', 'อ', 'พ', 'พฤ', 'ศ', 'ส', 'อา'],
|
| 205 |
+
datasets: [{
|
| 206 |
+
label: 'ชั่วโมงการนอน',
|
| 207 |
+
data: [7.5, 6.8, 8.2, 7.1, 7.8, 8.5, 7.2],
|
| 208 |
+
borderColor: '#60a5fa',
|
| 209 |
+
backgroundColor: 'rgba(96, 165, 250, 0.1)',
|
| 210 |
+
tension: 0.4,
|
| 211 |
+
fill: true,
|
| 212 |
+
pointRadius: 4,
|
| 213 |
+
pointBackgroundColor: '#60a5fa'
|
| 214 |
+
}]
|
| 215 |
+
},
|
| 216 |
+
options: {
|
| 217 |
+
responsive: true,
|
| 218 |
+
maintainAspectRatio: false,
|
| 219 |
+
plugins: {
|
| 220 |
+
legend: { display: false }
|
| 221 |
+
},
|
| 222 |
+
scales: {
|
| 223 |
+
y: {
|
| 224 |
+
beginAtZero: true,
|
| 225 |
+
max: 10,
|
| 226 |
+
ticks: {
|
| 227 |
+
color: '#9ca3af'
|
| 228 |
+
},
|
| 229 |
+
grid: {
|
| 230 |
+
color: 'rgba(75, 85, 99, 0.3)'
|
| 231 |
+
}
|
| 232 |
+
},
|
| 233 |
+
x: {
|
| 234 |
+
ticks: {
|
| 235 |
+
color: '#9ca3af'
|
| 236 |
+
},
|
| 237 |
+
grid: {
|
| 238 |
+
display: false
|
| 239 |
+
}
|
| 240 |
+
}
|
| 241 |
+
}
|
| 242 |
+
}
|
| 243 |
+
});
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
// Set active page in navbar
|
| 247 |
+
const navbar = document.querySelector('main-navbar');
|
| 248 |
+
if (navbar) {
|
| 249 |
+
navbar.setActivePage('sleep');
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
// Save to localStorage
|
| 253 |
+
localStorage.setItem('lastSleepView', new Date().toISOString());
|
| 254 |
+
});
|
| 255 |
+
</script>
|
| 256 |
+
<script>feather.replace();</script>
|
| 257 |
+
</body>
|
| 258 |
+
</html>
|
| 259 |
+
>>>>>>> REPLACE
|