WOD : séance à format, chrono et score (lot 4b, ADR 0010)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
d9604d43ec
commit
ee3f55a515
@@ -8,12 +8,14 @@ import { localDay, longDay, plural } from "../format.js";
|
||||
import { estimatedMinutes } from "../../domain/progression.js";
|
||||
import { actionBar, screenHeader } from "../layout.js";
|
||||
import { href } from "../router.js";
|
||||
import { buildSessionData, completion, createDraft, doneCount, draftMatches, draftTotals, replaceExercise, replaceQuery, setsInOrder, substituteItem } from "../session-draft.js";
|
||||
import { buildSessionData, completion, createDraft, doneCount, draftMatches, draftTotals, replaceExercise, replaceQuery, setsInOrder, substituteItem, wodMissing } from "../session-draft.js";
|
||||
import { clearDraft, loadDraft, saveDraft, takeReopen } from "../draft-storage.js";
|
||||
import { exerciseCard } from "../exercise-card.js";
|
||||
import { warmupCard, warmupSteps } from "../warmup-card.js";
|
||||
import { confirmDialog, toast } from "../feedback.js";
|
||||
import { comboLabel, recordFinish } from "../game.js";
|
||||
import { wodPanel } from "../wod-panel.js";
|
||||
import { formatLabel } from "../../domain/wod.js";
|
||||
|
||||
/**
|
||||
* @param {{store: import("../store.js").Store, key: string, date: string|null, nav: import("../router.js").Navigation, timer: import("../timer.js").Timer}} ctx
|
||||
@@ -45,6 +47,7 @@ export function sessionScreen({ store, key, date, nav, timer }) {
|
||||
const status = h("p", { class: "status", role: "alert" });
|
||||
const totalSets = draft.exercises.reduce((n, ex) => n + ex.sets, 0);
|
||||
const paintProgress = () => {
|
||||
if (draft.wod) return progress.replaceChildren(h("span", null, formatLabel(draft.wod.format)));
|
||||
const done = draft.exercises.reduce((n, ex) => n + doneCount(ex), 0);
|
||||
const combo = comboLabel(setsInOrder(draft));
|
||||
progress.replaceChildren(h("span", null, `${done}/${totalSets} séries`), combo ? h("span", { class: "combo" }, combo) : "");
|
||||
@@ -112,13 +115,22 @@ export function sessionScreen({ store, key, date, nav, timer }) {
|
||||
cards);
|
||||
});
|
||||
|
||||
// Séance WOD (ADR 0010) : un panneau à la place des cartes de séries.
|
||||
const wod = draft.wod ? wodPanel({ draft, session, store, onChange }) : null;
|
||||
|
||||
const finish = async () => {
|
||||
const c = completion(draft);
|
||||
if (c.doneSets === 0) {
|
||||
if (draft.wod) {
|
||||
const missing = wodMissing(draft.wod);
|
||||
if (missing) {
|
||||
status.textContent = missing;
|
||||
return;
|
||||
}
|
||||
} else if (c.doneSets === 0) {
|
||||
status.textContent = "Aucune série validée : rien à enregistrer.";
|
||||
return;
|
||||
}
|
||||
if (!c.complete) {
|
||||
if (!draft.wod && !c.complete) {
|
||||
const lines = [];
|
||||
if (c.missing.length)
|
||||
lines.push(`${plural(c.missing.length, "exercice")} pas commencé${c.missing.length > 1 ? "s" : ""} : ${c.missing.slice(0, 3).join(", ")}${c.missing.length > 3 ? "…" : "."}`);
|
||||
@@ -155,12 +167,14 @@ export function sessionScreen({ store, key, date, nav, timer }) {
|
||||
dateNotice,
|
||||
h("div", { class: "exercises" },
|
||||
warmup.steps.length > 0 && warmupCard({ plan: warmup, done: draft.warmup, timer, onChange, open: !resumed }),
|
||||
blocks),
|
||||
wod ? wod.node : blocks),
|
||||
status,
|
||||
h("p", { class: "foot" }, "Touche une série pour noter tes répétitions et ton ressenti : le repos démarre tout seul."),
|
||||
h("p", { class: "foot" }, wod
|
||||
? "Lance le chrono, suis les bips, puis note ton score : il restera dans ton historique."
|
||||
: "Touche une série pour noter tes répétitions et ton ressenti : le repos démarre tout seul."),
|
||||
actionBar(progress, h("button", { type: "button", class: "btn btn--primary btn--lg", on: { click: finish } }, "Terminer la séance")));
|
||||
setAccent(node, color, inkOn(color));
|
||||
paintProgress();
|
||||
|
||||
return { node, title: session.name, destroy: () => timer.stop() };
|
||||
return { node, title: session.name, destroy: () => { timer.stop(); wod?.destroy(); } };
|
||||
}
|
||||
|
||||
+54
-1
@@ -3,6 +3,7 @@
|
||||
// Module pur (sans DOM), testé dans tests/ui/session-draft.test.js.
|
||||
|
||||
import { resolveExercise, exerciseKey, trackingFor, targetSeconds } from "../domain/program.js";
|
||||
import { scoreLabel } from "../domain/wod.js";
|
||||
|
||||
/** @typedef {import("../domain/vocabulary.js").TrackingMode} TrackingMode */
|
||||
/** @typedef {import("../domain/events.js").LoggedSet} LoggedSet */
|
||||
@@ -36,6 +37,22 @@ import { resolveExercise, exerciseKey, trackingFor, targetSeconds } from "../dom
|
||||
* @property {string} date jour local AAAA-MM-JJ de la séance
|
||||
* @property {boolean[]} warmup étapes d'échauffement cochées
|
||||
* @property {DraftExercise[]} exercises
|
||||
* @property {DraftWod} [wod] séance WOD : horloge et score en cours (ADR 0010)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Le WOD en cours : l'horloge se cale sur l'heure (départ, et temps déjà couru
|
||||
* avant une pause), le score se remplit à la fin.
|
||||
* @typedef {object} DraftWod
|
||||
* @property {import("../domain/wod.js").WodFormat} format
|
||||
* @property {number|null} startedAt Date.now() au départ ou à la reprise ; null à l'arrêt
|
||||
* @property {number} banked secondes courues avant la pause
|
||||
* @property {boolean} rx
|
||||
* @property {number|null} seconds
|
||||
* @property {number|null} rounds
|
||||
* @property {number|null} reps
|
||||
* @property {number|null} kg
|
||||
* @property {boolean} capped
|
||||
*/
|
||||
|
||||
/** Durée par défaut d'une série au temps quand le programme n'en donne pas. */
|
||||
@@ -87,9 +104,35 @@ export function createDraft(session, state, date, warmupSteps) {
|
||||
date,
|
||||
warmup: Array(warmupSteps).fill(false),
|
||||
exercises: session.exercises.map((item) => draftExercise(session.key, item, state)),
|
||||
...(session.format ? { wod: emptyWod(session.format) } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
/** @param {import("../domain/wod.js").WodFormat} format @returns {DraftWod} */
|
||||
export function emptyWod(format) {
|
||||
return { format: structuredClone(format), startedAt: null, banked: 0, rx: true, seconds: null, rounds: null, reps: null, kg: null, capped: false };
|
||||
}
|
||||
|
||||
/**
|
||||
* Secondes courues par l'horloge du WOD à l'instant `now`.
|
||||
* @param {DraftWod} w @param {number} now Date.now()
|
||||
*/
|
||||
export function wodElapsed(w, now) {
|
||||
return w.banked + (w.startedAt === null ? 0 : Math.max(0, (now - w.startedAt) / 1000));
|
||||
}
|
||||
|
||||
/**
|
||||
* Le WOD est-il prêt à être enregistré ? Il faut un score qui a du sens pour le
|
||||
* format : un temps (ou le cap) pour un For Time, des tours pour un AMRAP.
|
||||
* @param {DraftWod} w
|
||||
* @returns {string|null} ce qui manque, ou null
|
||||
*/
|
||||
export function wodMissing(w) {
|
||||
if (w.format.type === "amrap" && w.rounds === null) return "Note le nombre de tours complets.";
|
||||
if (w.format.type === "fortime" && w.seconds === null && !w.capped) return "Note ton temps, ou coche « temps limite atteint ».";
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* L'exercice du programme, avec un autre exercice de la bibliothèque à sa place :
|
||||
* mêmes séries, répétitions, repos et superset ; le mode de suivi se déduit du
|
||||
@@ -157,6 +200,7 @@ export function draftMatches(draft, session, warmupSteps) {
|
||||
const d = /** @type {any} */ (draft);
|
||||
if (!d || d.sessionKey !== session.key || !Array.isArray(d.exercises) || !Array.isArray(d.warmup)) return false;
|
||||
if (d.exercises.length !== session.exercises.length) return false;
|
||||
if ((session.format?.type ?? null) !== (d.wod?.format?.type ?? null)) return false;
|
||||
const ok = session.exercises.every((item, i) => {
|
||||
const ex = resolveExercise(item);
|
||||
const x = d.exercises[i];
|
||||
@@ -280,12 +324,20 @@ export function buildSessionData(draft) {
|
||||
loadKg: usesLoad(ex.tracking) ? ex.loadKg : null,
|
||||
seconds: usesTime(ex.tracking) ? ex.seconds : null,
|
||||
plannedSets: ex.sets,
|
||||
sets: /** @type {LoggedSet[]} */ (ex.done.filter((s) => s !== null)).map((s) => ({ reps: s.reps, effort: s.effort })),
|
||||
// WOD : un mouvement fait compte pour une série, le score dit le reste.
|
||||
sets: draft.wod && doneCount(ex) === 0 ? [{ reps: null, effort: null }]
|
||||
: /** @type {LoggedSet[]} */ (ex.done.filter((s) => s !== null)).map((s) => ({ reps: s.reps, effort: s.effort })),
|
||||
...(ex.replaces ? { replaces: ex.replaces.id } : {}),
|
||||
})),
|
||||
...(draft.wod ? { wod: wodResult(draft.wod) } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
/** @param {DraftWod} w @returns {import("../domain/wod.js").WodResult} */
|
||||
function wodResult(w) {
|
||||
return { format: w.format, rx: w.rx, seconds: w.seconds, rounds: w.rounds, reps: w.reps, kg: w.kg, capped: w.format.type === "fortime" && w.capped };
|
||||
}
|
||||
|
||||
/**
|
||||
* Le contenu d'une séance enregistrée, sans ce que le repli ajoute (id,
|
||||
* loggedAt) : la base d'un SessionCorrected.
|
||||
@@ -305,5 +357,6 @@ export function sessionSummary(s) {
|
||||
const sets = s.exercises.reduce((n, x) => n + x.sets.length, 0);
|
||||
const done = s.exercises.filter((x) => x.sets.length > 0).length;
|
||||
if (s.kind !== "strength") return "";
|
||||
if (s.wod) return `WOD · ${scoreLabel(s.wod)}`;
|
||||
return `${done} exercice${done > 1 ? "s" : ""} · ${sets} série${sets > 1 ? "s" : ""}`;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,290 @@
|
||||
// Le panneau d'une séance WOD (lot 4b, ADR 0010) : le format, les mouvements,
|
||||
// le chrono (compte à rebours, intervalles, temps limite) et la saisie du score.
|
||||
// L'horloge se cale sur l'heure (draft.wod.startedAt) : elle reste juste si le
|
||||
// téléphone se met en veille, et reprend après un rechargement.
|
||||
// Calculs : domain/wod.js ; état : session-draft.js (DraftWod).
|
||||
|
||||
import { h, replace, vibrate } from "./dom.js";
|
||||
import { resolveExercise } from "../domain/program.js";
|
||||
import { clockText, currentMovement, formatHint, formatLabel, formatSeconds, parseClock, scoreFields, wodClock } from "../domain/wod.js";
|
||||
import { usesLoad, wodElapsed } from "./session-draft.js";
|
||||
import { kg, parseAmount } from "./format.js";
|
||||
import { confirmDialog } from "./feedback.js";
|
||||
|
||||
/** Compte à rebours avant le départ, en secondes. */
|
||||
const COUNTDOWN = 5;
|
||||
|
||||
/**
|
||||
* @param {{draft: import("./session-draft.js").Draft, session: import("../domain/program.js").ProgramSession,
|
||||
* store: import("./store.js").Store, onChange: () => void}} o
|
||||
* @returns {{node: HTMLElement, destroy: () => void}}
|
||||
*/
|
||||
export function wodPanel({ draft, session, store, onChange }) {
|
||||
const w = /** @type {import("./session-draft.js").DraftWod} */ (draft.wod);
|
||||
const format = w.format;
|
||||
const fields = scoreFields(format);
|
||||
const total = formatSeconds(format);
|
||||
|
||||
// ---- son et écran allumé ----------------------------------------------------------
|
||||
/** @type {AudioContext|null} */
|
||||
let audio = null;
|
||||
/** @param {number} freq @param {number} ms */
|
||||
const beep = (freq, ms) => {
|
||||
try {
|
||||
audio ??= new AudioContext();
|
||||
const osc = audio.createOscillator();
|
||||
const gain = audio.createGain();
|
||||
osc.frequency.value = freq;
|
||||
gain.gain.value = 0.2;
|
||||
osc.connect(gain).connect(audio.destination);
|
||||
osc.start();
|
||||
osc.stop(audio.currentTime + ms / 1000);
|
||||
} catch {
|
||||
// pas de son possible : la vibration et l'affichage suffisent
|
||||
}
|
||||
};
|
||||
/** @type {any} */
|
||||
let wakeLock = null;
|
||||
const keepAwake = async (on) => {
|
||||
try {
|
||||
if (on && !wakeLock && "wakeLock" in navigator) wakeLock = await /** @type {any} */ (navigator).wakeLock.request("screen");
|
||||
if (!on && wakeLock) { await wakeLock.release(); wakeLock = null; }
|
||||
} catch {
|
||||
wakeLock = null;
|
||||
}
|
||||
};
|
||||
|
||||
// ---- mouvements -------------------------------------------------------------------
|
||||
const moves = session.exercises.map((item, i) => {
|
||||
const ex = draft.exercises[i];
|
||||
const r = resolveExercise(item);
|
||||
const load = usesLoad(ex.tracking)
|
||||
? h("input", { class: "field__input", inputmode: "decimal", "aria-label": `Charge, ${r.name} (kg)`, value: ex.loadKg === null ? "" : kg(ex.loadKg) })
|
||||
: null;
|
||||
load?.addEventListener("change", () => {
|
||||
const v = parseAmount(load.value);
|
||||
ex.loadKg = typeof v === "number" && v > 0 ? v : null;
|
||||
if (ex.loadKg !== null && store.getState().workingLoads[ex.key]?.loadKg !== ex.loadKg)
|
||||
store.dispatch("WorkingLoadSet", { key: ex.key, loadKg: ex.loadKg });
|
||||
onChange();
|
||||
});
|
||||
return h("li", { class: "wod-move" },
|
||||
h("div", { class: "wod-move__main" },
|
||||
h("span", { class: "wod-move__reps num" }, item.reps),
|
||||
h("span", { class: "wod-move__name" }, r.name),
|
||||
load && h("span", { class: "wod-move__load" }, load, h("span", { "aria-hidden": "true" }, " kg"))),
|
||||
r.note && h("p", { class: "wod-move__note" }, r.note),
|
||||
(r.cues.length > 0 || r.tutorial) && h("details", { class: "wod-move__guide" },
|
||||
h("summary", null, "Le geste"),
|
||||
h("ul", { class: "cues" }, r.cues.map((c) => h("li", null, c))),
|
||||
h("a", { class: "btn btn--ghost btn--sm tutorial", href: r.tutorial, target: "_blank", rel: "noopener noreferrer" }, "Voir un tutoriel ↗")));
|
||||
});
|
||||
|
||||
// ---- chrono -----------------------------------------------------------------------
|
||||
const time = h("div", { class: "wod-clock__time num", "aria-hidden": "true" }, "0:00");
|
||||
const phase = h("div", { class: "wod-clock__phase" });
|
||||
const live = h("div", { class: "visually-hidden", role: "status", "aria-live": "polite" });
|
||||
const buttons = h("div", { class: "btn-row wod-clock__btns" });
|
||||
const clockBox = h("section", { class: "wod-clock", "aria-label": "Chrono du WOD" }, phase, time, live, buttons);
|
||||
|
||||
let last = { phase: "", round: /** @type {number|null} */ (null), remaining: /** @type {number|null} */ (null) };
|
||||
/** @type {ReturnType<typeof setInterval>|null} */
|
||||
let tick = null;
|
||||
|
||||
const running = () => w.startedAt !== null;
|
||||
const stopTicking = () => {
|
||||
if (tick) clearInterval(tick);
|
||||
tick = null;
|
||||
};
|
||||
|
||||
const start = () => {
|
||||
beep(660, 60); // débloque le son sur iOS, au geste de l'utilisateur
|
||||
w.startedAt = Date.now() + (w.banked === 0 ? COUNTDOWN * 1000 : 0);
|
||||
onChange();
|
||||
void keepAwake(true);
|
||||
run();
|
||||
};
|
||||
const pause = () => {
|
||||
w.banked = Math.max(0, wodElapsed(w, Date.now()));
|
||||
w.startedAt = null;
|
||||
onChange();
|
||||
void keepAwake(false);
|
||||
stopTicking();
|
||||
paint();
|
||||
};
|
||||
/** Arrêt du chrono : For Time et tours prennent le temps comme score. */
|
||||
const finishWod = () => {
|
||||
const elapsed = Math.round(Math.max(0, wodElapsed(w, Date.now())));
|
||||
pause();
|
||||
if (fields.seconds) {
|
||||
w.seconds = total !== null ? Math.min(elapsed, total) : elapsed;
|
||||
if (secondsInput) secondsInput.value = clockText(w.seconds);
|
||||
}
|
||||
onChange();
|
||||
paintScore();
|
||||
};
|
||||
const reset = async () => {
|
||||
if (w.banked > 0 || running()) {
|
||||
const ok = await confirmDialog({ title: "Remettre le chrono à zéro ?", lines: ["Le temps couru sera perdu."], confirm: "Remettre à zéro" });
|
||||
if (!ok) return;
|
||||
}
|
||||
w.startedAt = null;
|
||||
w.banked = 0;
|
||||
w.capped = false;
|
||||
onChange();
|
||||
void keepAwake(false);
|
||||
stopTicking();
|
||||
paint();
|
||||
};
|
||||
|
||||
const run = () => {
|
||||
stopTicking();
|
||||
tick = setInterval(paint, 200);
|
||||
paint();
|
||||
};
|
||||
|
||||
const paint = () => {
|
||||
const now = Date.now();
|
||||
const pre = w.startedAt !== null && w.startedAt > now ? Math.ceil((w.startedAt - now) / 1000) : 0;
|
||||
const c = wodClock(format, pre ? 0 : wodElapsed(w, now));
|
||||
const movement = currentMovement(c, moves.length);
|
||||
moves.forEach((m, i) => m.classList.toggle("wod-move--now", running() && !pre && i === movement));
|
||||
|
||||
if (pre) {
|
||||
time.textContent = String(pre);
|
||||
phase.textContent = "Prêt ?";
|
||||
if (last.remaining !== pre) beep(440, 80);
|
||||
last = { phase: "pre", round: null, remaining: pre };
|
||||
} else {
|
||||
// For Time et tours : on mesure un temps, le chrono monte. Sinon il descend.
|
||||
const up = format.type === "fortime" || format.type === "rounds";
|
||||
time.textContent = clockText(up || c.remaining === null ? c.elapsed : c.remaining);
|
||||
phase.textContent = phaseText(format, c);
|
||||
if (running()) {
|
||||
if (last.phase === "pre" || (last.phase && (c.phase !== last.phase || c.round !== last.round))) {
|
||||
beep(c.phase === "rest" ? 520 : 880, c.phase === "done" ? 900 : 250);
|
||||
vibrate(c.phase === "done" ? [400, 150, 400] : [200]);
|
||||
live.textContent = phase.textContent;
|
||||
} else if (c.remaining !== null && c.remaining <= 3 && c.remaining > 0 && c.remaining !== last.remaining) beep(660, 70);
|
||||
}
|
||||
last = { phase: c.phase, round: c.round, remaining: c.remaining };
|
||||
}
|
||||
clockBox.classList.toggle("wod-clock--rest", c.phase === "rest");
|
||||
clockBox.classList.toggle("wod-clock--done", c.phase === "done");
|
||||
|
||||
if (c.phase === "done" && running()) {
|
||||
// fin du format : For Time au cap, AMRAP, EMOM, Tabata terminés
|
||||
w.banked = /** @type {number} */ (total);
|
||||
w.startedAt = null;
|
||||
if (format.type === "fortime") { w.capped = true; w.seconds = null; }
|
||||
onChange();
|
||||
void keepAwake(false);
|
||||
stopTicking();
|
||||
paintScore();
|
||||
}
|
||||
paintButtons(c.phase === "done");
|
||||
};
|
||||
|
||||
const paintButtons = (/** @type {boolean} */ done) => {
|
||||
const btn = (/** @type {string} */ label, /** @type {() => void} */ fn, cls = "btn") => h("button", { type: "button", class: cls, on: { click: fn } }, label);
|
||||
replace(buttons,
|
||||
!done && !running() && btn(w.banked > 0 ? "Reprendre" : "Démarrer", start, "btn btn--primary btn--lg"),
|
||||
running() && btn("Pause", pause),
|
||||
running() && (format.type === "fortime" || format.type === "rounds") && btn("Fini !", finishWod, "btn btn--primary btn--lg"),
|
||||
(w.banked > 0 || running()) && btn("Zéro", () => void reset(), "btn btn--ghost"));
|
||||
};
|
||||
|
||||
// ---- score ------------------------------------------------------------------------
|
||||
/** @param {string} id @param {string} label @param {number|null} value @param {(v: number|null) => void} set */
|
||||
const numberField = (id, label, value, set) => {
|
||||
const input = h("input", { id, class: "field__input", inputmode: "numeric", value: value === null ? "" : String(value) });
|
||||
input.addEventListener("input", () => {
|
||||
const v = Number.parseInt(input.value, 10);
|
||||
set(Number.isInteger(v) && v >= 0 ? v : null);
|
||||
onChange();
|
||||
});
|
||||
return h("div", { class: "field" }, h("label", { class: "field__label", for: id }, label), input);
|
||||
};
|
||||
/** @type {HTMLInputElement|null} */
|
||||
let secondsInput = null;
|
||||
const score = h("div", { class: "wod-score" });
|
||||
const paintScore = () => {
|
||||
secondsInput = fields.seconds ? h("input", { id: "wod-time", class: "field__input", inputmode: "numeric", placeholder: "7:42", value: w.seconds === null ? "" : clockText(w.seconds) }) : null;
|
||||
secondsInput?.addEventListener("change", () => {
|
||||
const v = parseClock(/** @type {HTMLInputElement} */ (secondsInput).value);
|
||||
w.seconds = v;
|
||||
if (v !== null) w.capped = false;
|
||||
onChange();
|
||||
});
|
||||
const capped = format.type === "fortime" && format.capMinutes
|
||||
? h("input", { id: "wod-cap", type: "checkbox", checked: w.capped }) : null;
|
||||
capped?.addEventListener("change", () => {
|
||||
w.capped = /** @type {HTMLInputElement} */ (capped).checked;
|
||||
if (w.capped) w.seconds = null;
|
||||
onChange();
|
||||
paintScore();
|
||||
});
|
||||
const rx = (/** @type {boolean} */ value, /** @type {string} */ label) => h("button", {
|
||||
type: "button", class: "segmented__opt", "aria-pressed": String(w.rx === value),
|
||||
on: { click: () => { w.rx = value; onChange(); paintScore(); } },
|
||||
}, label);
|
||||
replace(score,
|
||||
h("h2", { class: "tape" }, "Score"),
|
||||
fields.seconds && !w.capped && h("div", { class: "field" }, h("label", { class: "field__label", for: "wod-time" }, "Temps (min:s)"), secondsInput),
|
||||
capped && h("label", { class: "check" }, capped, ` Temps limite atteint (${format.capMinutes} min)`),
|
||||
fields.rounds && numberField("wod-rounds", "Tours complets", w.rounds, (v) => { w.rounds = v; }),
|
||||
fields.reps && (format.type !== "fortime" || w.capped) && numberField("wod-reps",
|
||||
format.type === "amrap" ? "Répétitions en plus" : format.type === "fortime" ? "Répétitions faites au temps limite" : "Répétitions au total (facultatif)",
|
||||
w.reps, (v) => { w.reps = v; }),
|
||||
h("div", { class: "field" }, h("label", { class: "field__label", for: "wod-kg" }, "Charge principale (kg, facultatif)"),
|
||||
kgInput()),
|
||||
h("div", { class: "segmented", role: "group", "aria-label": "RX ou scaled" }, rx(true, "RX"), rx(false, "Scaled")));
|
||||
};
|
||||
const kgInput = () => {
|
||||
const input = h("input", { id: "wod-kg", class: "field__input", inputmode: "decimal", value: w.kg === null ? "" : kg(w.kg) });
|
||||
input.addEventListener("change", () => {
|
||||
const v = parseAmount(input.value);
|
||||
w.kg = typeof v === "number" && v > 0 ? v : null;
|
||||
onChange();
|
||||
});
|
||||
return input;
|
||||
};
|
||||
|
||||
paintScore();
|
||||
paint();
|
||||
if (running()) { void keepAwake(true); run(); }
|
||||
|
||||
const node = h("div", { class: "wod" },
|
||||
h("section", { class: "wod-format" },
|
||||
h("p", { class: "kicker" }, "WOD"),
|
||||
h("p", { class: "wod-format__label" }, formatLabel(format)),
|
||||
h("p", { class: "muted" }, formatHint(format))),
|
||||
h("ol", { class: "wod-moves" }, moves),
|
||||
clockBox,
|
||||
score);
|
||||
return {
|
||||
node,
|
||||
destroy: () => {
|
||||
stopTicking();
|
||||
void keepAwake(false);
|
||||
void audio?.close().catch(() => {});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Ce que montre l'horloge, en mots : « Temps restant », « Intervalle 3/10 »,
|
||||
* « Repos · tour 2/8 », « Chrono · cap 15 min ».
|
||||
* @param {import("../domain/wod.js").WodFormat} format
|
||||
* @param {import("../domain/wod.js").WodClock} c
|
||||
*/
|
||||
export function phaseText(format, c) {
|
||||
if (c.phase === "done") return "Terminé";
|
||||
switch (format.type) {
|
||||
case "amrap": return "Temps restant";
|
||||
case "emom": return `Intervalle ${c.round}/${c.rounds}`;
|
||||
case "tabata": return `${c.phase === "rest" ? "Repos" : "Effort"} · tour ${c.round}/${c.rounds}`;
|
||||
case "fortime": return format.capMinutes ? `Chrono · cap ${format.capMinutes} min` : "Chrono";
|
||||
default: return "Chrono";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user