Bibliothèque consultable (lot 3a), arbitrages du lot 4
Écran #/bibliotheque : recherche, filtres zone, muscle, famille et matériel dans l'adresse (nav.set), fiche avec place dans le programme, exercices proches et « Demander à mon IA » ; exercices génériques. #import-json= devient un fragment réservé. Plan du lot 4 (WOD). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
25639639cc
commit
be3e820b88
+19
-3
@@ -6,8 +6,11 @@
|
||||
// les réécrit pas : main.js les lit (link.js, sync-model.js), puis remplace
|
||||
// l'adresse.
|
||||
//
|
||||
// Une adresse peut porter des paramètres après « ? » (#/connecter-ia?…, page
|
||||
// d'autorisation d'une IA) : seul cet écran les lit, les autres les ignorent.
|
||||
// Une adresse peut porter des paramètres après « ? » : l'état de navigation
|
||||
// (filtres, recherche) y vit, ADR 0009. L'écran qui les lit ignore ceux qu'il ne
|
||||
// connaît pas ; changer un filtre remplace l'adresse sans reconstruire l'écran
|
||||
// (nav.set). La page d'autorisation d'une IA (#/connecter-ia?…) reçoit sa requête
|
||||
// brute, à renvoyer telle quelle.
|
||||
|
||||
/**
|
||||
* @typedef {{name: "home"}
|
||||
@@ -26,12 +29,14 @@
|
||||
* | {name: "sync"}
|
||||
* | {name: "pair"}
|
||||
* | {name: "connect-ai", query: string}
|
||||
* | {name: "library", query: string}
|
||||
* | {name: "library-item", id: string, query: string}
|
||||
* | {name: "reserved"}
|
||||
* | {name: "not-found"}} Route
|
||||
*/
|
||||
|
||||
/** Fragments réservés à d'autres modules. */
|
||||
export const RESERVED = ["#import=", "#pair="];
|
||||
export const RESERVED = ["#import=", "#import-json=", "#pair="];
|
||||
|
||||
/**
|
||||
* Lit une adresse. Fonction pure, testée.
|
||||
@@ -55,6 +60,8 @@ export function parseRoute(hash) {
|
||||
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 (head === "connecter-ia" && parts.length === 1) return { name: "connect-ai", query };
|
||||
if (head === "bibliotheque" && parts.length === 1) return { name: "library", query };
|
||||
if (head === "bibliotheque" && parts.length === 2 && arg) return { name: "library-item", id: arg, query };
|
||||
if (parts.length === 1 && SIMPLE[head]) return /** @type {Route} */ ({ name: SIMPLE[head] });
|
||||
return { name: "not-found" };
|
||||
}
|
||||
@@ -84,6 +91,8 @@ export const href = {
|
||||
proposal: (/** @type {string} */ id) => "#/proposition/" + enc(id),
|
||||
sync: () => "#/synchro",
|
||||
pair: () => "#/relier",
|
||||
library: (/** @type {string} */ query = "") => "#/bibliotheque" + (query ? "?" + query : ""),
|
||||
libraryItem: (/** @type {string} */ id, /** @type {string} */ query = "") => "#/bibliotheque/" + enc(id) + (query ? "?" + query : ""),
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -97,6 +106,8 @@ export const href = {
|
||||
* @typedef {object} Navigation
|
||||
* @property {(hash: string, options?: {replace?: boolean}) => void} go
|
||||
* @property {(fallback?: string) => void} back retour dans l'app, ou vers fallback
|
||||
* @property {(hash: string) => void} set remplace l'adresse sans changer d'écran
|
||||
* (un filtre qui change : l'écran se repeint lui-même, garde focus et défilement)
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -119,6 +130,11 @@ export function startRouter(root, render) {
|
||||
show();
|
||||
} else location.hash = hash;
|
||||
},
|
||||
set(hash) {
|
||||
if (hash === location.hash) return;
|
||||
history.replaceState(null, "", hash);
|
||||
visited[visited.length - 1] = hash;
|
||||
},
|
||||
back(fallback = href.home()) {
|
||||
if (visited.length > 1) history.back();
|
||||
else nav.go(fallback, { replace: true });
|
||||
|
||||
Reference in New Issue
Block a user