Écrans branchés : planning du jour, semaine, activités, poids, données, profil, analyses, propositions avec aperçu, gamification
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
077f2dc58d
commit
41d5e44daa
+38
-7
@@ -3,13 +3,22 @@
|
||||
//
|
||||
// Les fragments #import= (lien d'une IA, ADR 0005 point 7) et #pair=
|
||||
// (appariement, lot 2) sont réservés : le routeur ne les interprète pas et ne
|
||||
// les réécrit pas. À brancher : link.js (#import=), appariement (#pair=).
|
||||
// les réécrit pas : main.js lit #import= (link.js) ; #pair= attend le lot 2.
|
||||
|
||||
/**
|
||||
* @typedef {{name: "home"}
|
||||
* | {name: "session", key: string}
|
||||
* | {name: "session", key: string, date: string|null}
|
||||
* | {name: "finish"}
|
||||
* | {name: "progress"}
|
||||
* | {name: "history"}
|
||||
* | {name: "history-edit", id: string}
|
||||
* | {name: "week"}
|
||||
* | {name: "activities"}
|
||||
* | {name: "weight"}
|
||||
* | {name: "data"}
|
||||
* | {name: "profile"}
|
||||
* | {name: "analysis", exercise: string|null}
|
||||
* | {name: "proposal", id: string}
|
||||
* | {name: "reserved"}
|
||||
* | {name: "not-found"}} Route
|
||||
*/
|
||||
@@ -29,18 +38,40 @@ export function parseRoute(hash) {
|
||||
const parts = path.split("/").map((p) => {
|
||||
try { return decodeURIComponent(p); } catch { return p; }
|
||||
});
|
||||
if (parts[0] === "seance" && parts.length === 2 && parts[1]) return { name: "session", key: parts[1] };
|
||||
if (parts[0] === "historique" && parts.length === 1) return { name: "history" };
|
||||
if (parts[0] === "historique" && parts.length === 2 && parts[1]) return { name: "history-edit", id: parts[1] };
|
||||
const [head, arg, extra] = parts;
|
||||
if (head === "seance" && arg && parts.length === 2) return { name: "session", key: arg, date: null };
|
||||
if (head === "seance" && arg && parts.length === 3 && /^\d{4}-\d{2}-\d{2}$/.test(extra)) return { name: "session", key: arg, date: extra };
|
||||
if (head === "historique" && parts.length === 2 && arg) return { name: "history-edit", id: arg };
|
||||
if (head === "analyses" && parts.length === 1) return { name: "analysis", exercise: null };
|
||||
if (head === "analyses" && parts.length === 2 && arg) return { name: "analysis", exercise: arg };
|
||||
if (head === "proposition" && parts.length === 2 && arg) return { name: "proposal", id: arg };
|
||||
if (parts.length === 1 && SIMPLE[head]) return /** @type {Route} */ ({ name: SIMPLE[head] });
|
||||
return { name: "not-found" };
|
||||
}
|
||||
|
||||
/** Écrans sans paramètre : adresse → nom. @type {Record<string, string>} */
|
||||
const SIMPLE = {
|
||||
bravo: "finish", progression: "progress", historique: "history", semaine: "week", activites: "activities",
|
||||
poids: "weight", donnees: "data", profil: "profile",
|
||||
};
|
||||
|
||||
const enc = encodeURIComponent;
|
||||
|
||||
/** Adresses, pour écrire les liens sans les recopier. */
|
||||
export const href = {
|
||||
home: () => "#/",
|
||||
session: (/** @type {string} */ key) => "#/seance/" + encodeURIComponent(key),
|
||||
session: (/** @type {string} */ key, /** @type {string|null} */ date = null) => "#/seance/" + enc(key) + (date ? "/" + date : ""),
|
||||
finish: () => "#/bravo",
|
||||
progress: () => "#/progression",
|
||||
history: () => "#/historique",
|
||||
historyEdit: (/** @type {string} */ id) => "#/historique/" + encodeURIComponent(id),
|
||||
historyEdit: (/** @type {string} */ id) => "#/historique/" + enc(id),
|
||||
week: () => "#/semaine",
|
||||
activities: () => "#/activites",
|
||||
weight: () => "#/poids",
|
||||
data: () => "#/donnees",
|
||||
profile: () => "#/profil",
|
||||
analysis: (/** @type {string|null} */ exercise = null) => "#/analyses" + (exercise ? "/" + enc(exercise) : ""),
|
||||
proposal: (/** @type {string} */ id) => "#/proposition/" + enc(id),
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user