CSNET commited on
Commit
61444f5
·
verified ·
1 Parent(s): 19cfe26

ดีมาก ทีนี้ช่วยออกแบบ Tab สำหรับการฝึกทำ IF ด้วย Whoop ให้ที ขอแบบใช้งานได้และต้องเป็นภาษาไทยนะ

Browse files
Files changed (1) hide show
  1. index.html +377 -3
index.html CHANGED
@@ -133,10 +133,13 @@
133
  <button onclick="switchTab('insights')" class="tab-btn px-4 py-2 text-sm font-medium text-gray-600 transition-all" data-tab="insights">
134
  ข้อมูลเชิงลึก
135
  </button>
 
 
 
136
  <button onclick="switchTab('goals')" class="tab-btn px-4 py-2 text-sm font-medium text-gray-600 transition-all" data-tab="goals">
137
  เป้าหมาย
138
  </button>
139
- </div>
140
  </div>
141
 
142
  <!-- Content Area -->
@@ -589,8 +592,239 @@
589
  </div>
590
  </div>
591
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
592
  <!-- Goals Tab -->
593
- <div id="goals" class="tab-content hidden p-4">
594
  <!-- Active Goals -->
595
  <div class="mb-4">
596
  <h3 class="font-semibold mb-3">เป้าหมายประจำเดือน</h3>
@@ -1079,9 +1313,149 @@
1079
  selectedBehaviors = selectedBehaviors.filter(b => b !== behavior);
1080
  updateJournalDisplay();
1081
  }
1082
-
1083
  // Initialize journal display
1084
  updateJournalDisplay();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1085
  </script>
1086
  <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
1087
  </body>
 
133
  <button onclick="switchTab('insights')" class="tab-btn px-4 py-2 text-sm font-medium text-gray-600 transition-all" data-tab="insights">
134
  ข้อมูลเชิงลึก
135
  </button>
136
+ <button onclick="switchTab('if-training')" class="tab-btn px-4 py-2 text-sm font-medium text-gray-600 transition-all" data-tab="if-training">
137
+ ฝึก IF
138
+ </button>
139
  <button onclick="switchTab('goals')" class="tab-btn px-4 py-2 text-sm font-medium text-gray-600 transition-all" data-tab="goals">
140
  เป้าหมาย
141
  </button>
142
+ </div>
143
  </div>
144
 
145
  <!-- Content Area -->
 
592
  </div>
593
  </div>
594
  </div>
