CSNET commited on
Commit
6365de3
·
verified ·
1 Parent(s): df62a7a

ทำให้แอพใช้งานได้จริง โดยใส่ mockup data ที

Browse files
Files changed (3) hide show
  1. index.html +71 -131
  2. script.js +446 -32
  3. style.css +174 -4
index.html CHANGED
@@ -73,7 +73,6 @@
73
  <p class="text-indigo-600 font-semibold">ดังนั้น วันนี้ AI แนะนำให้งดเวทหนัก เปลี่ยนเป็นโยคะในบ้าน และดื่มน้ำให้มากขึ้นครับ</p>
74
  </div>
75
  </div>
76
-
77
  <!-- Contextual Vitals -->
78
  <div class="grid grid-cols-2 gap-4 mb-6">
79
  <div class="bg-gradient-to-br from-orange-400 to-red-500 rounded-2xl p-4 text-white">
@@ -81,34 +80,38 @@
81
  <span class="text-sm opacity-90">คุณภาพอากาศ</span>
82
  <i data-feather="alert-triangle" class="w-5 h-5"></i>
83
  </div>
84
- <div class="text-2xl font-bold">PM2.5: 85</div>
85
- <div class="text-sm mt-1">ฝุ่นสูง! ลดการออกกำลังกายกลางแจ้ง</div>
 
86
  </div>
87
  <div class="bg-gradient-to-br from-yellow-400 to-orange-500 rounded-2xl p-4 text-white">
88
  <div class="flex items-center justify-between mb-2">
89
  <span class="text-sm opacity-90">ดัชนีความร้อน</span>
90
  <i data-feather="sun" class="w-5 h-5"></i>
91
  </div>
92
- <div class="text-2xl font-bold">38°C</div>
93
- <div class="text-sm mt-1">ร้อนจัด! เสี่ยงฮีทสโตรก ดื่มน้ำเพิ่ม</div>
 
94
  </div>
95
  </div>
96
-
97
  <!-- Traffic Alert -->
98
  <div class="bg-gradient-to-r from-blue-500 to-purple-600 rounded-2xl p-4 text-white mb-6">
99
  <div class="flex items-center justify-between">
100
- <div>
101
  <div class="flex items-center mb-1">
102
  <i data-feather="navigation" class="w-5 h-5 mr-2"></i>
103
  <span class="text-sm">การจราจร</span>
104
  </div>
105
- <div class="text-lg font-bold">เดินทางไปทำงาน: 45 นาที</div>
106
- <div class="text-sm opacity-90">รถติดหนัก เผื่อเวลาเดินทาง และระวังความเครียดสะสม</div>
 
107
  </div>
108
  </div>
 
 
 
109
  </div>
110
-
111
- <!-- Quick Actions -->
112
  <div class="grid grid-cols-2 gap-4">
113
  <button class="bg-white rounded-2xl p-4 card-shadow flex items-center justify-between hover:shadow-lg transition-shadow">
114
  <div class="flex items-center">
@@ -236,45 +239,18 @@
236
  <div id="activity" class="page-content">
237
  <div class="py-6">
238
  <h1 class="text-3xl font-bold text-gray-900 mb-6">กิจกรรม</h1>
239
-
240
  <!-- Today's Activities -->
241
  <div class="bg-white rounded-2xl p-6 card-shadow mb-6">
242
  <h2 class="text-lg font-bold text-gray-900 mb-4">กิจกรรมวันนี้</h2>
243
- <div class="space-y-3">
244
- <div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
245
- <div class="flex items-center">
246
- <div class="w-10 h-10 bg-blue-100 rounded-full flex items-center justify-center mr-3">
247
- <i data-feather="target" class="w-5 h-5 text-blue-600"></i>
248
- </div>
249
- <div>
250
- <div class="font-semibold">วิ่งในสวน</div>
251
- <div class="text-sm text-gray-500">07:30 - 08:00</div>
252
- </div>
253
- </div>
254
- <div class="text-right">
255
- <div class="font-bold text-blue-600">10.2</div>
256
- <div class="text-sm text-gray-500">Strain</div>
257
- </div>
258
- </div>
259
- <div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
260
- <div class="flex items-center">
261
- <div class="w-10 h-10 bg-green-100 rounded-full flex items-center justify-center mr-3">
262
- <i data-feather="heart" class="w-5 h-5 text-green-600"></i>
263
- </div>
264
- <div>
265
- <div class="font-semibold">โยคะ</div>
266
- <div class="text-sm text-gray-500">18:00 - 18:30</div>
267
- </div>
268
- </div>
269
- <div class="text-right">
270
- <div class="font-bold text-green-600">4.5</div>
271
- <div class="text-sm text-gray-500">Strain</div>
272
- </div>
273
- </div>
274
  </div>
 
 
 
 
275
  </div>
276
-
277
- <!-- Quick Log -->
278
  <div class="grid grid-cols-2 gap-4 mb-6">
279
  <button class="bg-gradient-to-r from-blue-500 to-blue-600 text-white rounded-2xl p-4 flex items-center justify-center hover:shadow-lg transition">
280
  <i data-feather="plus-circle" class="w-5 h-5 mr-2"></i>
@@ -473,30 +449,29 @@
473
  <div id="nutrition" class="page-content">
474
  <div class="py-6">
475
  <h1 class="text-3xl font-bold text-gray-900 mb-6">โภชนาการ</h1>
476
-
477
  <!-- Today's Summary -->
478
  <div class="bg-gradient-to-br from-orange-500 to-red-600 rounded-2xl p-6 text-white mb-6">
479
  <div class="text-center">
480
- <div class="text-3xl font-bold mb-2">1,250 / 2,000</div>
481
  <div class="text-lg opacity-90">แคลอรี่วันนี้</div>
 
482
  </div>
483
  <div class="grid grid-cols-3 gap-4 mt-6">
484
  <div class="text-center">
485
- <div class="text-xl font-bold">45g</div>
486
- <div class="text-xs opacity-80">โปรตีน</div>
487
  </div>
488
  <div class="text-center">
489
- <div class="text-xl font-bold">180g</div>
490
- <div class="text-xs opacity-80">คาร์บ</div>
491
  </div>
492
  <div class="text-center">
493
- <div class="text-xl font-bold">55g</div>
494
- <div class="text-xs opacity-80">ไขมัน</div>
495
  </div>
496
  </div>
497
  </div>
498
-
499
- <!-- Quick Actions -->
500
  <div class="grid grid-cols-2 gap-4 mb-6">
501
  <button class="bg-white rounded-2xl p-4 card-shadow flex items-center justify-between hover:shadow-lg transition">
502
  <div class="flex items-center">
@@ -511,26 +486,34 @@
511
  </div>
512
  </button>
513
  </div>
514
-
515
  <!-- Today's Meals -->
516
  <div class="bg-white rounded-2xl p-6 card-shadow">
517
  <h2 class="text-lg font-bold text-gray-900 mb-4">มื้ออาหารวันนี้</h2>
