CSNET commited on
Commit
3363380
·
verified ·
1 Parent(s): 9fa900d

เขียนต่อให้จบ

Browse files
Files changed (2) hide show
  1. index.html +454 -3
  2. style.css +246 -19
index.html CHANGED
@@ -566,7 +566,458 @@
566
  {"metric_id": "testosterone_total", "name_en": "Total Testosterone", "name_th": "เทสโทสเตอโรนรวม", "description": "เทสโทสเตอโรน", "ai_notes": "ฮอร์โมนชาย", "type": "number", "unit": "ng/dL", "granularity": "event", "nullable": true, "category": "blood_hormone", "health_risks_targeted": ["ฮอร์โมน"], "expected_benefits": ["สุขภาพชาย"], "habit_concern": ["B073"], "marketplace_hooks": ["testosterone_support"]},
567
  {"metric_id": "estradiol_e2", "name_en": "Estradiol", "name_th": "อีสตราดิออล", "description": "ฮอร์โมนหญิง", "ai_notes": "ฮอร์โมนหญิง", "type": "number", "unit": "pg/mL", "granularity": "event", "nullable": true, "category": "blood_hormone", "health_risks_targeted": ["ฮอร์โมน"], "expected_benefits": ["สุขภาพหญิง"], "habit_concern": ["B074"], "marketplace_hooks": ["hormone_balance"]},
568
  {"metric_id": "progesterone", "name_en": "Progesterone", "name_th": "โปรเจสเตอโรน", "description": "ฮอร์โมน", "ai_notes": "ฮอร์โมนหญิง", "type": "number", "unit": "ng/mL", "granularity": "event", "nullable": true, "category": "blood_hormone", "health_risks_targeted": ["ฮอร์โมน"], "expected_benefits": ["สุขภาพหญิง"], "habit_concern": ["B075"], "marketplace_hooks": ["progesterone_support"]},
