Chaque section du lecteur finit par l'ordre de ses articles (inertie 2) : ses articles numérotés, son vote déplié, « Proposer un autre ordre » — une liste où l'on clique un article puis sa place, ses flèches, ou le clavier. Le titre du document (inertie 4) se vote et se propose sous le titre, « traduction à revoir » quand il a changé. Les deux sont dans la liste des propositions, le panier et la chaîne Ğ1 ; un nouvel article se propose dans une section, à sa fin. La liste du groupe compte les propositions ouvertes des modules. Restes mineurs : la participation ramenée se dit en deux temps (la mesure, puis ce que le groupe demande), les lignes « habituelle » des réglages resserrées, le sélecteur d'inertie se parcourt aux flèches (le cran actuel atteignable, jamais choisi), la marque « seed a minima » porte le vrai nombre de votes. Contrôles : C25 (ordre, dont la chaîne et le téléphone), C26 (titre), C27 (participation ramenée) ; C3, C17 (41 modules), C20 mis à jour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
// The order of the articles of a section, as a person proposes another one
|
|
// (Yvv, 2026-10-30: « une simple liste clipable »): click an article, then its
|
|
// new place — or move it with its arrows. The rules of the vote (who is in the
|
|
// order, an order completed at the end) are the server's (ADR 0009).
|
|
|
|
/** The article `chosen` takes the place of `target`; the others close up. */
|
|
export function place(list: string[], chosen: string, target: string): string[] {
|
|
const from = list.indexOf(chosen);
|
|
const to = list.indexOf(target);
|
|
if (from < 0 || to < 0 || from === to) return list;
|
|
const next = list.filter((id) => id !== chosen);
|
|
next.splice(to, 0, chosen);
|
|
return next;
|
|
}
|
|
|
|
/** One place up (-1) or down (1), never beyond the ends. */
|
|
export function step(list: string[], id: string, by: -1 | 1): string[] {
|
|
const from = list.indexOf(id);
|
|
const to = from + by;
|
|
if (from < 0 || to < 0 || to >= list.length) return list;
|
|
const target = list[to];
|
|
return target === undefined ? list : place(list, id, target);
|
|
}
|
|
|
|
export function sameOrder(a: string[], b: string[]): boolean {
|
|
return a.length === b.length && a.every((id, i) => b[i] === id);
|
|
}
|
|
|
|
/** The articles whose place changed from `before` to `after`. */
|
|
export function moved(before: string[], after: string[]): Set<string> {
|
|
return new Set(after.filter((id, i) => before[i] !== id));
|
|
}
|