518
- <div class="space-y-3">
519
- <div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
520
- <div>
521
- <div class="font-semibold">ข้าวมันไก่</div>
522
- <div class="text-sm text-gray-500">08:30 • 450 แคล</div>
523
- </div>
524
- <img src="http://static.photos/food/60x60/1" alt="อาหาร" class="w-12 h-12 rounded-lg object-cover">
525
- </div>
526
- <div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
527
- <div>
528
- <div class="font-semibold">กะเพราหมูกรอบ</div>
529
- <div class="text-sm text-gray-500">12:00 • 550 แคล</div>
530
- </div>
531
- <img src="http://static.photos/food/60x60/2" alt="อาหาร" class="w-12 h-12 rounded-lg object-cover">
532
- </div>
533
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
534
  </div>
535
 
536
  <!-- IF Tracker -->
@@ -540,31 +523,33 @@
540
  <span class="bg-white bg-opacity-20 px-3 py-1 rounded-full text-sm">16:8</span>
541
  </div>
542
  <div class="text-center">
543
- <div class="text-3xl font-bold mb-2">06:45:30</div>
544
  <div class="text-sm opacity-90">เวลาที่เหลือ</div>
545
  </div>
546
  </div>
547
- </div>
548
  </div>
549
 
550
  <!-- Mental Page -->
551
  <div id="mental" class="page-content">
552
  <div class="py-6">
553
  <h1 class="text-3xl font-bold text-gray-900 mb-6">สุขภาพจิต</h1>
554
-
555
  <!-- Current Mood -->
556
  <div class="bg-gradient-to-br from-purple-500 to-pink-600 rounded-2xl p-6 text-white mb-6">
557
  <h2 class="text-lg font-bold mb-4">อารมณ์วันนี้</h2>
558
  <div class="flex justify-around">
559
- <button class="text-4xl hover:scale-110 transition">😊</button>
560
- <button class="text-4xl hover:scale-110 transition">😐</button>
561
- <button class="text-4xl hover:scale-110 transition">😔</button>
562
- <button class="text-4xl hover:scale-110 transition">😰</button>
563
- <button class="text-4xl hover:scale-110 transition">😡</button>
 
 
 
 
564
  </div>
565
  </div>
566
-
567
- <!-- Stress Level -->
568
  <div class="bg-white rounded-2xl p-6 card-shadow mb-6">
569
  <h2 class="text-lg font-bold text-gray-900 mb-4">ระดับความเครียด</h2>
570
  <div class="text-center mb-4">
@@ -629,65 +614,21 @@
629
  <div id="community" class="page-content">
630
  <div class="py-6">
631
  <h1 class="text-3xl font-bold text-gray-900 mb-6">ชุมชน</h1>
632
-
633
  <!-- My Teams -->
634
  <div class="bg-white rounded-2xl p-6 card-shadow mb-6">
635
  <h2 class="text-lg font-bold text-gray-900 mb-4">ทีมของฉัน</h2>
636
- <div class="space-y-3">
637
- <div class="flex items-center justify-between p-3 bg-indigo-50 rounded-lg">
638
- <div class="flex items-center">
639
- <div class="w-10 h-10 bg-indigo-600 rounded-full flex items-center justify-center text-white font-bold mr-3">
640
- บ
641
- </div>
642
- <div>
643
- <div class="font-semibold">บริษัท Pulse Tech</div>
644
- <div class="text-sm text-gray-500">12 สมาชิก</div>
645
- </div>
646
- </div>
647
- <i data-feather="chevron-right" class="w-5 h-5 text-gray-400"></i>
648
- </div>
649
- <div class="flex items-center justify-between p-3 bg-green-50 rounded-lg">
650
- <div class="flex items-center">
651
- <div class="w-10 h-10 bg-green-600 rounded-full flex items-center justify-center text-white font-bold mr-3">
652
- ว
653
- </div>
654
- <div>
655
- <div class="font-semibold">วิ่งสวนลุม</div>
656
- <div class="text-sm text-gray-500">28 สมาชิก</div>
657
- </div>
658
- </div>
659
- <i data-feather="chevron-right" class="w-5 h-5 text-gray-400"></i>
660
- </div>
661
  </div>
662
  </div>
663
-
664
  <!-- Active Challenges -->
665
  <div class="bg-white rounded-2xl p-6 card-shadow">
666
  <h2 class="text-lg font-bold text-gray-900 mb-4">Challenge ที่กำลังทำ</h2>
667
- <div class="space-y-4">
668
- <div class="border rounded-lg p-4">
669
- <div class="flex items-center justify-between mb-2">
670
- <h3 class="font-bold">นอน 7 ชั่วโมง 30 วัน</h3>
671
- <span class="bg-green-100 text-green-800 px-2 py-1 rounded text-sm">กำลังทำ</span>
672
- </div>
673
- <div class="text-sm text-gray-600 mb-2">วันที่ 15/30</div>
674
- <div class="w-full bg-gray-200 rounded-full h-2">
675
- <div class="bg-green-500 h-2 rounded-full" style="width: 50%"></div>
676
- </div>
677
- </div>
678
- <div class="border rounded-lg p-4">
679
- <div class="flex items-center justify-between mb-2">
680
- <h3 class="font-bold">ลดพุงหลังสงกรานต์</h3>
681
- <span class="bg-blue-100 text-blue-800 px-2 py-1 rounded text-sm">เริ่มใหม่</span>
682
- </div>
683
- <div class="text-sm text-gray-600 mb-2">เหลืออีก 15 วัน</div>
684
- <div class="w-full bg-gray-200 rounded-full h-2">
685
- <div class="bg-blue-500 h-2 rounded-full" style="width: 10%"></div>
686
- </div>
687
- </div>
688
  </div>
689
  </div>
690
- </div>
691
  </div>
692
 
693
  <!-- Settings Page -->
@@ -757,6 +698,5 @@
757
  <script src="components/vitalCircle.js"></script>
758
  <script src="script.js"></script>
759
  <script>feather.replace();</script>
760
- <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
761
  </body>
762
  </html>
 
73
  <p class="text-indigo-600 font-semibold">ดังนั้น วันนี้ AI แนะนำให้งดเวทหนัก เปลี่ยนเป็นโยคะในบ้าน และดื่มน้ำให้มากขึ้นครับ</p>
74
  </div>
75
  </div>
 
76
  <!-- Contextual Vitals -->
77
  <div class="grid grid-cols-2 gap-4 mb-6">
78
  <div class="bg-gradient-to-br from-orange-400 to-red-500 rounded-2xl p-4 text-white">
 
80
  <span class="text-sm opacity-90">คุณภาพอากาศ</span>
81
  <i data-feather="alert-triangle" class="w-5 h-5"></i>
82
  </div>
83
+ <div class="text-2xl font-bold" data-weather="pm25">PM2.5: 85</div>
84
+ <div class="text-sm mt-1" data-weather="location">กรุงเทพฯ - ฝุ่นสูง!</div>
85
+ <div class="text-xs mt-2 opacity-80">ลดการออกกำลังกายกลางแจ้ง</div>
86
  </div>
87
  <div class="bg-gradient-to-br from-yellow-400 to-orange-500 rounded-2xl p-4 text-white">
88
  <div class="flex items-center justify-between mb-2">
89
  <span class="text-sm opacity-90">ดัชนีความร้อน</span>
90
  <i data-feather="sun" class="w-5 h-5"></i>
91
  </div>
92
+ <div class="text-2xl font-bold" data-weather="temperature">38°C</div>
93
+ <div class="text-sm mt-1">UV: 10 - รุนแรง</div>
94
+ <div class="text-xs mt-2 opacity-80">เสี่ยงฮีทสโตรก ดื่มน้ำเพิ่ม</div>
95
  </div>
