- web: BookPage/ReaderPage enrichis, sauvegarde de progression lecteur - web: locators EPUB/PDF normalisés (+ tests), EpubReader/PdfReader ajustés - web: nginx et service worker ajustés - api: progress — corrections contrôleur/service Refs: #13
11 lines
471 B
TypeScript
11 lines
471 B
TypeScript
export function parsePdfPageLocator(locator?: string | null): number | null {
|
|
if (!locator?.startsWith("pdf:page:")) return null;
|
|
const value = Number(locator.split(":").at(-1));
|
|
return Number.isInteger(value) && value > 0 ? value : null;
|
|
}
|
|
|
|
export function pdfPagePercent(page: number, pages: number): number {
|
|
if (!Number.isFinite(page) || !Number.isFinite(pages) || pages < 1) return 0;
|
|
return Math.max(0, Math.min(100, Math.round((page / pages) * 100)));
|
|
}
|