+
NUTRI ELITE
+ +
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
- 2500
-Daily Calorie Target
+
+
+
-
-
-
-
- 3.9L
- Daily Hydration -
-
-
-
-
-
-
-
-
- P
0g
C
0g
F
0g
- `;
- setUnits('metric');
- update();
- }
-
function update() {
const wv = parseFloat(document.getElementById('w').value)||0, hv = parseFloat(document.getElementById('h').value)||0;
- const av = parseFloat(document.getElementById('age').value)||0, act = parseFloat(document.getElementById('act').value);
+ const av = parseFloat(document.getElementById('age').value)||0, act = parseFloat(document.getElementById('act').value)||1;
const agg = parseInt(document.getElementById('agg').value);
+ if(!wv || !hv || !av) return;
+
const wc = isMetric ? wv : wv/2.205, hc = isMetric ? hv : hv*2.54;
const bmr = (10 * wc) + (6.25 * hc) - (5 * av) + 5;
const total = Math.round((bmr * act) + agg);
+
document.getElementById('kcal').innerText = total;
document.getElementById('aggDisp').innerText = (agg>0?'+':'')+agg+" kcal";
- document.getElementById('h2o').innerText = (wc * 0.035).toFixed(1) + "L";
const pG = Math.round((total * 0.3)/4), cG = Math.round((total * 0.4)/4), fG = Math.round((total * 0.3)/9);
document.getElementById('pG').innerText = pG+"g"; document.getElementById('cG').innerText = cG+"g"; document.getElementById('fG').innerText = fG+"g";
if(mChart) { mChart.data.datasets[0].data = [pG*4, cG*4, fG*9]; mChart.update(); }
}
- async function talk(custom) {
+ function resetAll() {
+ ['w','t','h','age','agg'].forEach(id => document.getElementById(id).value = id === 'agg' ? 0 : "");
+ document.getElementById('act').selectedIndex = 0;
+ document.getElementById('kcal').innerText = "0";
+ document.getElementById('chat').innerHTML = `
-
+
-
- System Ready.
- I have added the **Reset Button**. All biometrics, themes, and inputs are synchronized. Press **Enter** to talk to your coach. -
+
- 0
+Target Calories
+
-
+
+
-
-
-
-
+
+
+
+
+
+
+
+ P: 0g
+ C: 0g
+ F: 0g
+
+
+
+
@@ -136,76 +135,57 @@
function setTheme(t) { document.body.className = 'theme-' + t; }
- function setUnits(mode) {
- if((mode==='metric' && !isMetric) || (mode==='imperial' && isMetric)) {
- isMetric = !isMetric;
- const w = document.getElementById('w'), t = document.getElementById('t'), h = document.getElementById('h');
- if(isMetric) {
- w.value = (w.value/2.205).toFixed(0); t.value = (t.value/2.205).toFixed(0); h.value = (h.value*2.54).toFixed(0);
- } else {
- w.value = (w.value*2.205).toFixed(0); t.value = (t.value*2.205).toFixed(0); h.value = (h.value/2.54).toFixed(0);
- }
- document.getElementById('txtW').innerText = isMetric ? "Current (kg)" : "Current (lb)";
- document.getElementById('txtT').innerText = isMetric ? "Target (kg)" : "Target (lb)";
- document.getElementById('txtH').innerText = isMetric ? "Height (cm)" : "Height (in)";
- document.getElementById('btnMetric').className = isMetric ? "btn btn-primary active btn-sm" : "btn btn-outline-primary btn-sm";
- document.getElementById('btnImperial').className = !isMetric ? "btn btn-primary active btn-sm" : "btn btn-outline-primary btn-sm";
- update();
- }
- }
-
- function resetDashboard() {
- isMetric = true;
- document.getElementById('w').value = 110;
- document.getElementById('t').value = 85;
- document.getElementById('h').value = 176;
- document.getElementById('age').value = 30;
- document.getElementById('act').value = 1.55;
- document.getElementById('agg').value = -300;
- document.getElementById('chat').innerHTML = `
+
+
+
+
+ Mobile Engine Synced.
+ The dashboard is now fully responsive. Input your data to begin. +
+
+
+
System Reset.
Dashboard and Chat history have been cleared. Ready for a new session.System reset. All fields cleared.
`;
+ if(mChart) { mChart.data.datasets[0].data = [1,1,1]; mChart.update(); }
+ }
+
+ async function talk() {
const box = document.getElementById('chat'), input = document.getElementById('uIn');
- const text = custom || input.value; if(!text) return;
- if(!custom) { box.innerHTML += `${text}
`; input.value=""; }
- const id = 'ai-'+Date.now(); box.innerHTML += `Generating...
`;
+ const text = input.value; if(!text) return;
+ box.innerHTML += `${text}
`; input.value="";
+ const id = 'ai-'+Date.now(); box.innerHTML += `Thinking...
`;
box.scrollTop = box.scrollHeight;
- const res = await fetch("https://api.groq.com/openai/v1/chat/completions", {
- method: "POST", headers: {"Content-Type":"application/json", "Authorization":`Bearer ${API}`},
- body: JSON.stringify({ model:"llama-3.3-70b-versatile", messages:[
- {role:"system", content:`Pro Nutritionist. Target: ${document.getElementById('kcal').innerText} kcal. P:${document.getElementById('pG').innerText}. Use clean Markdown Tables.`},
- {role:"user", content:text}
- ]})
- });
- const d = await res.json();
- document.getElementById(id).innerHTML = marked.parse(d.choices[0].message.content);
+ try {
+ const res = await fetch("https://api.groq.com/openai/v1/chat/completions", {
+ method: "POST", headers: {"Content-Type":"application/json", "Authorization":`Bearer ${API}`},
+ body: JSON.stringify({ model:"llama-3.3-70b-versatile", messages:[
+ {role:"system", content:`Pro Nutritionist. Target: ${document.getElementById('kcal').innerText} kcal. Use Markdown tables.`},
+ {role:"user", content:text}
+ ]})
+ });
+ const d = await res.json();
+ document.getElementById(id).innerHTML = marked.parse(d.choices[0].message.content);
+ } catch(e) { document.getElementById(id).innerText = "Connection Error."; }
box.scrollTop = box.scrollHeight;
}
window.onload = () => {
mChart = new Chart(document.getElementById('mChart').getContext('2d'), {
type: 'doughnut', data: { datasets: [{ data: [1,1,1], backgroundColor: ['#0dcaf0','#dc3545','#ffc107'], borderWeight:0 }] },
- options: { plugins: { legend: { display: false } }, cutout: '78%' }
+ options: { plugins: { legend: { display: false } }, cutout: '75%' }
});
- update();
+ resetAll(); // Ensures empty fields on page load
}