96
  </div>
 
97
  <!-- Traffic Alert -->
98
  <div class="bg-gradient-to-r from-blue-500 to-purple-600 rounded-2xl p-4 text-white mb-6">
99
  <div class="flex items-center justify-between">
100
+ <div class="flex-1">
101
  <div class="flex items-center mb-1">
102
  <i data-feather="navigation" class="w-5 h-5 mr-2"></i>
103
  <span class="text-sm">การจราจร</span>
104
  </div>
105
+ <div class="text-lg font-bold" data-traffic="time">เดินทางไปทำงาน: 45 นาที</div>
106
+ <div class="text-sm opacity-90" data-traffic="route">สุขุมวิท - อโศก • รถติดหนัก</div>
107
+ <div class="text-xs mt-1 opacity-80">เผื่อเวลาเดินทาง และระวังความเครียดสะสม</div>
108
  </div>
109
  </div>
110
+ <div class="traffic-alternatives mt-3">
111
+ <!-- Alternative routes will be inserted here -->
112
+ </div>
113
  </div>
114
+ <!-- Quick Actions -->
 
115
  <div class="grid grid-cols-2 gap-4">
116
  <button class="bg-white rounded-2xl p-4 card-shadow flex items-center justify-between hover:shadow-lg transition-shadow">
117
  <div class="flex items-center">
 
239
  <div id="activity" class="page-content">
240
  <div class="py-6">
241
  <h1 class="text-3xl font-bold text-gray-900 mb-6">กิจกรรม</h1>
 
242
  <!-- Today's Activities -->
243
  <div class="bg-white rounded-2xl p-6 card-shadow mb-6">
244
  <h2 class="text-lg font-bold text-gray-900 mb-4">กิจกรรมวันนี้</h2>
245
+ <div class="activities-list space-y-3">
246
+ <!-- Activities will be dynamically inserted here -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  </div>
248
+ <button class="w-full mt-4 bg-indigo-50 text-indigo-600 rounded-lg py-2 font-semibold hover:bg-indigo-100 transition">
249
+ <i data-feather="plus" class="w-4 h-4 inline mr-2"></i>
250
+ เพิ่มกิจกรรม
251
+ </button>
252
  </div>
253
+ <!-- Quick Log -->
 
254
  <div class="grid grid-cols-2 gap-4 mb-6">
255
  <button class="bg-gradient-to-r from-blue-500 to-blue-600 text-white rounded-2xl p-4 flex items-center justify-center hover:shadow-lg transition">
256
  <i data-feather="plus-circle" class="w-5 h-5 mr-2"></i>
 
449
  <div id="nutrition" class="page-content">
450
  <div class="py-6">
451
  <h1 class="text-3xl font-bold text-gray-900 mb-6">โภชนาการ</h1>
 
452
  <!-- Today's Summary -->
453
  <div class="bg-gradient-to-br from-orange-500 to-red-600 rounded-2xl p-6 text-white mb-6">
454
  <div class="text-center">
455
+ <div class="text-3xl font-bold mb-2" data-nutrition="calories">1,250 / 2,000</div>
456
  <div class="text-lg opacity-90">แคลอรี่วันนี้</div>
457
+ <div class="text-sm mt-2 opacity-80">คงเหลือ 750 แคล • เผาผลาญ 320 แคล</div>
458
  </div>
459
  <div class="grid grid-cols-3 gap-4 mt-6">
460
  <div class="text-center">
461
+ <div class="text-xl font-bold" data-nutrition="protein">45g</div>
462
+ <div class="text-xs opacity-80">โปรตีน (60%)</div>
463
  </div>
464
  <div class="text-center">
465
+ <div class="text-xl font-bold" data-nutrition="carbs">180g</div>
466
+ <div class="text-xs opacity-80">คาร์บ (72%)</div>
467
  </div>
468
  <div class="text-center">
469
+ <div class="text-xl font-bold" data-nutrition="fat">55g</div>
470
+ <div class="text-xs opacity-80">ไขมัน (85%)</div>
471
  </div>
472
  </div>
473
  </div>
474
+ <!-- Quick Actions -->
 
475
  <div class="grid grid-cols-2 gap-4 mb-6">
476
  <button class="bg-white rounded-2xl p-4 card-shadow flex items-center justify-between hover:shadow-lg transition">
477
  <div class="flex items-center">
 
486
  </div>
487
  </button>
488
  </div>
 
489
  <!-- Today's Meals -->
490
  <div class="bg-white rounded-2xl p-6 card-shadow">
491
  <h2 class="text-lg font-bold text-gray-900 mb-4">มื้ออาหารวันนี้</h2>
492
+ <div class="space-y-3" id="meals-list">
493
+ <!-- Meals will be dynamically inserted here -->
 
 
 
 
 
 
 
 
 
 
 
 
 
494
  </div>
495
+ <button class="w-full mt-4 bg-orange-50 text-orange-600 rounded-lg py-2 font-semibold hover:bg-orange-100 transition">
496
+ <i data-feather="camera" class="w-4 h-4 inline mr-2"></i>
497
+ ถ่ายรูปเพิ่มอาหาร
498
+ </button>
499
+ </div>
500
+ <!-- Water Intake -->
501
+ <div class="bg-gradient-to-r from-blue-500 to-cyan-600 rounded-2xl p-6 text-white mt-6">
502
+ <div class="flex items-center justify-between mb-4">
503
+ <h3 class="text-lg font-bold">การดื่มน้ำ</h3>
504
+ <span class="bg-white bg-opacity-20 px-3 py-1 rounded-full text-sm">วันนี้</span>
505
+ </div>
506
+ <div class="text-center mb-4">
507
+ <div class="text-3xl font-bold mb-2" data-water="text">1,600 / 2,500 ml</div>
508
+ <div class="text-sm opacity-90">เป้าหมายประจำวัน</div>
509
+ </div>
510
+ <div class="w-full bg-white bg-opacity-30 rounded-full h-3 mb-4">
511
+ <div class="bg-white h-3 rounded-full transition-all duration-500" data-water="progress" style="width: 64%"></div>
512
+ </div>
513
+ <button class="w-full bg-white bg-opacity-20 text-white rounded-lg py-2 font-semibold hover:bg-opacity-30 transition">
514
+ <i data-feather="plus-circle" class="w-4 h-4 inline mr-2"></i>
515
+ เพิ่ม 250 มล.
516
+ </button>
517
  </div>
518
 
519
  <!-- IF Tracker -->
 
523
  <span class="bg-white bg-opacity-20 px-3 py-1 rounded-full text-sm">16:8</span>
524
  </div>
525
  <div class="text-center">
526
+ <div class="text-3xl font-bold mb-2 current-time">06:45:30</div>
527
  <div class="text-sm opacity-90">เวลาที่เหลือ</div>
528
  </div>
529
  </div>
530
+ </div>
531
  </div>
532
 
533
  <!-- Mental Page -->
534
  <div id="mental" class="page-content">
535
  <div class="py-6">
536
  <h1 class="text-3xl font-bold text-gray-900 mb-6">สุขภาพจิต</h1>
 
537
  <!-- Current Mood -->
538
  <div class="bg-gradient-to-br from-purple-500 to-pink-600 rounded-2xl p-6 text-white mb-6">
