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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="fr">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
| 6 |
+
<title>TRANSFORM</title>
|
| 7 |
+
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=Bebas+Neue&display=swap" rel="stylesheet">
|
| 8 |
+
<style>
|
| 9 |
+
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
|
| 10 |
+
body { background: #080c10; font-family: 'DM Sans', sans-serif; color: #fff; min-height: 100vh; }
|
| 11 |
+
input[type=number] { -moz-appearance: textfield; }
|
| 12 |
+
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
|
| 13 |
+
|
| 14 |
+
.page { display: none; }
|
| 15 |
+
.page.active { display: block; }
|
| 16 |
+
|
| 17 |
+
/* Setup */
|
| 18 |
+
#setup { display: none; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
|
| 19 |
+
#setup.active { display: flex; }
|
| 20 |
+
.setup-box { width: 100%; max-width: 420px; }
|
| 21 |
+
.setup-title { font-size: 56px; font-family: 'Bebas Neue', sans-serif; color: #b8ff57; letter-spacing: 4px; text-align: center; line-height: 1; }
|
| 22 |
+
.setup-sub { color: #555; font-size: 14px; text-align: center; margin-top: 6px; }
|
| 23 |
+
.setup-form { background: #0f1419; border-radius: 20px; padding: 32px; border: 1px solid #1a2030; margin-top: 40px; }
|
| 24 |
+
.setup-form label { color: #999; font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; display: block; }
|
| 25 |
+
.setup-form input { width: 100%; background: #171d27; border: 1px solid #2a3040; border-radius: 12px; padding: 14px 16px; color: #fff; font-size: 22px; font-family: 'DM Sans'; margin-top: 8px; margin-bottom: 20px; outline: none; }
|
| 26 |
+
.btn-primary { width: 100%; background: #b8ff57; color: #080c10; border: none; border-radius: 12px; padding: 16px; font-size: 16px; font-weight: 700; cursor: pointer; letter-spacing: 0.5px; font-family: 'DM Sans'; }
|
| 27 |
+
.btn-primary:active { opacity: 0.85; }
|
| 28 |
+
|
| 29 |
+
/* Dashboard */
|
| 30 |
+
#dashboard { padding-bottom: 80px; }
|
| 31 |
+
.container { max-width: 480px; margin: 0 auto; padding: 0 24px; }
|
| 32 |
+
.header { padding: 28px 24px 0; max-width: 480px; margin: 0 auto; display: flex; justify-content: space-between; align-items: flex-start; }
|
| 33 |
+
.logo { font-size: 28px; font-family: 'Bebas Neue'; color: #b8ff57; letter-spacing: 3px; }
|
| 34 |
+
.header-date { color: #444; font-size: 12px; margin-top: 2px; }
|
| 35 |
+
.streak-label { font-size: 11px; color: #555; letter-spacing: 1px; text-transform: uppercase; text-align: right; }
|
| 36 |
+
.streak-val { font-size: 24px; font-weight: 700; }
|
| 37 |
+
|
| 38 |
+
.card { background: #0f1419; border-radius: 20px; padding: 20px 24px; border: 1px solid #1a2030; margin-top: 16px; }
|
| 39 |
+
.card-gradient { background: linear-gradient(135deg, #0f1419 0%, #111820 100%); padding: 28px; position: relative; overflow: hidden; border-radius: 24px; }
|
| 40 |
+
.card-glow { position: absolute; top: -40px; right: -40px; width: 160px; height: 160px; border-radius: 50%; background: radial-gradient(circle, rgba(184,255,87,0.08), transparent 70%); }
|
| 41 |
+
.section-title { font-size: 12px; color: #555; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 16px; }
|
| 42 |
+
.stat-label { font-size: 11px; color: #555; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px; }
|
| 43 |
+
|
| 44 |
+
.weight-big { font-size: 52px; font-weight: 300; line-height: 1; }
|
| 45 |
+
.weight-big .unit { font-size: 20px; color: #555; margin-left: 4px; }
|
| 46 |
+
.goal-line { font-size: 12px; color: #666; margin-top: 6px; }
|
| 47 |
+
.goal-line span { color: #b8ff57; font-weight: 600; }
|
| 48 |
+
|
| 49 |
+
.progress-row { display: flex; justify-content: space-between; font-size: 11px; color: #555; margin-bottom: 8px; }
|
| 50 |
+
.progress-bar { height: 6px; background: #1a2030; border-radius: 99px; overflow: hidden; }
|
| 51 |
+
.progress-fill { height: 100%; background: linear-gradient(90deg, #5aff57, #b8ff57); border-radius: 99px; transition: width 0.8s ease; }
|
| 52 |
+
|
| 53 |
+
/* Log input */
|
| 54 |
+
.log-row { display: flex; gap: 12px; align-items: center; }
|
| 55 |
+
.log-input { flex: 1; background: #171d27; border: 1px solid #2a3040; border-radius: 12px; padding: 13px 16px; color: #fff; font-size: 16px; font-family: 'DM Sans'; outline: none; }
|
| 56 |
+
.log-btn { background: #b8ff57; color: #080c10; border: none; border-radius: 12px; padding: 13px 20px; font-size: 20px; font-weight: 700; cursor: pointer; flex-shrink: 0; }
|
| 57 |
+
|
| 58 |
+
/* Habits */
|
| 59 |
+
.habits-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
|
| 60 |
+
.habit-toggle { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #171d27; border-radius: 12px; cursor: pointer; border: 1px solid #2a3040; transition: all 0.2s; user-select: none; }
|
| 61 |
+
.habit-toggle.on { border-color: #b8ff57; background: #1a2a10; }
|
| 62 |
+
.habit-dot { width: 10px; height: 10px; border-radius: 50%; background: #2a3040; transition: background 0.2s; flex-shrink: 0; }
|
| 63 |
+
.habit-toggle.on .habit-dot { background: #b8ff57; }
|
| 64 |
+
.habit-name { font-size: 13px; color: #888; }
|
| 65 |
+
.habit-toggle.on .habit-name { color: #b8ff57; }
|
| 66 |
+
|
| 67 |
+
/* Chart */
|
| 68 |
+
.chart-box { position: relative; height: 200px; }
|
| 69 |
+
canvas { width: 100% !important; }
|
| 70 |
+
|
| 71 |
+
/* History */
|
| 72 |
+
.hist-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-radius: 10px; }
|
| 73 |
+
.hist-row:first-child { background: #171d27; }
|
| 74 |
+
.hist-date { color: #666; font-size: 13px; }
|
| 75 |
+
.hist-diff { font-size: 12px; font-weight: 600; }
|
| 76 |
+
.hist-weight { font-weight: 600; font-size: 16px; }
|
| 77 |
+
.hist-weight .unit { color: #444; font-size: 12px; }
|
| 78 |
+
|
| 79 |
+
.success-banner { margin-top: 16px; background: linear-gradient(135deg, #b8ff57, #5aff57); border-radius: 20px; padding: 24px; text-align: center; }
|
| 80 |
+
.success-banner .title { font-size: 18px; font-weight: 700; color: #080c10; margin-top: 8px; }
|
| 81 |
+
.success-banner .sub { color: #1a4010; font-size: 14px; margin-top: 4px; }
|
| 82 |
+
|
| 83 |
+
/* Loading overlay */
|
| 84 |
+
.loading { text-align: center; padding: 40px; color: #555; font-size: 14px; }
|
| 85 |
+
.spinner { width: 32px; height: 32px; border: 3px solid #1a2030; border-top-color: #b8ff57; border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 12px; }
|
| 86 |
+
@keyframes spin { to { transform: rotate(360deg); } }
|
| 87 |
+
|
| 88 |
+
/* Status message */
|
| 89 |
+
.status-msg { text-align: center; font-size: 12px; margin-top: 8px; min-height: 18px; }
|
| 90 |
+
.status-ok { color: #b8ff57; }
|
| 91 |
+
.status-err { color: #ff6b6b; }
|
| 92 |
+
|
| 93 |
+
/* Reset btn */
|
| 94 |
+
.reset-btn { background: none; border: 1px solid #2a3040; color: #555; border-radius: 10px; padding: 10px 16px; font-size: 12px; cursor: pointer; font-family: 'DM Sans'; margin-top: 16px; width: 100%; }
|
| 95 |
+
.reset-btn:active { opacity: 0.7; }
|
| 96 |
+
</style>
|
| 97 |
+
</head>
|
| 98 |
+
<body>
|
| 99 |
+
|
| 100 |
+
<!-- SETUP SCREEN -->
|
| 101 |
+
<div id="setup" class="page">
|
| 102 |
+
<div class="setup-box">
|
| 103 |
+
<div class="setup-title">TRANSFORM</div>
|
| 104 |
+
<div class="setup-sub">Suivi de perte de poids</div>
|
| 105 |
+
<div class="setup-form">
|
| 106 |
+
<label>Poids actuel (kg)</label>
|
| 107 |
+
<input type="number" id="inp-start" placeholder="ex: 85" inputmode="decimal">
|
| 108 |
+
<label>Poids objectif (kg)</label>
|
| 109 |
+
<input type="number" id="inp-goal" placeholder="ex: 72" inputmode="decimal">
|
| 110 |
+
<button class="btn-primary" onclick="doSetup()">Commencer ma transformation</button>
|
| 111 |
+
</div>
|
| 112 |
+
</div>
|
| 113 |
+
</div>
|
| 114 |
+
|
| 115 |
+
<!-- DASHBOARD -->
|
| 116 |
+
<div id="dashboard" class="page">
|
| 117 |
+
<div class="header">
|
| 118 |
+
<div>
|
| 119 |
+
<div class="logo">TRANSFORM</div>
|
| 120 |
+
<div class="header-date" id="hdr-date"></div>
|
| 121 |
+
</div>
|
| 122 |
+
<div>
|
| 123 |
+
<div class="streak-label">Streak</div>
|
| 124 |
+
<div class="streak-val" id="hdr-streak">0</div>
|
| 125 |
+
</div>
|
| 126 |
+
</div>
|
| 127 |
+
|
| 128 |
+
<div class="container">
|
| 129 |
+
<!-- Big stats card -->
|
| 130 |
+
<div class="card card-gradient" style="margin-top:28px; border:1px solid #1a2030;">
|
| 131 |
+
<div class="card-glow"></div>
|
| 132 |
+
<div style="display:flex;justify-content:space-between;align-items:center;position:relative;">
|
| 133 |
+
<div>
|
| 134 |
+
<div class="stat-label">Poids actuel</div>
|
| 135 |
+
<div class="weight-big" id="stat-current">--<span class="unit">kg</span></div>
|
| 136 |
+
<div class="goal-line">Objectif : <span id="stat-goal">--</span> kg</div>
|
| 137 |
+
</div>
|
| 138 |
+
<div style="text-align:center;">
|
| 139 |
+
<svg width="90" height="90" style="transform:rotate(-90deg)">
|
| 140 |
+
<circle cx="45" cy="45" r="38" fill="none" stroke="#1a2030" stroke-width="7"/>
|
| 141 |
+
<circle id="ring" cx="45" cy="45" r="38" fill="none" stroke="#b8ff57" stroke-width="7" stroke-linecap="round"
|
| 142 |
+
stroke-dasharray="238.76" stroke-dashoffset="238.76" style="transition:stroke-dashoffset 0.8s ease"/>
|
| 143 |
+
</svg>
|
| 144 |
+
<div style="margin-top:-54px;font-size:18px;font-weight:700;color:#b8ff57" id="stat-pct">0%</div>
|
| 145 |
+
<div style="margin-top:32px;font-size:10px;color:#555">COMPLETE</div>
|
| 146 |
+
</div>
|
| 147 |
+
</div>
|
| 148 |
+
<div style="margin-top:24px;">
|
| 149 |
+
<div class="progress-row">
|
| 150 |
+
<span>Perdu : <span style="font-weight:600" id="stat-lost">0 kg</span></span>
|
| 151 |
+
<span>Restant : <span style="font-weight:600" id="stat-left">0 kg</span></span>
|
| 152 |
+
</div>
|
| 153 |
+
<div class="progress-bar"><div class="progress-fill" id="bar-fill" style="width:0%"></div></div>
|
| 154 |
+
</div>
|
| 155 |
+
</div>
|
| 156 |
+
|
| 157 |
+
<!-- Log today -->
|
| 158 |
+
<div class="card">
|
| 159 |
+
<div class="log-row">
|
| 160 |
+
<input type="number" class="log-input" id="inp-weight" placeholder="Poids aujourd'hui (kg)" inputmode="decimal">
|
| 161 |
+
<button class="log-btn" onclick="addEntry()">+</button>
|
| 162 |
+
</div>
|
| 163 |
+
<!-- Habits -->
|
| 164 |
+
<div style="margin-top:16px;">
|
| 165 |
+
<div class="habits-grid">
|
| 166 |
+
<div class="habit-toggle" data-habit="jeune" onclick="toggleHabit(this)">
|
| 167 |
+
<div class="habit-dot"></div><div class="habit-name">Jeune</div>
|
| 168 |
+
</div>
|
| 169 |
+
<div class="habit-toggle" data-habit="sucre" onclick="toggleHabit(this)">
|
| 170 |
+
<div class="habit-dot"></div><div class="habit-name">Sans sucre</div>
|
| 171 |
+
</div>
|
| 172 |
+
<div class="habit-toggle" data-habit="vacuum" onclick="toggleHabit(this)">
|
| 173 |
+
<div class="habit-dot"></div><div class="habit-name">Vacuum</div>
|
| 174 |
+
</div>
|
| 175 |
+
<div class="habit-toggle" data-habit="flex" onclick="toggleHabit(this)">
|
| 176 |
+
<div class="habit-dot"></div><div class="habit-name">Souplesse</div>
|
| 177 |
+
</div>
|
| 178 |
+
<div class="habit-toggle" data-habit="eau" onclick="toggleHabit(this)" style="grid-column: span 2;">
|
| 179 |
+
<div class="habit-dot"></div><div class="habit-name">2L+ d'eau</div>
|
| 180 |
+
</div>
|
| 181 |
+
</div>
|
| 182 |
+
</div>
|
| 183 |
+
<div class="status-msg" id="status-msg"></div>
|
| 184 |
+
</div>
|
| 185 |
+
|
| 186 |
+
<!-- Chart -->
|
| 187 |
+
<div class="card" id="chart-card" style="display:none;">
|
| 188 |
+
<div class="section-title">Evolution</div>
|
| 189 |
+
<div class="chart-box">
|
| 190 |
+
<canvas id="chart"></canvas>
|
| 191 |
+
</div>
|
| 192 |
+
</div>
|
| 193 |
+
|
| 194 |
+
<!-- History -->
|
| 195 |
+
<div class="card" id="hist-card" style="display:none;">
|
| 196 |
+
<div class="section-title">Historique</div>
|
| 197 |
+
<div id="hist-list"></div>
|
| 198 |
+
</div>
|
| 199 |
+
|
| 200 |
+
<!-- Success -->
|
| 201 |
+
<div id="success-banner" class="success-banner" style="display:none;">
|
| 202 |
+
<div style="font-size:32px">🎉</div>
|
| 203 |
+
<div class="title">Objectif atteint !</div>
|
| 204 |
+
<div class="sub">Bravo, transformation accomplie.</div>
|
| 205 |
+
</div>
|
| 206 |
+
|
| 207 |
+
<!-- Reset -->
|
| 208 |
+
<button class="reset-btn" onclick="resetApp()">Reinitialiser l'application</button>
|
| 209 |
+
</div>
|
| 210 |
+
</div>
|
| 211 |
+
|
| 212 |
+
<!-- Loading -->
|
| 213 |
+
<div id="loading" style="display:none;position:fixed;inset:0;background:#080c10;z-index:999;display:flex;align-items:center;justify-content:center;">
|
| 214 |
+
<div class="loading"><div class="spinner"></div>Chargement...</div>
|
| 215 |
+
</div>
|
| 216 |
+
|
| 217 |
+
<script src="https://cdn.jsdelivr.net/npm/chart.js@4/dist/chart.umd.min.js"></script>
|
| 218 |
+
<script>
|
| 219 |
+
const API = "https://script.google.com/macros/s/AKfycbxI6OC2DxKtblzSjE5laasREnPmK7zDdeIeGYGZEN-rRryDKRPjptLexUefVKvj_ew/exec";
|
| 220 |
+
|
| 221 |
+
let entries = [];
|
| 222 |
+
let startWeight = 0;
|
| 223 |
+
let goalWeight = 0;
|
| 224 |
+
let chart = null;
|
| 225 |
+
|
| 226 |
+
// --- Utils ---
|
| 227 |
+
function todayStr() {
|
| 228 |
+
return new Date().toISOString().split("T")[0];
|
| 229 |
+
}
|
| 230 |
+
function fmtDate(d) {
|
| 231 |
+
return new Date(d).toLocaleDateString("fr-FR", { day: "2-digit", month: "short" });
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
// --- Persistence (localStorage for settings) ---
|
| 235 |
+
function saveSettings() {
|
| 236 |
+
localStorage.setItem("tf_start", startWeight);
|
| 237 |
+
localStorage.setItem("tf_goal", goalWeight);
|
| 238 |
+
}
|
| 239 |
+
function loadSettings() {
|
| 240 |
+
startWeight = parseFloat(localStorage.getItem("tf_start")) || 0;
|
| 241 |
+
goalWeight = parseFloat(localStorage.getItem("tf_goal")) || 0;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
// --- Google Sheets ---
|
| 245 |
+
async function fetchEntries() {
|
| 246 |
+
try {
|
| 247 |
+
const r = await fetch(API);
|
| 248 |
+
const data = await r.json();
|
| 249 |
+
// data is array of numbers (last 15 weights) from your script
|
| 250 |
+
// We'll map them to simple objects. Since the script only returns weights,
|
| 251 |
+
// we'll number them backwards from today.
|
| 252 |
+
if (Array.isArray(data) && data.length > 0) {
|
| 253 |
+
// If entries are numbers, create dates going back from today
|
| 254 |
+
if (typeof data[0] === "number") {
|
| 255 |
+
const today = new Date();
|
| 256 |
+
entries = data.map((w, i) => {
|
| 257 |
+
const d = new Date(today);
|
| 258 |
+
d.setDate(d.getDate() - (data.length - 1 - i));
|
| 259 |
+
return { date: d.toISOString().split("T")[0], weight: w };
|
| 260 |
+
});
|
| 261 |
+
} else {
|
| 262 |
+
// If we get objects (after script update)
|
| 263 |
+
entries = data.map(e => ({ date: e.date, weight: e.poids }));
|
| 264 |
+
}
|
| 265 |
+
}
|
| 266 |
+
} catch (err) {
|
| 267 |
+
console.error("Fetch error:", err);
|
| 268 |
+
}
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
async function postEntry(poids, habits) {
|
| 272 |
+
try {
|
| 273 |
+
const body = {
|
| 274 |
+
poids: poids,
|
| 275 |
+
jeune: habits.jeune || false,
|
| 276 |
+
sucre: habits.sucre || false,
|
| 277 |
+
vacuum: habits.vacuum || false,
|
| 278 |
+
flex: habits.flex || false,
|
| 279 |
+
eau: habits.eau || false
|
| 280 |
+
};
|
| 281 |
+
await fetch(API, {
|
| 282 |
+
method: "POST",
|
| 283 |
+
body: JSON.stringify(body),
|
| 284 |
+
headers: { "Content-Type": "text/plain" } // avoid CORS preflight
|
| 285 |
+
});
|
| 286 |
+
return true;
|
| 287 |
+
} catch (err) {
|
| 288 |
+
console.error("Post error:", err);
|
| 289 |
+
return false;
|
| 290 |
+
}
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
// --- Habits ---
|
| 294 |
+
function toggleHabit(el) {
|
| 295 |
+
el.classList.toggle("on");
|
| 296 |
+
}
|
| 297 |
+
function getHabits() {
|
| 298 |
+
const h = {};
|
| 299 |
+
document.querySelectorAll(".habit-toggle").forEach(el => {
|
| 300 |
+
h[el.dataset.habit] = el.classList.contains("on");
|
| 301 |
+
});
|
| 302 |
+
return h;
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
// --- Setup ---
|
| 306 |
+
function doSetup() {
|
| 307 |
+
const s = parseFloat(document.getElementById("inp-start").value);
|
| 308 |
+
const g = parseFloat(document.getElementById("inp-goal").value);
|
| 309 |
+
if (!s || !g || s <= g) return;
|
| 310 |
+
startWeight = s;
|
| 311 |
+
goalWeight = g;
|
| 312 |
+
saveSettings();
|
| 313 |
+
// Post initial weight
|
| 314 |
+
postEntry(s, {});
|
| 315 |
+
entries = [{ date: todayStr(), weight: s }];
|
| 316 |
+
showDashboard();
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
// --- Add entry ---
|
| 320 |
+
async function addEntry() {
|
| 321 |
+
const inp = document.getElementById("inp-weight");
|
| 322 |
+
const w = parseFloat(inp.value);
|
| 323 |
+
if (!w || w < 30 || w > 300) return;
|
| 324 |
+
|
| 325 |
+
const habits = getHabits();
|
| 326 |
+
const msgEl = document.getElementById("status-msg");
|
| 327 |
+
msgEl.textContent = "Enregistrement...";
|
| 328 |
+
msgEl.className = "status-msg";
|
| 329 |
+
|
| 330 |
+
const ok = await postEntry(w, habits);
|
| 331 |
+
if (ok) {
|
| 332 |
+
// Update local entries - replace today or add
|
| 333 |
+
const todayDate = todayStr();
|
| 334 |
+
const idx = entries.findIndex(e => e.date === todayDate);
|
| 335 |
+
if (idx >= 0) entries[idx].weight = w;
|
| 336 |
+
else entries.push({ date: todayDate, weight: w });
|
| 337 |
+
|
| 338 |
+
inp.value = "";
|
| 339 |
+
// Reset habit toggles
|
| 340 |
+
document.querySelectorAll(".habit-toggle").forEach(el => el.classList.remove("on"));
|
| 341 |
+
msgEl.textContent = "Enregistre !";
|
| 342 |
+
msgEl.className = "status-msg status-ok";
|
| 343 |
+
renderDashboard();
|
| 344 |
+
} else {
|
| 345 |
+
msgEl.textContent = "Erreur de connexion";
|
| 346 |
+
msgEl.className = "status-msg status-err";
|
| 347 |
+
}
|
| 348 |
+
setTimeout(() => { msgEl.textContent = ""; }, 3000);
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
// --- Render ---
|
| 352 |
+
function showPage(id) {
|
| 353 |
+
document.querySelectorAll(".page").forEach(p => p.classList.remove("active"));
|
| 354 |
+
document.getElementById(id).classList.add("active");
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
function showDashboard() {
|
| 358 |
+
showPage("dashboard");
|
| 359 |
+
renderDashboard();
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
function renderDashboard() {
|
| 363 |
+
const sorted = [...entries].sort((a, b) => a.date.localeCompare(b.date));
|
| 364 |
+
const latest = sorted[sorted.length - 1];
|
| 365 |
+
const current = latest ? latest.weight : startWeight;
|
| 366 |
+
const goal = goalWeight;
|
| 367 |
+
const start = startWeight;
|
| 368 |
+
const totalToLose = start - goal;
|
| 369 |
+
const alreadyLost = start - current;
|
| 370 |
+
const pct = totalToLose > 0 ? Math.min(100, Math.max(0, (alreadyLost / totalToLose) * 100)) : 0;
|
| 371 |
+
const toGo = Math.max(0, current - goal);
|
| 372 |
+
|
| 373 |
+
// Streak
|
| 374 |
+
let streak = 0;
|
| 375 |
+
if (sorted.length > 0) {
|
| 376 |
+
streak = 1;
|
| 377 |
+
let d = new Date(sorted[sorted.length - 1].date);
|
| 378 |
+
for (let i = sorted.length - 2; i >= 0; i--) {
|
| 379 |
+
const prev = new Date(sorted[i].date);
|
| 380 |
+
if ((d - prev) / 86400000 <= 1.5) { streak++; d = prev; } else break;
|
| 381 |
+
}
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
// Header
|
| 385 |
+
document.getElementById("hdr-date").textContent = fmtDate(todayStr());
|
| 386 |
+
const streakEl = document.getElementById("hdr-streak");
|
| 387 |
+
streakEl.textContent = streak + (streak >= 3 ? " \uD83D\uDD25" : "");
|
| 388 |
+
streakEl.style.color = streak >= 3 ? "#b8ff57" : "#fff";
|
| 389 |
+
|
| 390 |
+
// Stats
|
| 391 |
+
document.getElementById("stat-current").innerHTML = current.toFixed(1) + '<span class="unit">kg</span>';
|
| 392 |
+
document.getElementById("stat-goal").textContent = goal;
|
| 393 |
+
document.getElementById("stat-pct").textContent = pct.toFixed(0) + "%";
|
| 394 |
+
|
| 395 |
+
const circ = 2 * Math.PI * 38;
|
| 396 |
+
document.getElementById("ring").setAttribute("stroke-dashoffset", circ * (1 - pct / 100));
|
| 397 |
+
|
| 398 |
+
const lostEl = document.getElementById("stat-lost");
|
| 399 |
+
lostEl.textContent = alreadyLost.toFixed(1) + " kg";
|
| 400 |
+
lostEl.style.color = alreadyLost > 0 ? "#b8ff57" : "#fff";
|
| 401 |
+
|
| 402 |
+
const leftEl = document.getElementById("stat-left");
|
| 403 |
+
leftEl.textContent = toGo.toFixed(1) + " kg";
|
| 404 |
+
leftEl.style.color = toGo > 0 ? "#ff6b6b" : "#b8ff57";
|
| 405 |
+
|
| 406 |
+
document.getElementById("bar-fill").style.width = pct + "%";
|
| 407 |
+
|
| 408 |
+
// Chart
|
| 409 |
+
if (sorted.length >= 2) {
|
| 410 |
+
document.getElementById("chart-card").style.display = "block";
|
| 411 |
+
renderChart(sorted, goal);
|
| 412 |
+
} else {
|
| 413 |
+
document.getElementById("chart-card").style.display = "none";
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
// History
|
| 417 |
+
if (sorted.length > 0) {
|
| 418 |
+
document.getElementById("hist-card").style.display = "block";
|
| 419 |
+
const list = document.getElementById("hist-list");
|
| 420 |
+
list.innerHTML = "";
|
| 421 |
+
const rev = [...sorted].reverse().slice(0, 7);
|
| 422 |
+
rev.forEach((e, i) => {
|
| 423 |
+
const prev = sorted[sorted.length - 1 - i - 1];
|
| 424 |
+
const diff = prev ? (e.weight - prev.weight).toFixed(1) : null;
|
| 425 |
+
const row = document.createElement("div");
|
| 426 |
+
row.className = "hist-row";
|
| 427 |
+
let diffHtml = "";
|
| 428 |
+
if (diff !== null) {
|
| 429 |
+
const c = parseFloat(diff) < 0 ? "#b8ff57" : parseFloat(diff) > 0 ? "#ff6b6b" : "#666";
|
| 430 |
+
diffHtml = `<span class="hist-diff" style="color:${c}">${parseFloat(diff) > 0 ? "+" : ""}${diff} kg</span>`;
|
| 431 |
+
}
|
| 432 |
+
row.innerHTML = `
|
| 433 |
+
<span class="hist-date">${fmtDate(e.date)}</span>
|
| 434 |
+
<div style="display:flex;align-items:center;gap:12px">
|
| 435 |
+
${diffHtml}
|
| 436 |
+
<span class="hist-weight">${e.weight} <span class="unit">kg</span></span>
|
| 437 |
+
</div>`;
|
| 438 |
+
list.appendChild(row);
|
| 439 |
+
});
|
| 440 |
+
}
|
| 441 |
+
|
| 442 |
+
// Success
|
| 443 |
+
document.getElementById("success-banner").style.display = pct >= 100 ? "block" : "none";
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
function renderChart(sorted, goal) {
|
| 447 |
+
const labels = sorted.map(e => fmtDate(e.date));
|
| 448 |
+
const data = sorted.map(e => e.weight);
|
| 449 |
+
|
| 450 |
+
if (chart) chart.destroy();
|
| 451 |
+
const ctx = document.getElementById("chart").getContext("2d");
|
| 452 |
+
chart = new Chart(ctx, {
|
| 453 |
+
type: "line",
|
| 454 |
+
data: {
|
| 455 |
+
labels,
|
| 456 |
+
datasets: [
|
| 457 |
+
{
|
| 458 |
+
data,
|
| 459 |
+
borderColor: "#b8ff57",
|
| 460 |
+
backgroundColor: "rgba(184,255,87,0.08)",
|
| 461 |
+
borderWidth: 2.5,
|
| 462 |
+
pointRadius: 4,
|
| 463 |
+
pointBackgroundColor: "#b8ff57",
|
| 464 |
+
pointBorderWidth: 0,
|
| 465 |
+
tension: 0.3,
|
| 466 |
+
fill: true
|
| 467 |
+
}
|
| 468 |
+
]
|
| 469 |
+
},
|
| 470 |
+
options: {
|
| 471 |
+
responsive: true,
|
| 472 |
+
maintainAspectRatio: false,
|
| 473 |
+
plugins: {
|
| 474 |
+
legend: { display: false },
|
| 475 |
+
tooltip: {
|
| 476 |
+
backgroundColor: "#111",
|
| 477 |
+
borderColor: "#b8ff57",
|
| 478 |
+
borderWidth: 1,
|
| 479 |
+
titleColor: "#b8ff57",
|
| 480 |
+
bodyColor: "#fff",
|
| 481 |
+
callbacks: { label: ctx => ctx.parsed.y + " kg" }
|
| 482 |
+
},
|
| 483 |
+
annotation: goal ? {
|
| 484 |
+
annotations: {
|
| 485 |
+
goalLine: {
|
| 486 |
+
type: "line",
|
| 487 |
+
yMin: goal, yMax: goal,
|
| 488 |
+
borderColor: "rgba(184,255,87,0.4)",
|
| 489 |
+
borderDash: [4, 4],
|
| 490 |
+
borderWidth: 1
|
| 491 |
+
}
|
| 492 |
+
}
|
| 493 |
+
} : undefined
|
| 494 |
+
},
|
| 495 |
+
scales: {
|
| 496 |
+
x: { grid: { color: "#1a2030" }, ticks: { color: "#444", font: { size: 11 } } },
|
| 497 |
+
y: { grid: { color: "#1a2030" }, ticks: { color: "#444", font: { size: 11 } } }
|
| 498 |
+
}
|
| 499 |
+
}
|
| 500 |
+
});
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
// --- Reset ---
|
| 504 |
+
function resetApp() {
|
| 505 |
+
if (!confirm("Reinitialiser ? Les donnees Google Sheets ne seront pas supprimees.")) return;
|
| 506 |
+
localStorage.removeItem("tf_start");
|
| 507 |
+
localStorage.removeItem("tf_goal");
|
| 508 |
+
entries = [];
|
| 509 |
+
showPage("setup");
|
| 510 |
+
}
|
| 511 |
+
|
| 512 |
+
// --- Init ---
|
| 513 |
+
async function init() {
|
| 514 |
+
document.getElementById("loading").style.display = "flex";
|
| 515 |
+
loadSettings();
|
| 516 |
+
|
| 517 |
+
if (startWeight && goalWeight) {
|
| 518 |
+
await fetchEntries();
|
| 519 |
+
document.getElementById("loading").style.display = "none";
|
| 520 |
+
showDashboard();
|
| 521 |
+
} else {
|
| 522 |
+
document.getElementById("loading").style.display = "none";
|
| 523 |
+
showPage("setup");
|
| 524 |
+
}
|
| 525 |
+
}
|
| 526 |
+
|
| 527 |
+
// Enter key support
|
| 528 |
+
document.addEventListener("keydown", e => {
|
| 529 |
+
if (e.key === "Enter" && document.activeElement === document.getElementById("inp-weight")) {
|
| 530 |
+
addEntry();
|
| 531 |
+
}
|
| 532 |
+
});
|
| 533 |
+
|
| 534 |
+
init();
|
| 535 |
+
</script>
|
| 536 |
+
</body>
|
| 537 |
</html>
|