595
+
596
+ <!-- IF Training Tab -->
597
+ <div id="if-training" class="tab-content hidden p-4">
598
+ <!-- IF Status Card -->
599
+ <div class="bg-gradient-to-br from-orange-500 to-red-500 rounded-xl p-4 text-white mb-4">
600
+ <div class="flex justify-between items-start mb-3">
601
+ <div>
602
+ <h3 class="font-semibold text-lg">Intermittent Fasting</h3>
603
+ <p class="text-sm opacity-90">วันที่ 15 ของเดือนนี้</p>
604
+ </div>
605
+ <div class="bg-white/20 backdrop-blur rounded-full px-3 py-1">
606
+ <span class="text-sm font-medium">16:8</span>
607
+ </div>
608
+ </div>
609
+
610
+ <!-- Current Fast Timer -->
611
+ <div class="bg-white/10 backdrop-blur rounded-lg p-3 mb-3">
612
+ <div class="flex justify-between items-center mb-2">
613
+ <span class="text-sm">ระยะเวลาที่ทำไปแล้ว</span>
614
+ <span class="text-xs bg-green-400 text-green-900 px-2 py-1 rounded-full">กำลังทำอยู่</span>
615
+ </div>
616
+ <div class="text-3xl font-bold mb-1">14:32:45</div>
617
+ <div class="w-full bg-white/20 rounded-full h-2">
618
+ <div class="bg-white h-2 rounded-full transition-all duration-1000" style="width: 91%"></div>
619
+ </div>
620
+ <div class="flex justify-between text-xs mt-2 opacity-90">
621
+ <span>เริ่ม 20:00</span>
622
+ <span>สิ้นสุด 12:00</span>
623
+ </div>
624
+ </div>
625
+
626
+ <!-- Quick Stats -->
627
+ <div class="grid grid-cols-3 gap-3 text-center">
628
+ <div>
629
+ <p class="text-xl font-bold">15</p>
630
+ <p class="text-xs opacity-90">วันทำต่อเนื่อง</p>
631
+ </div>
632
+ <div>
633
+ <p class="text-xl font-bold">68</p>
634
+ <p class="text-xs opacity-90">ชั่วโมงรวม</p>
635
+ </div>
636
+ <div>
637
+ <p class="text-xl font-bold">2.1</p>
638
+ <p class="text-xs opacity-90">กก. ลดน้ำหนัก</p>
639
+ </div>
640
+ </div>
641
+ </div>
642
+
643
+ <!-- IF Plans -->
644
+ <div class="mb-4">
645
+ <h3 class="font-semibold mb-3 flex items-center">
646
+ <i data-feather="clock" class="w-4 h-4 mr-2 text-purple-600"></i>
647
+ แผนการทำ IF
648
+ </h3>
649
+ <div class="grid grid-cols-2 gap-3">
650
+ <button onclick="selectIFPlan('16:8')" class="bg-white rounded-xl p-3 card-shadow border-2 border-purple-500">
651
+ <div class="text-center">
652
+ <p class="font-bold text-purple-600">16:8</p>
653
+ <p class="text-xs text-gray-600 mt-1">16 ชม. อด 8 ชม. กิน</p>
654
+ <p class="text-xs text-green-600 mt-2">✓ กำลังใช้งาน</p>
655
+ </div>
656
+ </button>
657
+
658
+ <button onclick="selectIFPlan('18:6')" class="bg-white rounded-xl p-3 card-shadow">
659
+ <div class="text-center">
660
+ <p class="font-bold">18:6</p>
661
+ <p class="text-xs text-gray-600 mt-1">18 ชม. อด 6 ชม. กิน</p>
662
+ <p class="text-xs text-gray-500 mt-2">ขั้นสูง</p>
663
+ </div>
664
+ </button>
665
+
666
+ <button onclick="selectIFPlan('20:4')" class="bg-white rounded-xl p-3 card-shadow">
667
+ <div class="text-center">
668
+ <p class="font-bold">20:4</p>
669
+ <p class="text-xs text-gray-600 mt-1">20 ชม. อด 4 ชม. กิน</p>
670
+ <p class="text-xs text-gray-500 mt-2">ผู้เชี่ยวชาญ</p>
671
+ </div>
672
+ </button>
673
+
674
+ <button onclick="selectIFPlan('OMAD')" class="bg-white rounded-xl p-3 card-shadow">
675
+ <div class="text-center">
676
+ <p class="font-bold">OMAD</p>
677
+ <p class="text-xs text-gray-600 mt-1">มื้อเดียวต่อวัน</p>
678
+ <p class="text-xs text-gray-500 mt-2">สุดขั้ว</p>
679
+ </div>
680
+ </button>
681
+ </div>
682
+ </div>
683
+
684
+ <!-- Weekly Schedule -->
685
+ <div class="bg-white rounded-xl p-4 card-shadow mb-4">
686
+ <h3 class="font-semibold mb-3 flex items-center">
687
+ <i data-feather="calendar" class="w-4 h-4 mr-2 text-purple-600"></i>
688
+ ตารางทำ IF รายสัปดาห์
689
+ </h3>
690
+ <div class="space-y-2">
691
+ <div class="flex items-center justify-between p-2 bg-green-50 rounded-lg">
692
+ <div class="flex items-center">
693
+ <div class="w-8 h-8 bg-green-500 rounded-full flex items-center justify-center text-white text-xs font-bold">จ</div>
694
+ <span class="ml-3 text-sm font-medium">จันทร์</span>
695
+ </div>
696
+ <div class="text-right">
697
+ <p class="text-sm font-semibold">สำเร็จ</p>
698
+ <p class="text-xs text-gray-600">16:08 ชม.</p>
699
+ </div>
700
+ </div>
701
+
702
+ <div class="flex items-center justify-between p-2 bg-green-50 rounded-lg">
703
+ <div class="flex items-center">
704
+ <div class="w-8 h-8 bg-green-500 rounded-full flex items-center justify-center text-white text-xs font-bold">อ</div>
705
+ <span class="ml-3 text-sm font-medium">อังคาร</span>
706
+ </div>
707
+ <div class="text-right">
708
+ <p class="text-sm font-semibold">สำเร็จ</p>
709
+ <p class="text-xs text-gray-600">16:12 ชม.</p>
710
+ </div>
711
+ </div>
712
+
713
+ <div class="flex items-center justify-between p-2 bg-green-50 rounded-lg">
714
+ <div class="flex items-center">
715
+ <div class="w-8 h-8 bg-green-500 rounded-full flex items-center justify-center text-white text-xs font-bold">พ</div>
716
+ <span class="ml-3 text-sm font-medium">พุธ</span>
717
+ </div>
718
+ <div class="text-right">
719
+ <p class="text-sm font-semibold">สำเร็จ</p>
720
+ <p class="text-xs text-gray-600">16:05 ชม.</p>
721
+ </div>
722
+ </div>
723
+
724
+ <div class="flex items-center justify-between p-2 bg-orange-50 rounded-lg">
725
+ <div class="flex items-center">
726
+ <div class="w-8 h-8 bg-orange-500 rounded-full flex items-center justify-center text-white text-xs font-bold">พฤ</div>
727
+ <span class="ml-3 text-sm font-medium">พฤหัส</span>
728
+ </div>
729
+ <div class="text-right">
730
+ <p class="text-sm font-semibold text-orange-600">กำลังทำ</p>
731
+ <p class="text-xs text-gray-600">14:32 ชม.</p>
732
+ </div>
733
+ </div>
734
+
735
+ <div class="flex items-center justify-between p-2 bg-gray-50 rounded-lg">
736
+ <div class="flex items-center">
737
+ <div class="w-8 h-8 bg-gray-300 rounded-full flex items-center justify-center text-white text-xs font-bold">ศ</div>
738
+ <span class="ml-3 text-sm font-medium">ศุกร์</span>
739
+ </div>
740
+ <div class="text-right">
741
+ <p class="text-sm font-semibold">รอดำเนินการ</p>
742
+ <p class="text-xs text-gray-600">20:00 - 12:00</p>
743
+ </div>
744
+ </div>
745
+
746
+ <div class="flex items-center justify-between p-2 bg-gray-50 rounded-lg">
747
+ <div class="flex items-center">
748
+ <div class="w-8 h-8 bg-gray-300 rounded-full flex items-center justify-center text-white text-xs font-bold">ส</div>
749
+ <span class="ml-3 text-sm font-medium">เสาร์</span>
750
+ </div>
751
+ <div class="text-right">
752
+ <p class="text-sm font-semibold">วันหยุดพัก</p>
753
+ <p class="text-xs text-gray-600">กินตามปกติ</p>
754
+ </div>
755
+ </div>
756
+
757
+ <div class="flex items-center justify-between p-2 bg-gray-50 rounded-lg">
758
+ <div class="flex items-center">
759
+ <div class="w-8 h-8 bg-gray-300 rounded-full flex items-center justify-center text-white text-xs font-bold">อา</div>
760
+ <span class="ml-3 text-sm font-medium">อาทิตย์</span>
761
+ </div>
762
+ <div class="text-right">
763
+ <p class="text-sm font-semibold">วันหยุดพัก</p>
764
+ <p class="text-xs text-gray-600">กินตามปกติ</p>
765
+ </div>
766
+ </div>
767
+ </div>
768
+ </div>
769
+
770
+ <!-- IF Tips -->
771
+ <div class="bg-white rounded-xl p-4 card-shadow mb-4">
772
+ <h3 class="font-semibold mb-3 flex items-center">
773
+ <i data-feather="info" class="w-4 h-4 mr-2 text-purple-600"></i>
774
+ เคล็ดลับการทำ IF
775
+ </h3>
776
+ <div class="space-y-3">
777
+ <div class="flex items-start space-x-3">
778
+ <div class="w-6 h-6 bg-blue-100 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
779
+ <i data-feather="droplet" class="w-3 h-3 text-blue-600"></i>
780
+ </div>
781
+ <div>
782
+ <p class="font-medium text-sm">ดื่มน้ำมากๆ</p>
783
+ <p class="text-xs text-gray-600">ช่วยลดความหิวและรักษาสมดุลร่างกาย</p>
784
+ </div>
785
+ </div>
786
+
787
+ <div class="flex items-start space-x-3">
788
+ <div class="w-6 h-6 bg-green-100 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
789
+ <i data-feather="coffee" class="w-3 h-3 text-green-600"></i>
790
+ </div>
791
+ <div>
792
+ <p class="font-medium text-sm">ดื่มกาแฟ/ชาได้</p>
793
+ <p class="text-xs text-gray-600">ไม่ใส่นมและน้ำตาล ช่วยไม่ให้หิวง่าย</p>
794
+ </div>
795
+ </div>
796
+
797
+ <div class="flex items-start space-x-3">
798
+ <div class="w-6 h-6 bg-purple-100 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
799
+ <i data-feather="moon" class="w-3 h-3 text-purple-600"></i>
800
+ </div>
801
+ <div>
802
+ <p class="font-medium text-sm">นอนหลับให้เพียงพอ</p>
803
+ <p class="text-xs text-gray-600">ช่วยควบคุมฮอร์โมนความหิว</p>
804
+ </div>
805
+ </div>
806
+
807
+ <div class="flex items-start space-x-3">
808
+ <div class="w-6 h-6 bg-orange-100 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
809
+ <i data-feather="activity" class="w-3 h-3 text-orange-600"></i>
810
+ </div>
811
+ <div>
812
+ <p class="font-medium text-sm">ออกกำลังกายเบาๆ</p>
813
+ <p class="text-xs text-gray-600">การเดินหรือยิมเบาๆ ช่วยเผาผลาญได้ดี</p>
814
+ </div>
815
+ </div>
816
+ </div>
817
+ </div>
818
+
819
+ <!-- Start/End Fast Button -->
820
+ <button onclick="toggleFast()" id="fastToggleBtn" class="w-full bg-red-500 text-white rounded-xl p-4 font-semibold hover:bg-red-600 transition-colors">
821
+ <i data-feather="square" class="w-5 h-5 inline mr-2"></i>
822
+ หยุดการทำ IF วันนี้
823
+ </button>
824
+ </div>
825
+
826
  <!-- Goals Tab -->