539
  <h2 class="text-lg font-bold mb-4">อารมณ์วันนี้</h2>
540
  <div class="flex justify-around">
541
+ <button class="text-4xl hover:scale-110 transition mood-button" data-mood="happy">😊</button>
542
+ <button class="text-4xl hover:scale-110 transition mood-button" data-mood="neutral">😐</button>
543
+ <button class="text-4xl hover:scale-110 transition mood-button" data-mood="sad">😔</button>
544
+ <button class="text-4xl hover:scale-110 transition mood-button" data-mood="anxious">😰</button>
545
+ <button class="text-4xl hover:scale-110 transition mood-button" data-mood="angry">😡</button>
546
+ </div>
547
+ <div class="mt-4 text-center">
548
+ <div class="text-sm opacity-90">ระดับความเครียด:</div>
549
+ <div class="text-2xl font-bold" data-mental="stress">45%</div>
550
  </div>
551
  </div>
552
+ <!-- Stress Level -->
 
553
  <div class="bg-white rounded-2xl p-6 card-shadow mb-6">
554
  <h2 class="text-lg font-bold text-gray-900 mb-4">ระดับความเครียด</h2>
555
  <div class="text-center mb-4">
 
614
  <div id="community" class="page-content">
615
  <div class="py-6">
616
  <h1 class="text-3xl font-bold text-gray-900 mb-6">ชุมชน</h1>
 
617
  <!-- My Teams -->
618
  <div class="bg-white rounded-2xl p-6 card-shadow mb-6">
619
  <h2 class="text-lg font-bold text-gray-900 mb-4">ทีมของฉัน</h2>
620
+ <div class="teams-list space-y-3">
621
+ <!-- Teams will be dynamically inserted here -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
622
  </div>
623
  </div>
 
624
  <!-- Active Challenges -->
625
  <div class="bg-white rounded-2xl p-6 card-shadow">
626
  <h2 class="text-lg font-bold text-gray-900 mb-4">Challenge ที่กำลังทำ</h2>
627
+ <div class="challenges-list space-y-4">
628
+ <!-- Challenges will be dynamically inserted here -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
629
  </div>
630
  </div>
631
+ </div>
632
  </div>
633
 
634
  <!-- Settings Page -->
 
698
  <script src="components/vitalCircle.js"></script>
699
  <script src="script.js"></script>
700
  <script>feather.replace();</script>
 
701
  </body>
702
  </html>
script.js CHANGED
@@ -147,22 +147,110 @@ function handleFormSubmit(e) {
147
  modal.style.display = 'none';
148
  }
149
  }
150
-
151
  function loadInitialData() {
152
  // Simulate loading data from APIs
153
  loadHealthData();
154
  loadWeatherData();
155
  loadTrafficData();
156
  loadNutritionData();
 
 
157
  }
158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  async function loadHealthData() {
160
- // Simulate API call for health data
161
  try {
162
  // const response = await fetch('/api/health');
163
  // const data = await response.json();
164
 
165
- // Simulated data
166
  const healthData = {
167
  recovery: 72,
168
  strain: 8.5,
@@ -174,16 +262,41 @@ async function loadHealthData() {
174
  rem: 19,
175
  light: 55,
176
  awake: 3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  }
178
  };
179
 
180
  updateHealthUI(healthData);
 
 
181
  } catch (error) {
182
  console.error('Error loading health data:', error);
183
  showToast('ไม่สามารถโหลดข้อมูลสุขภาพได้', 'error');
184
  }
185
  }
