ยินดีต้อนรับกลับมา
คุณมีเป้าหมาย: ลดไขมัน 3% ใน 60 วัน
ข้อมูลวันนี้
28.5%
เป้าหมาย: 25%
31.2 กก.
ตามเป้าหมาย
66.4 กก.
1,540 kcal
สถานะวันนี้
เผาผลาญแล้ว
เป้าหมาย 2,000 kcal
เดินแล้ว
เป้าหมาย 8,000 ก้าว
Meal Plan วันนี้
// Tab switching functionality function switchTab(tabName) { // Hide all tab contents const tabContents = document.querySelectorAll('.tab-content'); tabContents.forEach(content => { content.classList.add('hidden'); }); // Show selected tab const selectedTab = document.getElementById(tabName); if (selectedTab) { selectedTab.classList.remove('hidden'); } // Update tab button colors const tabButtons = document.querySelectorAll('.tab-btn'); tabButtons.forEach(btn => { btn.classList.remove('text-green-600'); btn.classList.add('text-gray-600'); }); // Highlight active tab button const activeBtn = document.querySelector(`button[onclick="switchTab('${tabName}')"]`); if (activeBtn) { activeBtn.classList.remove('text-gray-600'); activeBtn.classList.add('text-green-600'); } // Re-initialize feather icons feather.replace(); // Initialize chart if graph tab is selected if (tabName === 'graph') { setTimeout(() => initChart(), 100); } } // Chart functionality let healthChart = null; function initChart() { const canvas = document.getElementById('healthChart'); if (!canvas) return; const ctx = canvas.getContext('2d'); // Sample data for 7 days const labels = ['จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.', 'อา.']; const fatData = [29.1, 28.9, 28.8, 28.7, 28.6, 28.5, 28.4]; const muscleData = [30.2, 30.4, 30.5, 30.8, 30.9, 31.0, 31.2]; const weightData = [67.0, 66.8, 66.7, 66.6, 66.5, 66.4, 66.4]; // Simple line chart drawing drawLineChart(ctx, canvas.width, canvas.height, labels, [ { data: fatData, color: '#3B82F6', label: 'ไขมัน %' }, { data: muscleData, color: '#10B981', label: 'กล้ามเนื้อ kg' }, { data: weightData, color: '#8B5CF6', label: 'น้ำหนัก kg' } ]); } function drawLineChart(ctx, width, height, labels, datasets) { // Clear canvas ctx.clearRect(0, 0, width, height); const padding = 40; const graphWidth = width - padding * 2; const graphHeight = height - padding * 2; const dataPoints = labels.length; // Draw axes ctx.strokeStyle = '#E5E7EB'; ctx.lineWidth = 1; ctx.beginPath(); ctx.moveTo(padding, padding); ctx.lineTo(padding, height - padding); ctx.lineTo(width - padding, height - padding); ctx.stroke(); // Draw grid lines ctx.strokeStyle = '#F3F4F6'; for (let i = 0; i <= 5; i++) { const y = padding + (graphHeight / 5) * i; ctx.beginPath(); ctx.moveTo(padding, y); ctx.lineTo(width - padding, y); ctx.stroke(); } // Draw labels ctx.fillStyle = '#6B7280'; ctx.font = '12px Prompt'; labels.forEach((label, i) => { const x = padding + (graphWidth / (dataPoints - 1)) * i; ctx.fillText(label, x - 10, height - padding + 20); }); // Draw data lines datasets.forEach(dataset => { ctx.strokeStyle = dataset.color; ctx.lineWidth = 2; ctx.beginPath(); dataset.data.forEach((value, i) => { const x = padding + (graphWidth / (dataPoints - 1)) * i; const normalizedValue = (value - Math.min(...dataset.data)) / (Math.max(...dataset.data) - Math.min(...dataset.data)); const y = height - padding - (normalizedValue * graphHeight * 0.8 + graphHeight * 0.1); if (i === 0) { ctx.moveTo(x, y); } else { ctx.lineTo(x, y); } }); ctx.stroke(); // Draw data points dataset.data.forEach((value, i) => { const x = padding + (graphWidth / (dataPoints - 1)) * i; const normalizedValue = (value - Math.min(...dataset.data)) / (Math.max(...dataset.data) - Math.min(...dataset.data)); const y = height - padding - (normalizedValue * graphHeight * 0.8 + graphHeight * 0.1); ctx.fillStyle = dataset.color; ctx.beginPath(); ctx.arc(x, y, 3, 0, Math.PI * 2); ctx.fill(); }); }); } // Update graph based on time range function updateGraph(days) { // Update button styles const buttons = document.querySelectorAll('[onclick^="updateGraph"]'); buttons.forEach(btn => { btn.classList.remove('bg-green-500', 'text-white'); btn.classList.add('bg-gray-200', 'text-gray-700'); }); event.target.classList.remove('bg-gray-200', 'text-gray-700'); event.target.classList.add('bg-green-500', 'text-white'); // Re-initialize chart with new data initChart(); } // Add to cart functionality function addToCart(productName, price) { // Create notification const notification = document.createElement('div'); notification.className = 'fixed top-20 right-4 bg-green-500 text-white px-4 py-2 rounded-lg shadow-lg z-50'; notification.textContent = `เพิ่ม ${productName} ลงตะกร้าแล้ว`; document.body.appendChild(notification); // Animate in notification.style.animation = 'slideIn 0.3s ease-out'; // Remove after 2 seconds setTimeout(() => { notification.style.animation = 'slideOut 0.3s ease-out'; setTimeout(() => { document.body.removeChild(notification); }, 300); }, 2000); } // Buy now functionality function buyNow(productName, price) { // Create confirmation modal const modal = document.createElement('div'); modal.className = 'fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50'; modal.innerHTML = `
คุณต้องการสั่งซื้อ ${productName} ในราคา ${price} ใช่หรือไม่?
คุณสามารถติดต่อโค้ชได้ผ่านช่องทางต่อไปนี้:
คุณมีเป้าหมาย: ลดไขมัน 3% ใน 60 วัน
28.5%
เป้าหมาย: 25%
31.2 กก.
ตามเป้าหมาย
66.4 กก.
1,540 kcal
เผาผลาญแล้ว
เป้าหมาย 2,000 kcal
เดินแล้ว
เป้าหมาย 8,000 ก้าว
Meal Plan วันนี้