569
- {"metric_id": "dhea_s", "name_en": "DHEA-S", "name_th": "DHEA-S", "description": "DHEA-S", "ai
570
- <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
571
  </body>
572
- </html>
 
566
  {"metric_id": "testosterone_total", "name_en": "Total Testosterone", "name_th": "เทสโทสเตอโรนรวม", "description": "เทสโทสเตอโรน", "ai_notes": "ฮอร์โมนชาย", "type": "number", "unit": "ng/dL", "granularity": "event", "nullable": true, "category": "blood_hormone", "health_risks_targeted": ["ฮอร์โมน"], "expected_benefits": ["สุขภาพชาย"], "habit_concern": ["B073"], "marketplace_hooks": ["testosterone_support"]},
567
  {"metric_id": "estradiol_e2", "name_en": "Estradiol", "name_th": "อีสตราดิออล", "description": "ฮอร์โมนหญิง", "ai_notes": "ฮอร์โมนหญิง", "type": "number", "unit": "pg/mL", "granularity": "event", "nullable": true, "category": "blood_hormone", "health_risks_targeted": ["ฮอร์โมน"], "expected_benefits": ["สุขภาพหญิง"], "habit_concern": ["B074"], "marketplace_hooks": ["hormone_balance"]},
568
  {"metric_id": "progesterone", "name_en": "Progesterone", "name_th": "โปรเจสเตอโรน", "description": "ฮอร์โมน", "ai_notes": "ฮอร์โมนหญิง", "type": "number", "unit": "ng/mL", "granularity": "event", "nullable": true, "category": "blood_hormone", "health_risks_targeted": ["ฮอร์โมน"], "expected_benefits": ["สุขภาพหญิง"], "habit_concern": ["B075"], "marketplace_hooks": ["progesterone_support"]},
569
+ {"metric_id": "dhea_s", "name_en": "DHEA-S", "name_th": "DHEA-S", "description": "DHEA-S", "ai_notes": "ฮอร์โมนต้านชรา", "type": "number", "unit": "µg/dL", "granularity": "event", "nullable": true, "category": "blood_hormone", "health_risks_targeted": ["ฮอร์โมน"], "expected_benefits": ["ต้านชรา"], "habit_concern": ["B076"], "marketplace_hooks": ["anti_aging"]}
570
+ ]
571
+ },
572
+ {
573
+ "source_id": "nutrition",
574
+ "name_en": "Nutrition",
575
+ "name_th": "โภชนาการ",
576
+ "description": "การบริโภคอาหารและสารอาหาร",
577
+ "primary_metrics": [
578
+ {"metric_id": "date", "name_en": "Date", "name_th": "วันที่", "description": "วันที่บันทึก", "ai_notes": "วันที่รับประทาน", "type": "date", "unit": "", "granularity": "daily", "nullable": false, "category": "nutrition_meta", "health_risks_targeted": [], "expected_benefits": ["การติดตาม"], "habit_concern": [], "marketplace_hooks": []},
579
+ {"metric_id": "calories_consumed", "name_en": "Calories Consumed", "name_th": "แคลอรี่ที่รับประทาน", "description": "แคลอรี่ทั้งหมด", "ai_notes": "พลังงานรับเข้า", "type": "number", "unit": "kcal", "granularity": "daily", "nullable": true, "category": "nutrition_energy", "health_risks_targeted": ["น้ำหนัก"], "expected_benefits": ["จัดการน้ำหนัก"], "habit_concern": ["N001"], "marketplace_hooks": ["calorie_tracker"]},
580
+ {"metric_id": "protein_g", "name_en": "Protein (g)", "name_th": "โปรตีน (กรัม)", "description": "โปรตีนที่รับประทาน", "ai_notes": "สร้างกล้ามเนื้อ", "type": "number", "unit": "g", "granularity": "daily", "nullable": true, "category": "nutrition_macro", "health_risks_targeted": ["กล้ามเนื้อ"], "expected_benefits": ["สร้างกล้ามเนื้อ"], "habit_concern": ["N002"], "marketplace_hooks": ["protein_powder"]},
581
+ {"metric_id": "carbs_g", "name_en": "Carbohydrates (g)", "name_th": "คาร์โบไฮเดรต (กรัม)", "description": "คาร์โบไฮเดรต", "ai_notes": "พลังงานหลัก", "type": "number", "unit": "g", "granularity": "daily", "nullable": true, "category": "nutrition_macro", "health_risks_targeted": ["พลังงาน"], "expected_benefits": ["พลังงาน"], "habit_concern": ["N003"], "marketplace_hooks": ["carb_management"]},
582
+ {"metric_id": "fat_g", "name_en": "Fat (g)", "name_th": "ไขมัน (กรัม)", "description": "ไขมันที่รับประทาน", "ai_notes": "ไขมัน", "type": "number", "unit": "g", "granularity": "daily", "nullable": true, "category": "nutrition_macro", "health_risks_targeted": ["ไขมัน"], "expected_benefits": ["สุขภาพ"], "habit_concern": ["N004"], "marketplace_hooks": ["healthy_fats"]},
583
+ {"metric_id": "fiber_g", "name_en": "Fiber (g)", "name_th": "ไฟเบอร์ (กรัม)", "description": "ใยอาหาร", "ai_notes": "ระบบย่อยอาหาร", "type": "number", "unit": "g", "granularity": "daily", "nullable": true, "category": "nutrition_fiber", "health_risks_targeted": ["ระบบย่อย"], "expected_benefits": ["ระบบย่อยดี"], "habit_concern": ["N005"], "marketplace_hooks": ["fiber_supplements"]},
584
+ {"metric_id": "sugar_g", "name_en": "Sugar (g)", "name_th": "น้ำตาล (กรัม)", "description": "น้ำตาลที่รับประทาน", "ai_notes": "น้ำตาล", "type": "number", "unit": "g", "granularity": "daily", "nullable": true, "category": "nutrition_sugar", "health_risks_targeted": ["น้ำตาล"], "expected_benefits": ["ลดน้ำตาล"], "habit_concern": ["N006"], "marketplace_hooks": ["sugar_alternatives"]},
585
+ {"metric_id": "water_ml", "name_en": "Water (ml)", "name_th": "น้ำ (มิลลิลิตร)", "description": "ปริมาณน้ำที่ดื่ม", "ai_notes": "ความชุ่มชื้น", "type": "number", "unit": "ml", "granularity": "daily", "nullable": true, "category": "nutrition_hydration", "health_risks_targeted": ["ขาดน้ำ"], "expected_benefits": ["ความชุ่มชื้น"], "habit_concern": ["N007"], "marketplace_hooks": ["water_tracker"]},
586
+ {"metric_id": "caffeine_mg", "name_en": "Caffeine (mg)", "name_th": "คาเฟอีน (มิลลิกรัม)", "description": "คาเฟอีนที่รับประทาน", "ai_notes": "สารกระตุ้น", "type": "number", "unit": "mg", "granularity": "daily", "nullable": true, "category": "nutrition_stimulant", "health_risks_targeted": ["การนอน"], "expected_benefits": ["พลังงาน"], "habit_concern": ["N008"], "marketplace_hooks": ["caffeine_management"]}
587
+ ]
588
+ },
589
+ {
590
+ "source_id": "manual",
591
+ "name_en": "Manual Input",
592
+ "name_th": "บันทึกด้วยตนเอง",
593
+ "description": "ข้อมูลที่บันทึกด้วยตนเอง",
594
+ "primary_metrics": [
595
+ {"metric_id": "date", "name_en": "Date", "name_th": "วันที่", "description": "วันที่บันทึก", "ai_notes": "วันที่รับ", "type": "date", "unit": "", "granularity": "daily", "nullable": false, "category": "manual_meta", "health_risks_targeted": [], "expected_benefits": ["การติดตาม"], "habit_concern": [], "marketplace_hooks": []},
596
+ {"metric_id": "mood_score", "name_en": "Mood Score", "name_th": "คะแนนอารมณ์", "description": "อารมณ์โดยรวม", "ai_notes": "สุขภาพจิต", "type": "number", "unit": "1-10", "granularity": "daily", "nullable": true, "category": "manual_mood", "health_risks_targeted": ["สุขภาพจิต"], "expected_benefits": ["สุขภาพจิตดี"], "habit_concern": ["M001"], "marketplace_hooks": ["mood_tracker"]},
597
+ {"metric_id": "energy_level", "name_en": "Energy Level", "name_th": "ระดับพลังงาน", "description": "พลังงานโดยรวม", "ai_notes": "พลังงาน", "type": "number", "unit": "1-10", "granularity": "daily", "nullable": true, "category": "manual_energy", "health_risks_targeted": ["ความเหนื่อย"], "expected_benefits": ["พลังงานดี"], "habit_concern": ["M002"], "marketplace_hooks": ["energy_management"]},
598
+ {"metric_id": "stress_level", "name_en": "Stress Level", "name_th": "ระดับความเครียด", "description": "ความเครียดโดยรวม", "ai_notes": "ความเครียด", "type": "number", "unit": "1-10", "granularity": "daily", "nullable": true, "category": "manual_stress", "health_risks_targeted": ["ความเครียด"], "expected_benefits": ["ลดความเครียด"], "habit_concern": ["M003"], "marketplace_hooks": ["stress_relief"]},
599
+ {"metric_id": "headache", "name_en": "Headache", "name_th": "ปวดหัว", "description": "ปวดหัว (0/1)", "ai_notes": "ปวดหัว", "type": "boolean", "unit": "", "granularity": "daily", "nullable": true, "category": "manual_symptoms", "health_risks_targeted": ["ปวดหัว"], "expected_benefits": ["ติดตามอาการ"], "habit_concern": ["M004"], "marketplace_hooks": ["headache_relief"]},
600
+ {"metric_id": "medication_taken", "name_en": "Medication Taken", "name_th": "ทานยา", "description": "ทานยาตามกำหนด", "ai_notes": "การทานยา", "type": "boolean", "unit": "", "granularity": "daily", "nullable": true, "category": "manual_medication", "health_risks_targeted": ["การรักษา"], "expected_benefits": ["การรักษาต่อเนื่อง"], "habit_concern": ["M005"], "marketplace_hooks": ["medication_reminder"]},
601
+ {"metric_id": "symptoms_notes", "name_en": "Symptoms Notes", "name_th": "บันทึกอาการ", "description": "บันทึกอาการอื่นๆ", "ai_notes": "อาการเฉพาะ", "type": "text", "unit": "", "granularity": "daily", "nullable": true, "category": "manual_notes", "health_risks_targeted": ["อาการต่างๆ"], "expected_benefits": ["บันทึกอาการ"], "habit_concern": ["M006"], "marketplace_hooks": ["symptom_tracker"]}
602
+ ]
603
+ },
604
+ {
605
+ "source_id": "system",
606
+ "name_en": "System Calculated",
607
+ "name_th": "คำนวณโดยระบบ",
608
+ "description": "เมตริกที่คำนวณโดยระบบ AI",
609
+ "primary_metrics": [
610
+ {"metric_id": "date", "name_en": "Date", "name_th": "วันที่", "description": "วันที่คำนวณ", "ai_notes": "วันที่วิเคราะห์", "type": "date", "unit": "", "granularity": "daily", "nullable": false, "category": "system_meta", "health_risks_targeted": [], "expected_benefits": ["การวิเคราะห์"], "habit_concern": [], "marketplace_hooks": []},
611
+ {"metric_id": "health_score", "name_en": "Health Score", "name_th": "คะแนนสุขภาพ", "description": "คะแนนสุขภาพโดยรวม", "ai_notes": "สรุปสุขภาพ", "type": "number", "unit": "0-100", "granularity": "daily", "nullable": true, "category": "system_health", "health_risks_targeted": ["สุขภาพทั่วไป"], "expected_benefits": ["สุขภาพดี"], "habit_concern": ["S001"], "marketplace_hooks": ["health_monitoring"]},
612
+ {"metric_id": "biological_age", "name_en": "Biological Age", "name_th": "อายุทางชีวภาพ", "description": "อายุจากสุขภาพ", "ai_notes": "อายุชีวภาพ", "type": "number", "unit": "years", "granularity": "monthly", "nullable": true, "category": "system_aging", "health_risks_targeted": ["การแก่"], "expected_benefits": ["ชะลอวัย"], "habit_concern": ["S002"], "marketplace_hooks": ["anti_aging_program"]},
613
+ {"metric_id": "fitness_age", "name_en": "Fitness Age", "name_th": "อายุความฟิต", "description": "อายุจากความฟิต", "ai_notes": "ความฟิต", "type": "number", "unit": "years", "granularity": "monthly", "nullable": true, "category": "system_fitness", "health_risks_targeted": ["ความฟิต"], "expected_benefits": ["ฟิตขึ้น"], "habit_concern": ["S003"], "marketplace_hooks": ["fitness_program"]},
614
+ {"metric_id": "metabolic_health_score", "name_en": "Metabolic Health Score", "name_th": "คะแนนสุขภาพเมตาบอลิก", "description": "สุขภาพเมตาบอลิก", "ai_notes": "เมตาบอลิก", "type": "number", "unit": "0-100", "granularity": "monthly", "nullable": true, "category": "system_metabolic", "health_risks_targeted": ["เมตาบอลิก"], "expected_benefits": ["เมตาบอลิกดี"], "habit_concern": ["S004"], "marketplace_hooks": ["metabolic_health"]},
615
+ {"metric_id": "immune_score", "name_en": "Immune Score", "name_th": "คะแนนภูมิคุ้มกัน", "description": "สุขภาพภูมิคุ้มกัน", "ai_notes": "ภูมิคุ้มกัน", "type": "number", "unit": "0-100", "granularity": "monthly", "nullable": true, "category": "system_immune", "health_risks_targeted": ["ภูมิคุ้มกัน"], "expected_benefits": ["ภูมิคุ้มกันแข็งแกร่ง"], "habit_concern": ["S005"], "marketplace_hooks": ["immune_boosters"]},
616
+ {"metric_id": "cardio_score", "name_en": "Cardio Score", "name_th": "คะแนนหัวใจ", "description": "สุขภาพหัวใจ", "ai_notes": "หัวใจ", "type": "number", "unit": "0-100", "granularity": "monthly", "nullable": true, "category": "system_cardio", "health_risks_targeted": ["หัวใจ"], "expected_benefits": ["หัวใจแข็งแรง"], "habit_concern": ["S006"], "marketplace_hooks": ["heart_health"]},
617
+ {"metric_id": "stress_resilience", "name_en": "Stress Resilience", "name_th": "ความต้านทานความเครียด", "description": "ความสามารถต้านทานความเครียด", "ai_notes": "ความเครียด", "type": "number", "unit": "0-100", "granularity": "monthly", "nullable": true, "category": "system_stress", "health_risks_targeted": ["ความเครียด"], "expected_benefits": ["จัดการความเครียด"], "habit_concern": ["S007"], "marketplace_hooks": ["resilience_training"]}
618
+ ]
619
+ }
620
+ ]
621
+ };
622
+
623
+ // Global variables
624
+ let currentMetricData = {};
625
+ let metricDetailChart = null;
626
+ let healthTrendChart = null;
627
+ let sleepRecoveryChart = null;
628
+
629
+ // Initialize
630
+ document.addEventListener('DOMContentLoaded', function() {
631
+ feather.replace();
632
+ initializeCharts();
633
+ loadMetricsList();
634
+ });
635
+
636
+ // Tab switching
637
+ function switchTab(tabName) {
638
+ // Hide all tabs
639
+ document.querySelectorAll('.tab-content').forEach(tab => {
640
+ tab.classList.add('hidden');
641
+ });
642
+
643
+ // Remove active class from all buttons
644
+ document.querySelectorAll('.tab-btn').forEach(btn => {
645
+ btn.classList.remove('tab-active');
646
+ });
647
+
648
+ // Show selected tab
649
+ document.getElementById(`${tabName}-tab`).classList.remove('hidden');
650
+
651
+ // Add active class to clicked button
652
+ event.target.classList.add('tab-active');
653
+ }
654
+
655
+ // Initialize charts
656
+ function initializeCharts() {
657
+ // Health Trend Chart
658
+ const healthCtx = document.getElementById('healthTrendChart').getContext('2d');
659
+ healthTrendChart = new Chart(healthCtx, {
660
+ type: 'line',
661
+ data: {
662
+ labels: generateDateLabels(30),
663
+ datasets: [{
664
+ label: 'Health Score',
665
+ data: generateRandomData(30, 85, 95),
666
+ borderColor: '#10b981',
667
+ backgroundColor: 'rgba(16, 185, 129, 0.1)',
668
+ tension: 0.4
669
+ }]
670
+ },
671
+ options: {
672
+ responsive: true,
673
+ maintainAspectRatio: false,
674
+ plugins: {
675
+ legend: { display: false }
676
+ },
677
+ scales: {
678
+ y: { beginAtZero: false, min: 70, max: 100 }
679
+ }
680
+ }
681
+ });
682
+
683
+ // Sleep & Recovery Chart
684
+ const sleepCtx = document.getElementById('sleepRecoveryChart').getContext('2d');
685
+ sleepRecoveryChart = new Chart(sleepCtx, {
686
+ type: 'bar',
687
+ data: {
688
+ labels: generateDateLabels(7),
689
+ datasets: [{
690
+ label: 'Sleep Score',
691
+ data: generateRandomData(7, 70, 90),
692
+ backgroundColor: '#3b82f6'
693
+ }, {
694
+ label: 'Recovery Score',
695
+ data: generateRandomData(7, 60, 85),
696
+ backgroundColor: '#eab308'
697
+ }]
698
+ },
699
+ options: {
700
+ responsive: true,
701
+ maintainAspectRatio: false,
702
+ plugins: {
703
+ legend: { position: 'bottom' }
704
+ },
705
+ scales: {
706
+ y: { beginAtZero: false, min: 50, max: 100 }
707
+ }
708
+ }
709
+ });
710
+ }
711
+
712
+ // Generate date labels
713
+ function generateDateLabels(days) {
714
+ const labels = [];
715
+ for (let i = days - 1; i >= 0; i--) {
716
+ const date = new Date();
717
+ date.setDate(date.getDate() - i);
718
+ labels.push(date.toLocaleDateString('th-TH', { day: 'numeric', month: 'short' }));
719
+ }
720
+ return labels;
721
+ }
722
+
723
+ // Generate random data
724
+ function generateRandomData(count, min, max) {
725
+ return Array.from({ length: count }, () => Math.floor(Math.random() * (max - min + 1)) + min);
726
+ }
727
+
728
+ // Load metrics list
729
+ function loadMetricsList() {
730
+ const metricsList = document.getElementById('metricsList');
731
+ let allMetrics = [];
732
+
733
+ // Collect all metrics
734
+ METRICS_CATALOG.data_sources.forEach(source => {
735
+ source.primary_metrics.forEach(metric => {
736
+ allMetrics.push({
737
+ ...metric,
738
+ source_name: source.name_th,
739
+ source_id: source.source_id
740
+ });
741
+ });
742
+ });
743
+
744
+ // Display all metrics initially
745
+ displayMetrics(allMetrics);
746
+ }
747
+
748
+ // Display metrics
749
+ function displayMetrics(metrics) {
750
+ const metricsList = document.getElementById('metricsList');
751
+ metricsList.innerHTML = '';
752
+
753
+ metrics.forEach(metric => {
754
+ const metricCard = document.createElement('div');
755
+ metricCard.className = 'bg-white rounded-xl p-4 shadow-sm hover:shadow-md transition cursor-pointer';
756
+ metricCard.innerHTML = `
757
+ <div class="flex items-start justify-between mb-2">
758
+ <div>
759
+ <h3 class="font-semibold text-gray-900">${metric.name_th}</h3>
760
+ <p class="text-sm text-gray-500">${metric.source_name}</p>
761
+ </div>
762
+ <span class="px-2 py-1 bg-emerald-100 text-emerald-700 text-xs rounded-full">
763
+ ${getCategoryName(metric.category)}
764
+ </span>
765
+ </div>
766
+ <p class="text-sm text-gray-600 mb-3">${metric.description}</p>
767
+ <div class="flex items-center justify-between">
768
+ <span class="text-xs text-gray-400">หน่วย: ${metric.unit || '-'}</span>
769
+ <button onclick="viewMetricDetail('${metric.metric_id}', '${metric.source_id}')"
770
+ class="text-emerald-600 hover:text-emerald-700 text-sm font-medium">
771
+ ดูรายละเอียด →
772
+ </button>
773
+ </div>
774
+ `;
775
+ metricsList.appendChild(metricCard);
776
+ });
777
+ }
778
+
779
+ // Get category display name
780
+ function getCategoryName(category) {
781
+ const categoryNames = {
782
+ 'wearable_hr': 'หัวใจ',
783
+ 'wearable_sleep': 'การนอน',
784
+ 'wearable_activity': 'กิจกรรม',
785
+ 'body_weight': 'น้ำหนัก',
786
+ 'blood_lipid': 'ไขมัน',
787
+ 'nutrition_macro': 'โปรตีน',
788
+ 'manual_mood': 'อารมณ์'
789
+ };
790
+ return categoryNames[category] || 'ทั่วไป';
791
+ }
792
+
793
+ // Filter metrics
794
+ function filterMetrics(sourceId) {
795
+ let filteredMetrics = [];
796
+
797
+ // Update button styles
798
+ document.querySelectorAll('.filter-btn').forEach(btn => {
799
+ btn.classList.remove('bg-emerald-100', 'text-emerald-700');
800
+ btn.classList.add('bg-gray-100', 'text-gray-700');
801
+ });
802
+ event.target.classList.remove('bg-gray-100', 'text-gray-700');
803
+ event.target.classList.add('bg-emerald-100', 'text-emerald-700');
804
+
805
+ if (sourceId === 'all') {
806
+ METRICS_CATALOG.data_sources.forEach(source => {
807
+ source.primary_metrics.forEach(metric => {
808
+ filteredMetrics.push({
809
+ ...metric,
810
+ source_name: source.name_th,
811
+ source_id: source.source_id
812
+ });
813
+ });
814
+ });
815
+ } else {
816
+ const source = METRICS_CATALOG.data_sources.find(s => s.source_id === sourceId);
817
+ if (source) {
818
+ source.primary_metrics.forEach(metric => {
819
+ filteredMetrics.push({
820
+ ...metric,
821
+ source_name: source.name_th,
822
+ source_id: source.source_id
823
+ });
824
+ });
825
+ }
826
+ }
827
+
828
+ displayMetrics(filteredMetrics);
829
+ }
830
+
831
+ // Search metrics
832
+ document.getElementById('searchInput').addEventListener('input', function(e) {
833
+ const searchTerm = e.target.value.toLowerCase();
834
+ const metricCards = document.querySelectorAll('#metricsList > div');
835
+
836
+ metricCards.forEach(card => {
837
+ const text = card.textContent.toLowerCase();
838
+ if (text.includes(searchTerm)) {
839
+ card.style.display = 'block';
840
+ } else {
841
+ card.style.display = 'none';
842
+ }
843
+ });
844
+ });
845
+
846
+ // View metric detail
847
+ function viewMetricDetail(metricId, sourceId) {
848
+ const source = METRICS_CATALOG.data_sources.find(s => s.source_id === sourceId);
849
+ const metric = source.primary_metrics.find(m => m.metric_id === metricId);
850
+
851
+ if (!metric) return;
852
+
853
+ currentMetricData = { ...metric, source_name: source.name_th };
854
+
855
+ // Hide metrics list and show detail
856
+ document.getElementById('metrics-tab').querySelector('.bg-white.rounded-xl.p-4.mb-6').classList.add('hidden');
857
+ document.getElementById('metricsList').classList.add('hidden');
858
+ document.getElementById('metric-detail').classList.remove('hidden');
859
+
860
+ // Update detail view
861
+ updateMetricDetailView();
862
+ }
863
+
864
+ // Update metric detail view
865
+ function updateMetricDetailView() {
866
+ const metric = currentMetricData;
867
+
868
+ // Update basic info
869
+ document.getElementById('metric-name').textContent = metric.name_th;
870
+ document.getElementById('metric-value').textContent = generateRandomValue();
871
+ document.getElementById('metric-status').textContent = getRandomStatus();
872
+ document.getElementById('metric-date').textContent = new Date().toLocaleDateString('th-TH');
873
+
874
+ // Update trends
875
+ document.getElementById('trend-3d').textContent = generateRandomTrend();
876
+ document.getElementById('trend-7d').textContent = generateRandomTrend();
877
+ document.getElementById('trend-30d').textContent = generateRandomTrend();
878
+
879
+ // Update projection
880
+ document.getElementById('projection-value').textContent = generateRandomValue() + ' (คาดการณ์)';
881
+
882
+ // Update AI insight
883
+ document.getElementById('ai-insight').textContent = generateAIInsight(metric);
884
+
885
+ // Initialize detail chart
886
+ initializeMetricDetailChart();
887
+ }
888
+
889
+ // Generate random value based on metric
890
+ function generateRandomValue() {
891
+ const values = ['92.5', '78%', '85', '12.5', '65 bpm', '45 ms', '7.5 ชม.', '8,432 ก้าว'];
892
+ return values[Math.floor(Math.random() * values.length)];
893
+ }
894
+
895
+ // Get random status
896
+ function getRandomStatus() {
897
+ const statuses = [
898
+ { text: 'ดีมาก', class: 'bg-green-100 text-green-700' },
899
+ { text: 'ปกติ', class: 'bg-blue-100 text-blue-700' },
900
+ { text: 'ต้องปรับปรุง', class: 'bg-yellow-100 text-yellow-700' },
901
+ { text: 'ต้องการความสนใจ', class: 'bg-red-100 text-red-700' }
902
+ ];
903
+ const status = statuses[Math.floor(Math.random() * statuses.length)];
904
+ const element = document.getElementById('metric-status');
905
+ element.textContent = status.text;
906
+ element.className = `status-badge px-3 py-1 rounded-full text-sm ${status.class}`;
907
+ return status.text;
908
+ }
909
+
910
+ // Generate random trend
911
+ function generateRandomTrend() {
912
+ const trends = ['↑ 3.2%', '↓ 1.5%', '→ 0.0%', '↑ 5.8%'];
913
+ return trends[Math.floor(Math.random() * trends.length)];
914
+ }
915
+
916
+ // Generate AI insight
917
+ function generateAIInsight(metric) {
918
+ const insights = {
919
+ 'heart_rate': 'อัตราการเต้นหัวใจของคุณอยู่ในช่วงปกติ การออกกำลังกายสม่ำเสมอช่วยปรับปรุงสุขภาพหัวใจ',
920
+ 'sleep_score': 'คุณภาพการนอนหลับดีขึ้น แต่ควรลดการใช้จอภาพก่อนนอน 1 ชั่วโมง',
921
+ 'weight': 'น้ำหนักเสถียร การควบคุมโปรตีนและการออกกำลังกายจะช่วยสร้างกล้ามเนื้อ',
922
+ 'default': 'ข้อมูลนี้แสดงแนวโน้มที่ดี การติดตามอย่างสม่ำเสมอช่วยให้เข้าใจร่างกายมากขึ้น'
923
+ };
924
+
925
+ const key = metric.metric_id.includes('heart') ? 'heart_rate' :
926
+ metric.metric_id.includes('sleep') ? 'sleep_score' :
927
+ metric.metric_id.includes('weight') ? 'weight' : 'default';
928
+
929
+ return insights[key] || insights.default;
930
+ }
931
+
932
+ // Initialize metric detail chart
933
+ function initializeMetricDetailChart() {
934
+ const ctx = document.getElementById('metricDetailChart').getContext('2d');
935
+
936
+ if (metricDetailChart) {
937
+ metricDetailChart.destroy();
938
+ }
939
+
940
+ metricDetailChart = new Chart(ctx, {
941
+ type: 'line',
942
+ data: {
943
+ labels: generateDateLabels(30),
944
+ datasets: [{
945
+ label: currentMetricData.name_th,
946
+ data: generateRandomData(30, 60, 95),
947
+ borderColor: '#10b981',
948
+ backgroundColor: 'rgba(16, 185, 129, 0.1)',
949
+ tension: 0.4,
950
+ fill: true
951
+ }]
952
+ },
953
+ options: {
954
+ responsive: true,
955
+ maintainAspectRatio: false,
956
+ plugins: {
957
+ legend: { display: true, position: 'top' }
958
+ },
959
+ scales: {
960
+ y: { beginAtZero: false }
961
+ }
962
+ }
963
+ });
964
+ }
965
+
966
+ // Back to metrics list
967
+ function backToMetrics() {
968
+ document.getElementById('metric-detail').classList.add('hidden');
969
+ document.getElementById('metrics-tab').querySelector('.bg-white.rounded-xl.p-4.mb-6').classList.remove('hidden');
970
+ document.getElementById('metricsList').classList.remove('hidden');
971
+ }
972
+
973
+ // Show action modal
974
+ function showActionModal(type) {
975
+ const modal = document.getElementById('actionModal');
976
+ const title = document.getElementById('modalTitle');
977
+ const content = document.getElementById('modalContent');
978
+
979
+ const modalContent = {
980
+ habit: {
981
+ title: 'สร้างนิสัยใหม่',
982
+ content: 'เลือกนิสัยที่ต้องการสร้าง:<br>• ดื่มน้ำ 8 แก้วต่อวัน<br>• ออกกำลังกาย 30 นาที<br>• นอนหลับ 8 ชั่วโมง<br>• ทำสมาธิ 10 นาที'
983
+ },
984
+ nutrition: {
985
+ title: 'ปรับโภชนาการ',
986
+ content: 'คำแนะนำโภชนาการ:<br>• เพิ่มโปรตีน 2 กรัมต่อน้ำหนักกิโลกรัม<br>• ลดน้ำตาลเพิ่มเติม<br>• เพิ่มผัก 5 ส่วนต่อวัน<br>•เลือกไขมันดี'
987
+ },
988
+ exercise: {
989
+ title: 'แผนการออกกำลังกาย',
990
+ content: 'แผนการฝึกแนะนำ:<br>• คาร์ดิโอ 3 ครั้งต่อสัปดาห์<br>• ฝึกกำลัง 2 ครั้งต่อสัปดาห์<br>• ยืดกล้ามเนื้อทุกวัน<br>• พักผ่อนเพียงพอ'
991
+ }
992
+ };
993
+
994
+ const selected = modalContent[type];
995
+ title.textContent = selected.title;
996
+ content.innerHTML = selected.content;
997
+
998
+ modal.classList.remove('hidden');
999
+ }
1000
+
1001
+ // Close action modal
1002
+ function closeActionModal() {
1003
+ document.getElementById('actionModal').classList.add('hidden');
1004
+ }
1005
+
1006
+ // Confirm action
1007
+ function confirmAction() {
1008
+ // Show loading state
1009
+ const modal = document.getElementById('actionModal');
1010
+ const content = document.getElementById('modalContent');
1011
+ content.innerHTML = '<div class="text-center py-4"><div class="loader mx-auto mb-4"></div><p>กำลังบันทึก...</p></div>';
1012
+
1013
+ // Simulate API call
1014
+ setTimeout(() => {
1015
+ content.innerHTML = '<div class="text-center py-4"><p class="text-emerald-600">✓ บันทึกเรียบร้อยแล้ว</p></div>';
1016
+ setTimeout(() => {
1017
+ closeActionModal();
1018
+ }, 1500);
1019
+ }, 1500);
1020
+ }
1021
+ </script>
1022
  </body>