186
-
187
  function updateHealthUI(data) {
188
  // Update vitals circles
189
  updateVitalCircles(data);
@@ -239,23 +352,34 @@ function updateRecoveryFactors(data) {
239
  // Update recovery factor analysis
240
  // This would be implemented based on the actual recovery calculation
241
  }
242
-
243
  async function loadWeatherData() {
244
  try {
245
- // Simulate API call for weather data
246
  const weatherData = {
247
  temperature: 38,
248
  humidity: 75,
249
  pm25: 85,
250
- aqi: 152
 
 
 
 
 
 
 
 
 
 
 
 
251
  };
252
 
253
  updateWeatherUI(weatherData);
 
254
  } catch (error) {
255
  console.error('Error loading weather data:', error);
256
  }
257
  }
258
-
259
  function updateWeatherUI(data) {
260
  // Update weather cards
261
  const pm25Element = document.querySelector('[data-weather="pm25"]');
@@ -268,54 +392,104 @@ function updateWeatherUI(data) {
268
  tempElement.textContent = `${data.temperature}°C`;
269
  }
270
  }
271
-
272
  async function loadTrafficData() {
273
  try {
274
- // Simulate API call for traffic data
275
  const trafficData = {
276
  homeToWork: 45,
277
  workToHome: 55,
278
- congestionLevel: 'high'
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  };
280
 
281
  updateTrafficUI(trafficData);
 
282
  } catch (error) {
283
  console.error('Error loading traffic data:', error);
284
  }
285
  }
286
-
287
  function updateTrafficUI(data) {
288
  const trafficElement = document.querySelector('[data-traffic="time"]');
289
  if (trafficElement) {
290
  trafficElement.textContent = `${data.homeToWork} นาที`;
291
  }
292
  }
293
-
294
  async function loadNutritionData() {
295
  try {
296
- // Simulate API call for nutrition data
297
  const nutritionData = {
298
  calories: {
299
  consumed: 1250,
300
- goal: 2000
 
 
301
  },
302
  macros: {
303
- protein: 45,
304
- carbs: 180,
305
- fat: 55
306
  },
307
  meals: [
308
- { name: 'ข้าวมันไก่', time: '08:30', calories: 450 },
309
- { name: 'กะเพราหมูกรอบ', time: '12:00', calories: 550 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  ]
311
  };
312
 
313
  updateNutritionUI(nutritionData);
 
 
314
  } catch (error) {
315
  console.error('Error loading nutrition data:', error);
316
  }
317
  }
318
-
319
  function updateNutritionUI(data) {
320
  // Update calories display
321
  const caloriesElement = document.querySelector('[data-nutrition="calories"]');
@@ -365,30 +539,60 @@ function startMeditation() {
365
  console.log('Starting meditation...');
366
  showToast('เริ่มการนั่งสมาธิ...');
367
  }
368
-
369
  function showToast(message, type = 'success') {
370
  // Create and show toast notification
371
  const toast = document.createElement('div');
372
- toast.className = 'toast';
373
- toast.textContent = message;
374
 
375
- if (type === 'error') {
376
- toast.style.backgroundColor = '#ef4444';
377
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
378
 
379
  document.body.appendChild(toast);
380
 
 
381
  setTimeout(() => {
382
- toast.remove();
 
 
 
 
 
 
 
 
 
 
383
  }, 3000);
384
  }
385
-
386
  // Simulate real-time data updates
387
  setInterval(() => {
388
  // Update time-based data
389
  updateTime();
390
  updateRealTimeMetrics();
391
- }, 60000); // Update every minute
 
392
 
393
  function updateTime() {
394
  const now = new Date();
@@ -400,10 +604,220 @@ function updateTime() {
400
 
401
  function updateRealTimeMetrics() {
402
  // Update metrics that change in real-time
403
- // This would fetch fresh data from APIs
404
- console.log('Updating real-time metrics...');
 
 
 
 
 
 
 
 
 
 
 
 
 
405
  }
406
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
407
  // Handle visibility change
408
  document.addEventListener('visibilitychange', function() {
409
  if (document.visibilityState === 'visible') {
 
147
  modal.style.display = 'none';
148
  }
149
  }
 
150
  function loadInitialData() {
151
  // Simulate loading data from APIs
152
  loadHealthData();
153
  loadWeatherData();
154
  loadTrafficData();
155
  loadNutritionData();
156
+ loadMentalHealthData();
157
+ loadCommunityData();
158
  }
159
 
160
+ async function loadMentalHealthData() {
161
+ try {
162
+ const mentalData = {
163
+ stressLevel: 45,
164
+ mood: 'calm',
165
+ meditationStreak: 7,
166
+ meditationMinutes: 35,
167
+ moodHistory: [
168
+ { date: '2024-01-01', mood: 'happy', stress: 40 },
169
+ { date: '2024-01-02', mood: 'neutral', stress: 50 },
170
+ { date: '2024-01-03', mood: 'stressed', stress: 65 },
171
+ { date: '2024-01-04', mood: 'calm', stress: 45 }
172
+ ],
173
+ recommendedActivities: [
174
+ { name: 'นั่งสมาธิ 5 นาที', duration: '5:00', type: 'meditation' },
175
+ { name: 'สวดมนต์ ชินบัญชร', duration: '10:00', type: 'prayer' },
176
+ { name: 'ฟังเพลงสมาธิ', duration: '15:00', type: 'music' }
177
+ ],
178
+ officeSyndromeAlert: {
179
+ sittingTime: 45,
180
+ reminderInterval: 30
181
+ }
182
+ };
183
+
184
+ updateMentalHealthUI(mentalData);
185
+ } catch (error) {
186
+ console.error('Error loading mental health data:', error);
187
+ }
188
+ }
189
+
190
+ async function loadCommunityData() {
191
+ try {
192
+ const communityData = {
193
+ teams: [
194
+ {
195
+ name: 'บริษัท Pulse Tech',
196
+ members: 12,
197
+ rank: 3,
198
+ points: 2850,
199
+ avatar: 'บ'
200
+ },
201
+ {
202
+ name: 'วิ่งสวนลุม',
203
+ members: 28,
204
+ rank: 1,
205
+ points: 3200,
206
+ avatar: 'ว'
207
+ }
208
+ ],
209
+ challenges: [
210
+ {
211
+ id: 1,
212
+ name: 'นอน 7 ชั่วโมง 30 วัน',
213
+ progress: 15,
214
+ total: 30,
215
+ status: 'active',
216
+ reward: '100 points'
217
+ },
218
+ {
219
+ id: 2,
220
+ name: 'ลดพุงหลังสงกรานต์',
221
+ progress: 2,
222
+ total: 30,
223
+ status: 'active',
224
+ reward: '250 points'
225
+ },
226
+ {
227
+ id: 3,
228
+ name: 'วิ่ง 100 กม. เดือนนี้',
229
+ progress: 68,
230
+ total: 100,
231
+ status: 'active',
232
+ reward: '500 points'
233
+ }
234
+ ],
235
+ leaderboard: [
236
+ { rank: 1, name: 'สมชาย', points: 3250, avatar: 'ส' },
237
+ { rank: 2, name: 'มานี', points: 2980, avatar: 'ม' },
238
+ { rank: 3, name: 'คุณ', points: 2850, avatar: 'จ' }
239
+ ]
240
+ };
241
+
242
+ updateCommunityUI(communityData);
243
+ } catch (error) {
244
+ console.error('Error loading community data:', error);
245
+ }
246
+ }
247
  async function loadHealthData() {
248
+ // Simulate API call for health data with realistic mock data
249
  try {
250
  // const response = await fetch('/api/health');
251
  // const data = await response.json();
252
 
253
+ // Simulated data with realistic Thai user patterns
254
  const healthData = {
255
  recovery: 72,
256
  strain: 8.5,
 
262
  rem: 19,
263
  light: 55,
264
  awake: 3
265
+ },
266
+ weeklyData: {
267
+ monday: { recovery: 68, strain: 9.2, sleep: 7.2 },
268
+ tuesday: { recovery: 75, strain: 8.8, sleep: 8.1 },
269
+ wednesday: { recovery: 72, strain: 8.5, sleep: 7.8 },
270
+ thursday: { recovery: 70, strain: 9.0, sleep: 7.5 },
271
+ friday: { recovery: 65, strain: 10.5, sleep: 6.8 },
272
+ saturday: { recovery: 80, strain: 15.8, sleep: 8.5 },
273
+ sunday: { recovery: 78, strain: 6.3, sleep: 9.0 }
274
+ },
275
+ activities: [
276
+ { name: 'วิ่งในสวน', time: '07:30-08:00', strain: 10.2, calories: 280, type: 'running' },
277
+ { name: 'โยคะ', time: '18:00-18:30', strain: 4.5, calories: 120, type: 'yoga' },
278
+ { name: 'เดินทางไปทำงาน', time: '08:30-09:15', strain: 3.2, calories: 95, type: 'walking' }
279
+ ],
280
+ heartRateVariability: {
281
+ current: 52,
282
+ baseline: 55,
283
+ trend: 'slightly_down'
284
+ },
285
+ restingHeartRate: {
286
+ current: 58,
287
+ baseline: 60,
288
+ trend: 'stable'
289
  }
290
  };
291
 
292
  updateHealthUI(healthData);
293
+ loadWeeklyTrends(healthData.weeklyData);
294
+ loadActivities(healthData.activities);
295
  } catch (error) {
296
  console.error('Error loading health data:', error);
297
  showToast('ไม่สามารถโหลดข้อมูลสุขภาพได้', 'error');
298
  }
299
  }
 
300
  function updateHealthUI(data) {
301
  // Update vitals circles
302
  updateVitalCircles(data);
 
352
  // Update recovery factor analysis
353
  // This would be implemented based on the actual recovery calculation
354
  }
 
355
  async function loadWeatherData() {
356
  try {
357
+ // Simulate API call for weather data with Bangkok realistic data
358
  const weatherData = {
359
  temperature: 38,
360
  humidity: 75,
361
  pm25: 85,
362
+ aqi: 152,
363
+ location: 'กรุงเทพมหานคร',
364
+ weatherCondition: 'ร้อนจัด',
365
+ uvIndex: 10,
366
+ windSpeed: 12,
367
+ visibility: 5,
368
+ hourlyForecast: [
369
+ { time: '09:00', temp: 35, pm25: 78 },
370
+ { time: '12:00', temp: 38, pm25: 85 },
371
+ { time: '15:00', temp: 37, pm25: 82 },
372
+ { time: '18:00', temp: 34, pm25: 75 },
373
+ { time: '21:00', temp: 30, pm25: 68 }
374
+ ]
375
  };
376
 
377
  updateWeatherUI(weatherData);
378
+ updateHourlyForecast(weatherData.hourlyForecast);
379
  } catch (error) {
380
  console.error('Error loading weather data:', error);
381
  }
382
  }
 
383
  function updateWeatherUI(data) {
384
  // Update weather cards
385
  const pm25Element = document.querySelector('[data-weather="pm25"]');
 
392
  tempElement.textContent = `${data.temperature}°C`;
393
  }
394
  }
 
395
  async function loadTrafficData() {
396
  try {
397
+ // Simulate API call for traffic data with Bangkok realistic data
398
  const trafficData = {
399
  homeToWork: 45,
400
  workToHome: 55,
401
+ congestionLevel: 'high',
402
+ route: 'สุขุมวิท - อโศก',
403
+ distance: 12.5,
404
+ alternativeRoutes: [
405
+ { route: 'ถนนพระราม 4', time: 52, distance: 14.2 },
406
+ { route: 'BTS', time: 28, distance: 12.8 }
407
+ ],
408
+ trafficConditions: {
409
+ current: 'ติดขัดหนัก',
410
+ peakHours: ['07:00-09:00', '17:00-19:00'],
411
+ incidents: [
412
+ { location: 'แยกอโศก', type: 'อุบัติเหตุ', delay: 15 }
413
+ ]
414
+ }
415
  };
416
 
417
  updateTrafficUI(trafficData);
418
+ updateTrafficAlternatives(trafficData.alternativeRoutes);
419
  } catch (error) {
420
  console.error('Error loading traffic data:', error);
421
  }
422
  }
 
423
  function updateTrafficUI(data) {
424
  const trafficElement = document.querySelector('[data-traffic="time"]');
425
  if (trafficElement) {
426
  trafficElement.textContent = `${data.homeToWork} นาที`;
427
  }
428
  }
 
429
  async function loadNutritionData() {
430
  try {
431
+ // Simulate API call for nutrition data with Thai food
432
  const nutritionData = {
433
  calories: {
434
  consumed: 1250,
435
+ goal: 2000,
436
+ burned: 320,
437
+ remaining: 750
438
  },
439
  macros: {
440
+ protein: { consumed: 45, goal: 75 },
441
+ carbs: { consumed: 180, goal: 250 },
442
+ fat: { consumed: 55, goal: 65 }
443
  },
444
  meals: [
445
+ {
446
+ name: 'ข้าวมันไก่',
447
+ time: '08:30',
448
+ calories: 450,
449
+ protein: 25,
450
+ carbs: 45,
451
+ fat: 18,
452
+ image: 'http://static.photos/food/80x80/1'
453
+ },
454
+ {
455
+ name: 'กะเพราหมูกรอบ',
456
+ time: '12:00',
457
+ calories: 550,
458
+ protein: 28,
459
+ carbs: 52,
460
+ fat: 25,
461
+ image: 'http://static.photos/food/80x80/2'
462
+ },
463
+ {
464
+ name: 'ขนมปังกับไข่ต้ม',
465
+ time: '15:30',
466
+ calories: 250,
467
+ protein: 12,
468
+ carbs: 28,
469
+ fat: 12,
470
+ image: 'http://static.photos/food/80x80/3'
471
+ }
472
+ ],
473
+ waterIntake: {
474
+ consumed: 1600,
475
+ goal: 2500,
476
+ unit: 'ml'
477
+ },
478
+ nutritionScore: 78,
479
+ recommendations: [
480
+ 'เพิ่มผักให้ครบ 5 สี',
481
+ 'ลดโซเดียมจากอาหาร',
482
+ 'ดื่มน้ำเพิ่ม 900 มล.'
483
  ]
484
  };
485
 
486
  updateNutritionUI(nutritionData);
487
+ updateWaterIntake(nutritionData.waterIntake);
488
+ updateNutritionScore(nutritionData.nutritionScore);
489
  } catch (error) {
490
  console.error('Error loading nutrition data:', error);
491
  }
492
  }
 
493
  function updateNutritionUI(data) {
494
  // Update calories display
495
  const caloriesElement = document.querySelector('[data-nutrition="calories"]');
 
539
  console.log('Starting meditation...');
540
  showToast('เริ่มการนั่งสมาธิ...');
541
  }
 
542
  function showToast(message, type = 'success') {
543
  // Create and show toast notification
544
  const toast = document.createElement('div');
545
+ toast.className = `toast toast-${type}`;
 
546
 
547
+ // Add icon based on type
548
+ const icons = {
549
+ success: '✓',
550
+ error: '✕',
551
+ warning: '⚠',
552
+ info: 'ℹ'
553
+ };
554
+
555
+ toast.innerHTML = `
556
+ <div class="flex items-center">
557
+ <span class="toast-icon mr-2">${icons[type] || icons.info}</span>
558
+ <span class="toast-message">${message}</span>
559
+ </div>
560
+ `;
561
+
562
+ // Style the toast
563
+ const colors = {
564
+ success: '#10b981',
565
+ error: '#ef4444',
566
+ warning: '#f59e0b',
567
+ info: '#3b82f6'
568
+ };
569
+
570
+ toast.style.backgroundColor = colors[type] || colors.info;
571
 
572
  document.body.appendChild(toast);
573
 
574
+ // Animate in
575
  setTimeout(() => {
576
+ toast.style.transform = 'translateY(0)';
577
+ toast.style.opacity = '1';
578
+ }, 10);
579
+
580
+ // Remove after timeout
581
+ setTimeout(() => {
582
+ toast.style.transform = 'translateY(20px)';
583
+ toast.style.opacity = '0';
584
+ setTimeout(() => {
585
+ toast.remove();
586
+ }, 300);
587
  }, 3000);
588
  }
 
589
  // Simulate real-time data updates
590
  setInterval(() => {
591
  // Update time-based data
592
  updateTime();
593
  updateRealTimeMetrics();
594
+ checkAlerts();
595
+ }, 30000); // Update every 30 seconds for more responsiveness
596
 
597
  function updateTime() {
598
  const now = new Date();
 
604
 
605
  function updateRealTimeMetrics() {
606
  // Update metrics that change in real-time
607
+ // Simulate heart rate changes
608
+ const heartRateElement = document.querySelector('[data-metric="heartRate"]');
609
+ if (heartRateElement) {
610
+ const baseHR = 72;
611
+ const variation = Math.floor(Math.random() * 10) - 5;
612
+ heartRateElement.textContent = baseHR + variation;
613
+ }
614
+
615
+ // Update steps counter
616
+ const stepsElement = document.querySelector('[data-metric="steps"]');
617
+ if (stepsElement) {
618
+ const currentSteps = parseInt(stepsElement.textContent.replace(',', ''));
619
+ const newSteps = currentSteps + Math.floor(Math.random() * 50);
620
+ stepsElement.textContent = newSteps.toLocaleString('th-TH');
621
+ }
622
  }
623
 
624
+ function checkAlerts() {
625
+ // Check for important alerts
626
+ const alerts = [
627
+ {
628
+ condition: () => Math.random() > 0.95,
629
+ message: 'ถึงเวลาลุกขึ้นเดิน! นั่งนิ่งมานานแล้ว',
630
+ type: 'warning'
631
+ },
632
+ {
633
+ condition: () => new Date().getHours() === 12 && new Date().getMinutes() === 0,
634
+ message: 'ถึงเวลาทานยาตามนัด',
635
+ type: 'info'
636
+ }
637
+ ];
638
+
639
+ alerts.forEach(alert => {
640
+ if (alert.condition()) {
641
+ showToast(alert.message, alert.type);
642
+ }
643
+ });
644
+ }
645
+
646
+ // New utility functions for updating UI with mock data
647
+ function loadWeeklyTrends(weeklyData) {
648
+ // Update weekly trend charts
649
+ Object.keys(weeklyData).forEach(day => {
650
+ const element = document.querySelector(`[data-weekly="${day}"]`);
651
+ if (element && weeklyData[day]) {
652
+ element.setAttribute('data-recovery', weeklyData[day].recovery);
653
+ element.setAttribute('data-strain', weeklyData[day].strain);
654
+ }
655
+ });
656
+ }
657
+
658
+ function loadActivities(activities) {
659
+ const activitiesContainer = document.querySelector('.activities-list');
660
+ if (activitiesContainer && activities) {
661
+ activitiesContainer.innerHTML = activities.map(activity => `
662
+ <div class="activity-item flex items-center justify-between p-3 bg-gray-50 rounded-lg mb-2">
663
+ <div class="flex items-center">
664
+ <div class="w-10 h-10 bg-${getActivityColor(activity.type)}-100 rounded-full flex items-center justify-center mr-3">
665
+ <i data-feather="${getActivityIcon(activity.type)}" class="w-5 h-5 text-${getActivityColor(activity.type)}-600"></i>
666
+ </div>
667
+ <div>
668
+ <div class="font-semibold">${activity.name}</div>
669
+ <div class="text-sm text-gray-500">${activity.time}</div>
670
+ </div>
671
+ </div>
672
+ <div class="text-right">
673
+ <div class="font-bold text-${getActivityColor(activity.type)}-600">${activity.strain}</div>
674
+ <div class="text-sm text-gray-500">${activity.calories} kcal</div>
675
+ </div>
676
+ </div>
677
+ `).join('');
678
+ feather.replace();
679
+ }
680
+ }
681
+
682
+ function getActivityColor(type) {
683
+ const colors = {
684
+ running: 'blue',
685
+ yoga: 'green',
686
+ walking: 'purple',
687
+ cycling: 'orange'
688
+ };
689
+ return colors[type] || 'blue';
690
+ }
691
+
692
+ function getActivityIcon(type) {
693
+ const icons = {
694
+ running: 'target',
695
+ yoga: 'heart',
696
+ walking: 'navigation',
697
+ cycling: 'zap'
698
+ };
699
+ return icons[type] || 'activity';
700
+ }
701
+
702
+ function updateHourlyForecast(forecast) {
703
+ const forecastContainer = document.querySelector('.hourly-forecast');
704
+ if (forecastContainer && forecast) {
705
+ forecastContainer.innerHTML = forecast.map(hour => `
706
+ <div class="text-center">
707
+ <div class="text-sm text-gray-500">${hour.time}</div>
708
+ <div class="text-lg font-semibold">${hour.temp}°</div>
709
+ <div class="text-xs text-orange-500">PM2.5: ${hour.pm25}</div>
710
+ </div>
711
+ `).join('');
712
+ }
713
+ }
714
+
715
+ function updateTrafficAlternatives(alternatives) {
716
+ const alternativesContainer = document.querySelector('.traffic-alternatives');
717
+ if (alternativesContainer && alternatives) {
718
+ alternativesContainer.innerHTML = alternatives.map(route => `
719
+ <div class="flex items-center justify-between p-2 bg-gray-50 rounded-lg mb-2">
720
+ <div>
721
+ <div class="font-semibold text-sm">${route.route}</div>
722
+ <div class="text-xs text-gray-500">${route.distance} กม.</div>
723
+ </div>
724
+ <div class="text-right">
725
+ <div class="font-bold text-${route.time < 40 ? 'green' : 'orange'}-600">${route.time} นาที</div>
726
+ </div>
727
+ </div>
728
+ `).join('');
729
+ }
730
+ }
731
+
732
+ function updateWaterIntake(waterData) {
733
+ const waterProgress = document.querySelector('[data-water="progress"]');
734
+ const waterText = document.querySelector('[data-water="text"]');
735
+
736
+ if (waterProgress && waterText && waterData) {
737
+ const percentage = (waterData.consumed / waterData.goal) * 100;
738
+ waterProgress.style.width = `${percentage}%`;
739
+ waterText.textContent = `${waterData.consumed} / ${waterData.goal} ${waterData.unit}`;
740
+ }
741
+ }
742
+
743
+ function updateNutritionScore(score) {
744
+ const scoreElement = document.querySelector('[data-nutrition="score"]');
745
+ if (scoreElement) {
746
+ scoreElement.textContent = score;
747
+ scoreElement.className = `text-2xl font-bold ${score >= 80 ? 'text-green-600' : score >= 60 ? 'text-yellow-600' : 'text-red-600'}`;
748
+ }
749
+ }
750
+
751
+ function updateMentalHealthUI(mentalData) {
752
+ // Update stress level
753
+ const stressElement = document.querySelector('[data-mental="stress"]');
754
+ if (stressElement && mentalData) {
755
+ stressElement.textContent = `${mentalData.stressLevel}%`;
756
+
757
+ // Update stress color
758
+ const stressColor = mentalData.stressLevel <= 30 ? 'green' : mentalData.stressLevel <= 60 ? 'yellow' : 'red';
759
+ stressElement.className = `text-2xl font-bold text-${stressColor}-500`;
760
+ }
761
+
762
+ // Update mood buttons
763
+ const moodButtons = document.querySelectorAll('.mood-button');
764
+ moodButtons.forEach(button => {
765
+ const mood = button.dataset.mood;
766
+ if (mood === mentalData.mood) {
767
+ button.classList.add('ring-2', 'ring-purple-500', 'scale-110');
768
+ }
769
+ });
770
+ }
771
+
772
+ function updateCommunityUI(communityData) {
773
+ // Update teams
774
+ if (communityData && communityData.teams) {
775
+ const teamsContainer = document.querySelector('.teams-list');
776
+ if (teamsContainer) {
777
+ teamsContainer.innerHTML = communityData.teams.map(team => `
778
+ <div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg mb-2">
779
+ <div class="flex items-center">
780
+ <div class="w-10 h-10 bg-indigo-600 rounded-full flex items-center justify-center text-white font-bold mr-3">
781
+ ${team.avatar}
782
+ </div>
783
+ <div>
784
+ <div class="font-semibold">${team.name}</div>
785
+ <div class="text-sm text-gray-500">${team.members} สมาชิก</div>
786
+ </div>
787
+ </div>
788
+ <div class="text-right">
789
+ <div class="font-bold text-indigo-600">${team.points} pts</div>
790
+ <div class="text-sm text-gray-500">อันดับ ${team.rank}</div>
791
+ </div>
792
+ </div>
793
+ `).join('');
794
+ }
795
+ }
796
+
797
+ // Update challenges
798
+ if (communityData && communityData.challenges) {
799
+ const challengesContainer = document.querySelector('.challenges-list');
800
+ if (challengesContainer) {
801
+ challengesContainer.innerHTML = communityData.challenges.map(challenge => `
802
+ <div class="border rounded-lg p-4 mb-3">
803
+ <div class="flex items-center justify-between mb-2">
804
+ <h3 class="font-bold">${challenge.name}</h3>
805
+ <span class="bg-${challenge.status === 'active' ? 'green' : 'gray'}-100 text-${challenge.status === 'active' ? 'green' : 'gray'}-800 px-2 py-1 rounded text-sm">
806
+ ${challenge.status === 'active' ? 'กำลังทำ' : 'สิ้นสุด'}
807
+ </span>
808
+ </div>
809
+ <div class="text-sm text-gray-600 mb-2">
810
+ วันที่ ${challenge.progress}/${challenge.total} • ${challenge.reward}
811
+ </div>
812
+ <div class="w-full bg-gray-200 rounded-full h-2">
813
+ <div class="bg-${(challenge.progress/challenge.total) > 0.5 ? 'green' : 'blue'}-500 h-2 rounded-full transition-all"
814
+ style="width: ${(challenge.progress/challenge.total) * 100}%"></div>
815
+ </div>
816
+ </div>
817
+ `).join('');
818
+ }
819
+ }
820
+ }
821
  // Handle visibility change
822
  document.addEventListener('visibilitychange', function() {
823
  if (document.visibilityState === 'visible') {
style.css CHANGED
@@ -267,13 +267,12 @@ input:checked + .toggle-slider:before {
267
  width: 90%;
268
  animation: slideUp 0.3s ease-out;
269
  }
270
-
271
  /* Toast Notification */
272
  .toast {
273
  position: fixed;
274
  bottom: 100px;
275
  left: 50%;
276
- transform: translateX(-50%);
277
  background: #1f2937;
278
  color: white;
279
  padding: 12px 24px;
@@ -281,8 +280,36 @@ input:checked + .toggle-slider:before {
281
  font-size: 14px;
282
  z-index: 2000;
283
  animation: slideUp 0.3s ease-out;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
  }
285
 
 
 
 
 
 
 
 
 
 
 
 
286
  /* Chart Styles */
287
  .chart-container {
288
  position: relative;
@@ -369,7 +396,6 @@ input:checked + .toggle-slider:before {
369
  transform: scale(1.1);
370
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
371
  }
372
-
373
  /* Skeleton Loader */
374
  .skeleton {
375
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
@@ -384,4 +410,148 @@ input:checked + .toggle-slider:before {
384
  100% {
385
  background-position: -200% 0;
386
  }
387
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
  width: 90%;
268
  animation: slideUp 0.3s ease-out;
269
  }
 
270
  /* Toast Notification */
271
  .toast {
272
  position: fixed;
273
  bottom: 100px;
274
  left: 50%;
275
+ transform: translateX(-50%) translateY(20px);
276
  background: #1f2937;
277
  color: white;
278
  padding: 12px 24px;
 
280
  font-size: 14px;
281
  z-index: 2000;
282
  animation: slideUp 0.3s ease-out;
283
+ opacity: 0;
284
+ transition: all 0.3s ease;
285
+ max-width: 320px;
286
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
287
+ }
288
+
289
+ .toast-icon {
290
+ font-size: 18px;
291
+ font-weight: bold;
292
+ }
293
+
294
+ .toast-message {
295
+ flex: 1;
296
+ }
297
+
298
+ .toast-success {
299
+ background: linear-gradient(135deg, #10b981, #059669);
300
  }
301
 
302
+ .toast-error {
303
+ background: linear-gradient(135deg, #ef4444, #dc2626);
304
+ }
305
+
306
+ .toast-warning {
307
+ background: linear-gradient(135deg, #f59e0b, #d97706);
308
+ }
309
+
310
+ .toast-info {
311
+ background: linear-gradient(135deg, #3b82f6, #2563eb);
312
+ }
313
  /* Chart Styles */
314
  .chart-container {
315
  position: relative;
 
396
  transform: scale(1.1);
397
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
398
  }
 
399
  /* Skeleton Loader */
400
  .skeleton {
401
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
 
410
  100% {
411
  background-position: -200% 0;
412
  }
413
+ }
414
+
415
+ /* Activity Animations */
416
+ .activity-item {
417
+ transition: all 0.3s ease;
418
+ transform: translateX(0);
419
+ }
420
+
421
+ .activity-item:hover {
422
+ transform: translateX(4px);
423
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
424
+ }
425
+
426
+ /* Mood Button Styles */
427
+ .mood-button {
428
+ transition: all 0.3s ease;
429
+ filter: grayscale(0.3);
430
+ opacity: 0.7;
431
+ }
432
+
433
+ .mood-button:hover {
434
+ filter: grayscale(0);
435
+ opacity: 1;
436
+ transform: scale(1.1);
437
+ }
438
+
439
+ .mood-button.ring-2 {
440
+ filter: grayscale(0);
441
+ opacity: 1;
442
+ transform: scale(1.2);
443
+ }
444
+
445
+ /* Live Updates */
446
+ .live-indicator {
447
+ display: inline-block;
448
+ width: 8px;
449
+ height: 8px;
450
+ background: #10b981;
451
+ border-radius: 50%;
452
+ margin-right: 8px;
453
+ animation: pulse 2s infinite;
454
+ }
455
+
456
+ /* Data Cards */
457
+ .data-card {
458
+ position: relative;
459
+ overflow: hidden;
460
+ }
461
+
462
+ .data-card::before {
463
+ content: '';
464
+ position: absolute;
465
+ top: 0;
466
+ left: -100%;
467
+ width: 100%;
468
+ height: 100%;
469
+ background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
470
+ transition: left 0.5s ease;
471
+ }
472
+
473
+ .data-card:hover::before {
474
+ left: 100%;
475
+ }
476
+
477
+ /* Progress Ring Styles */
478
+ .progress-ring {
479
+ transform: rotate(-90deg);
480
+ }
481
+
482
+ .progress-ring-circle {
483
+ transition: stroke-dashoffset 0.5s ease;
484
+ }
485
+
486
+ /* Responsive Breakpoints */
487
+ @media (max-width: 480px) {
488
+ .toast {
489
+ max-width: 280px;
490
+ font-size: 12px;
491
+ padding: 10px 20px;
492
+ }
493
+ }
494
+
495
+ /* Dark Mode Support (Future Feature) */
496
+ @media (prefers-color-scheme: dark) {
497
+ .modal-content {
498
+ background: #1f2937;
499
+ color: white;
500
+ }
501
+
502
+ .card-shadow {
503
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
504
+ }
505
+ }
506
+
507
+ /* Enhanced Button Styles */
508
+ .btn {
509
+ position: relative;
510
+ overflow: hidden;
511
+ }
512
+
513
+ .btn::after {
514
+ content: '';
515
+ position: absolute;
516
+ top: 50%;
517
+ left: 50%;
518
+ width: 0;
519
+ height: 0;
520
+ border-radius: 50%;
521
+ background: rgba(255, 255, 255, 0.3);
522
+ transform: translate(-50%, -50%);
523
+ transition: width 0.6s, height 0.6s;
524
+ }
525
+
526
+ .btn:active::after {
527
+ width: 300px;
528
+ height: 300px;
529
+ }
530
+
531
+ /* Chart Animation */
532
+ .chart-bar {
533
+ animation: growBar 0.5s ease-out forwards;
534
+ }
535
+
536
+ @keyframes growBar {
537
+ from {
538
+ height: 0;
539
+ }
540
+ }
541
+
542
+ /* Notification Badge */
543
+ .notification-badge {
544
+ animation: bounce 2s infinite;
545
+ }
546
+
547
+ @keyframes bounce {
548
+ 0%, 20%, 50%, 80%, 100% {
549
+ transform: translateY(0);
550
+ }
551
+ 40% {
552
+ transform: translateY(-4px);
553
+ }
554
+ 60% {
555
+ transform: translateY(-2px);
556
+ }
557
+ }