827
+ <div id="goals" class="tab-content hidden p-4">
828
  <!-- Active Goals -->
829
  <div class="mb-4">
830
  <h3 class="font-semibold mb-3">เป้าหมายประจำเดือน</h3>
 
1313
  selectedBehaviors = selectedBehaviors.filter(b => b !== behavior);
1314
  updateJournalDisplay();
1315
  }
 
1316
  // Initialize journal display
1317
  updateJournalDisplay();
1318
+ }
1319
+
1320
+ // IF Training Functions
1321
+ let currentIFPlan = '16:8';
1322
+ let fastStartTime = null;
1323
+ let fastInterval = null;
1324
+ let isCurrentlyFasting = true;
1325
+
1326
+ function selectIFPlan(plan) {
1327
+ currentIFPlan = plan;
1328
+
1329
+ // Update UI to show selected plan
1330
+ document.querySelectorAll('#if-training .grid button').forEach(btn => {
1331
+ btn.classList.remove('border-2', 'border-purple-500');
1332
+ });
1333
+
1334
+ event.target.closest('button').classList.add('border-2', 'border-purple-500');
1335
+
1336
+ // Show confirmation
1337
+ showNotification(`เปลี่ยนแผนเป็น ${plan} แล้ว ✅`);
1338
+ }
1339
+
1340
+ function toggleFast() {
1341
+ const btn = document.getElementById('fastToggleBtn');
1342
+
1343
+ if (isCurrentlyFasting) {
1344
+ // End fast
1345
+ isCurrentlyFasting = false;
1346
+ clearInterval(fastInterval);
1347
+ btn.innerHTML = '<i data-feather="play" class="w-5 h-5 inline mr-2"></i>เริ่มทำ IF ใหม่';
1348
+ btn.classList.remove('bg-red-500', 'hover:bg-red-600');
1349
+ btn.classList.add('bg-green-500', 'hover:bg-green-600');
1350
+
1351
+ // Update status
1352
+ document.querySelector('#if-training .bg-white\\/10 .bg-green-400').textContent = 'สิ้นสุดแล้ว';
1353
+ document.querySelector('#if-training .bg-white\\/10 .bg-green-400').classList.remove('bg-green-400', 'text-green-900');
1354
+ document.querySelector('#if-training .bg-white\\/10 .bg-green-400').classList.add('bg-gray-400', 'text-gray-900');
1355
+
1356
+ showNotification('สิ้นสุดการทำ IF วันนี้แล้ว! 🎉');
1357
+ } else {
1358
+ // Start fast
1359
+ isCurrentlyFasting = true;
1360
+ startFastTimer();
1361
+ btn.innerHTML = '<i data-feather="square" class="w-5 h-5 inline mr-2"></i>หยุดการทำ IF วันนี้';
1362
+ btn.classList.remove('bg-green-500', 'hover:bg-green-600');
1363
+ btn.classList.add('bg-red-500', 'hover:bg-red-600');
1364
+
1365
+ showNotification('เริ่มทำ IF แล้ว! 💪');
1366
+ }
1367
+
1368
+ feather.replace();
1369
+ }
1370
+
1371
+ function startFastTimer() {
1372
+ fastStartTime = new Date();
1373
+
1374
+ fastInterval = setInterval(() => {
1375
+ if (!isCurrentlyFasting) return;
1376
+
1377
+ const now = new Date();
1378
+ const elapsed = now - fastStartTime;
1379
+
1380
+ // Calculate target time (16 hours from start for 16:8)
1381
+ const targetHours = 16;
1382
+ const targetMs = targetHours * 60 * 60 * 1000;
1383
+
1384
+ const hours = Math.floor(elapsed / (1000 * 60 * 60));
1385
+ const minutes = Math.floor((elapsed % (1000 * 60 * 60)) / (1000 * 60));
1386
+ const seconds = Math.floor((elapsed % (1000 * 60)) / 1000);
1387
+
1388
+ const timeString = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
1389
+
1390
+ // Update timer display
1391
+ const timerElement = document.querySelector('#if-training .text-3xl');
1392
+ if (timerElement) {
1393
+ timerElement.textContent = timeString;
1394
+ }
1395
+
1396
+ // Update progress bar
1397
+ const progress = Math.min((elapsed / targetMs) * 100, 100);
1398
+ const progressBar = document.querySelector('#if-training .bg-white\\/10 .bg-white');
1399
+ if (progressBar) {
1400
+ progressBar.style.width = `${progress}%`;
1401
+ }
1402
+
1403
+ // Update status
1404
+ const statusElement = document.querySelector('#if-training .bg-white\\/10 span');
1405
+ if (statusElement && progress < 100) {
1406
+ statusElement.textContent = 'กำลังทำอยู่';
1407
+ statusElement.classList.remove('bg-gray-400', 'text-gray-900', 'bg-green-400', 'text-green-900');
1408
+ statusElement.classList.add('bg-green-400', 'text-green-900');
1409
+ } else if (statusElement && progress >= 100) {
1410
+ statusElement.textContent = 'เกินเป้าแล้ว!';
1411
+ statusElement.classList.remove('bg-green-400', 'text-green-900');
1412
+ statusElement.classList.add('bg-yellow-400', 'text-yellow-900');
1413
+
1414
+ // Show completion notification
1415
+ if (!window.completionShown) {
1416
+ showNotification('🎊 ทำ IF ครบ 16 ชั่วโมงแล้ว! สามารถเริ่มทานอาหารได้');
1417
+ window.completionShown = true;
1418
+ }
1419
+ }
1420
+ }, 1000);
1421
+ }
1422
+
1423
+ function showNotification(message) {
1424
+ // Create a simple toast notification
1425
+ const toast = document.createElement('div');
1426
+ toast.className = 'fixed top-4 right-4 bg-purple-600 text-white px-4 py-3 rounded-lg shadow-lg z-50 max-w-xs';
1427
+ toast.innerHTML = `
1428
+ <div class="flex items-center">
1429
+ <i data-feather="check-circle" class="w-5 h-5 mr-2"></i>
1430
+ <span class="text-sm">${message}</span>
1431
+ </div>
1432
+ `;
1433
+
1434
+ document.body.appendChild(toast);
1435
+ feather.replace();
1436
+
1437
+ // Auto remove after 3 seconds
1438
+ setTimeout(() => {
1439
+ toast.style.transition = 'opacity 0.3s';
1440
+ toast.style.opacity = '0';
1441
+ setTimeout(() => toast.remove(), 300);
1442
+ }, 3000);
1443
+ }
1444
+
1445
+ // Initialize IF timer on page load
1446
+ document.addEventListener('DOMContentLoaded', () => {
1447
+ if (isCurrentlyFasting) {
1448
+ // Simulate that fast started at 20:00
1449
+ const now = new Date();
1450
+ fastStartTime = new Date();
1451
+ fastStartTime.setHours(20, 0, 0, 0);
1452
+
1453
+ // If it's after 20:00, start the timer
1454
+ if (now.getHours() >= 20 || now.getHours() < 12) {
1455
+ startFastTimer();
1456
+ }
1457
+ }
1458
+ });
1459
  </script>
1460
  <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
1461
  </body>