1023
+ </html>
style.css CHANGED
@@ -1,28 +1,255 @@
1
- body {
2
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  }
5
 
6
- h1 {
7
- font-size: 16px;
8
- margin-top: 0;
9
  }
10
 
11
- p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
16
  }
17
 
18
- .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
24
  }
25
 
26
- .card p:last-child {
27
- margin-bottom: 0;
 
 
 
28
  }
 
1
+
2
+ /* Additional styles for VitalMetrics Pro */
3
+
4
+ /* Custom scrollbar */
5
+ ::-webkit-scrollbar {
6
+ width: 8px;
7
+ height: 8px;
8
+ }
9
+
10
+ ::-webkit-scrollbar-track {
11
+ background: #f1f5f9;
12
+ border-radius: 4px;
13
+ }
14
+
15
+ ::-webkit-scrollbar-thumb {
16
+ background: #cbd5e1;
17
+ border-radius: 4px;
18
+ }
19
+
20
+ ::-webkit-scrollbar-thumb:hover {
21
+ background: #94a3b8;
22
+ }
23
+
24
+ /* Animations */
25
+ @keyframes slideIn {
26
+ from {
27
+ opacity: 0;
28
+ transform: translateY(10px);
29
+ }
30
+ to {
31
+ opacity: 1;
32
+ transform: translateY(0);
33
+ }
34
+ }
35
+
36
+ .animate-slide-in {
37
+ animation: slideIn 0.3s ease-out;
38
+ }
39
+
40
+ /* Metric cards grid */
41
+ .metrics-grid {
42
+ display: grid;
43
+ grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
44
+ gap: 1rem;
45
+ }
46
+
47
+ /* Status indicators */
48
+ .status-indicator {
49
+ display: inline-block;
50
+ width: 8px;
51
+ height: 8px;
52
+ border-radius: 50%;
53
+ margin-right: 8px;
54
+ }
55
+
56
+ .status-good {
57
+ background: #10b981;
58
+ }
59
+
60
+ .status-warning {
61
+ background: #f59e0b;
62
+ }
63
+
64
+ .status-danger {
65
+ background: #ef4444;
66
+ }
67
+
68
+ /* Enhanced metric cards */
69
+ .metric-enhanced {
70
+ border-left: 4px solid transparent;
71
+ transition: all 0.3s ease;
72
+ }
73
+
74
+ .metric-enhanced:hover {
75
+ border-left-color: #10b981;
76
+ transform: translateX(4px);
77
+ }
78
+
79
+ /* Loading skeleton */
80
+ .skeleton {
81
+ background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
82
+ background-size: 200% 100%;
83
+ animation: loading 1.5s infinite;
84
+ }
85
+
86
+ @keyframes loading {
87
+ 0% { background-position: 200% 0; }
88
+ 100% { background-position: -200% 0; }
89
+ }
90
+
91
+ /* Responsive improvements */
92
+ @media (max-width: 768px) {
93
+ .metrics-grid {
94
+ grid-template-columns: 1fr;
95
+ }
96
+
97
+ .tab-btn {
98
+ font-size: 0.875rem;
99
+ padding: 0.5rem 0.75rem;
100
+ }
101
+ }
102
+
103
+ /* Print styles */
104
+ @media print {
105
+ .no-print {
106
+ display: none !important;
107
+ }
108
+
109
+ .metric-card {
110
+ break-inside: avoid;
111
+ }
112
+ }
113
+
114
+ /* Focus styles for accessibility */
115
+ .filter-btn:focus,
116
+ .search-input:focus,
117
+ .tab-btn:focus {
118
+ outline: 2px solid #10b981;
119
+ outline-offset: 2px;
120
+ }
121
+
122
+ /* Dark mode support */
123
+ @media (prefers-color-scheme: dark) {
124
+ .glass-effect {
125
+ background: rgba(31, 41, 55, 0.95);
126
+ border-color: rgba(75, 85, 99, 0.3);
127
+ }
128
+
129
+ .metric-card {
130
+ background: #1f2937;
131
+ color: #f9fafb;
132
+ }
133
+
134
+ .text-gray-500 {
135
+ color: #9ca3af;
136
+ }
137
+
138
+ .text-gray-900 {
139
+ color: #f9fafb;
140
+ }
141
+ }
142
+
143
+ /* Chart container enhancements */
144
+ .chart-container {
145
+ position: relative;
146
+ height: 250px;
147
+ width: 100%;
148
+ margin: 1rem 0;
149
+ }
150
+
151
+ .chart-loading {
152
+ display: flex;
153
+ align-items: center;
154
+ justify-content: center;
155
+ height: 250px;
156
+ }
157
+
158
+ /* Modal enhancements */
159
+ .modal-backdrop {
160
+ background: rgba(0, 0, 0, 0.5);
161
+ backdrop-filter: blur(4px);
162
+ }
163
+
164
+ .modal-content {
165
+ background: white;
166
+ border-radius: 1rem;
167
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
168
+ }
169
+
170
+ /* Progress bars */
171
+ .progress-bar {
172
+ height: 8px;
173
+ background: #e5e7eb;
174
+ border-radius: 4px;
175
+ overflow: hidden;
176
+ }
177
+
178
+ .progress-fill {
179
+ height: 100%;
180
+ background: linear-gradient(90deg, #10b981, #059669);
181
+ transition: width 0.5s ease;
182
+ }
183
+
184
+ /* Tooltips */
185
+ .tooltip {
186
+ position: relative;
187
+ }
188
+
189
+ .tooltip:hover::after {
190
+ content: attr(data-tooltip);
191
+ position: absolute;
192
+ bottom: 100%;
193
+ left: 50%;
194
+ transform: translateX(-50%);
195
+ background: #1f2937;
196
+ color: white;
197
+ padding: 0.5rem;
198
+ border-radius: 0.375rem;
199
+ font-size: 0.875rem;
200
+ white-space: nowrap;
201
+ z-index: 1000;
202
+ }
203
+
204
+ /* Badge variations */
205
+ .badge-sm {
206
+ font-size: 0.75rem;
207
+ padding: 0.25rem 0.5rem;
208
+ }
209
+
210
+ .badge-lg {
211
+ font-size: 1rem;
212
+ padding: 0.5rem 1rem;
213
+ }
214
+
215
+ /* Tab content transitions */
216
+ .tab-content {
217
+ animation: fadeIn 0.3s ease-in;
218
+ }
219
+
220
+ @keyframes fadeIn {
221
+ from { opacity: 0; }
222
+ to { opacity: 1; }
223
+ }
224
+
225
+ /* Metric value display */
226
+ .metric-value {
227
+ font-variant-numeric: tabular-nums;
228
+ letter-spacing: -0.025em;
229
+ }
230
+
231
+ /* Trend indicators */
232
+ .trend-indicator {
233
+ display: inline-flex;
234
+ align-items: center;
235
+ font-weight: 500;
236
  }
237
 
238
+ .trend-positive {
239
+ color: #10b981;
 
240
  }
241
 
242
+ .trend-negative {
243
+ color: #ef4444;
 
 
 
244
  }
245
 
246
+ .trend-neutral {
247
+ color: #6b7280;
 
 
 
 
248
  }
249
 
250
+ /* Search highlight */
251
+ .search-highlight {
252
+ background: #fef3c7;
253
+ padding: 0 2px;
254
+ border-radius: 2px;
255
  }