@rgaa-audit/cli 0.0.0-stage → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +62 -2
- package/bin/rgaa-audit.js +141 -0
- package/bin/rgaa-fill-grid.js +75 -0
- package/package.json +49 -4
- package/src/aggregate.js +77 -0
- package/src/audit.js +836 -0
- package/src/browser.js +61 -0
- package/src/captures.js +75 -0
- package/src/html-validation.js +71 -0
- package/src/logger.js +18 -0
- package/src/page-prep.js +100 -0
- package/src/reporters/index.js +59 -0
- package/src/reporters/ods-grid.js +240 -0
- package/src/rules/index.js +144 -0
- package/src/shared.js +33 -0
- package/src/simulator.js +656 -0
- package/vendor/rgaa-criteria.js +139 -0
- package/vendor/rgaa-guide-fiches.js +296 -0
- package/vendor/rgaa-guide-page.js +441 -0
- package/vendor/rgaa-rules.js +2830 -0
- package/vendor/vulgarized-report-template.js +779 -0
|
@@ -0,0 +1,779 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
(function init(root, factory) {
|
|
4
|
+
if (typeof module === 'object' && module.exports) {
|
|
5
|
+
module.exports = factory();
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
root.RgaaSharedReport = factory();
|
|
9
|
+
})(typeof globalThis !== 'undefined' ? globalThis : this, function factory() {
|
|
10
|
+
function generateVulgarizedReport(report, opts) {
|
|
11
|
+
const options = opts || {};
|
|
12
|
+
const includeCliLink = options.includeCliLink !== false;
|
|
13
|
+
|
|
14
|
+
const safeReport = report || {};
|
|
15
|
+
const summary = summarizeCriteria(Array.isArray(safeReport.results) ? safeReport.results : []);
|
|
16
|
+
const top = buildTopPriorities(summary.byCriterion).slice(0, 5);
|
|
17
|
+
const score = safeReport.score || { taux: 0, nonConformes: 0, conformes: 0, aVerifier: 0, na: 0, total: 0 };
|
|
18
|
+
const positives = buildPositiveSignals(safeReport);
|
|
19
|
+
const encouragement = buildEncouragement(score);
|
|
20
|
+
const actionLevers = buildActionLevers(top, summary.byCriterion);
|
|
21
|
+
const transparencyBox = renderTransparency(safeReport);
|
|
22
|
+
const toCheck = renderToCheck(summary.byCriterion);
|
|
23
|
+
|
|
24
|
+
const cards = top.map((item) => `
|
|
25
|
+
<div class="card">
|
|
26
|
+
<div class="chip chip-${item.priority.toLowerCase()}">${item.priority}</div>
|
|
27
|
+
<h3>${esc(item.title)}</h3>
|
|
28
|
+
<p><strong>Constat :</strong> ${esc(item.issue)}</p>
|
|
29
|
+
<p><strong>Impact :</strong> ${esc(item.impact)}</p>
|
|
30
|
+
<p><strong>Action :</strong> ${esc(item.action)}</p>
|
|
31
|
+
<p class="meta">Critère RGAA ${esc(item.criterion)} · Effort ${esc(item.effort)}</p>
|
|
32
|
+
</div>
|
|
33
|
+
`).join('');
|
|
34
|
+
|
|
35
|
+
const avg = top.length ? Math.round(top.reduce((acc, item) => acc + effortToPoints(item.effort), 0) / top.length) : 0;
|
|
36
|
+
const effortLabel = avg <= 1 ? 'Faible' : avg === 2 ? 'Moyen' : 'Élevé';
|
|
37
|
+
|
|
38
|
+
const ods = safeReport.odsDownload || null;
|
|
39
|
+
const hasOds = Boolean(ods && ods.base64 && ods.fileName);
|
|
40
|
+
const newWindowHint = '<span class="sr-only"> (ouvre dans une nouvelle fenêtre)</span>';
|
|
41
|
+
|
|
42
|
+
// Les captures sont déjà dans la page : inutile de les dupliquer dans le JSON téléchargeable.
|
|
43
|
+
const { captures: _captures, ...reportForJson } = safeReport;
|
|
44
|
+
const reportDataScript = toInlineJson(reportForJson);
|
|
45
|
+
const odsDataScript = toInlineJson(hasOds ? ods : null);
|
|
46
|
+
|
|
47
|
+
return `<!DOCTYPE html>
|
|
48
|
+
<html lang="fr">
|
|
49
|
+
<head>
|
|
50
|
+
<meta charset="UTF-8">
|
|
51
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
52
|
+
<title>Rapport vulgarisé — ${esc(safeReport.title || safeReport.url || 'Audit RGAA')}</title>
|
|
53
|
+
<style>
|
|
54
|
+
:root {
|
|
55
|
+
--bg-1:#f5f8ff;
|
|
56
|
+
--bg-2:#eef8f3;
|
|
57
|
+
--panel:#ffffff;
|
|
58
|
+
--border:#d8e1ee;
|
|
59
|
+
--ink:#142033;
|
|
60
|
+
--muted:#4f5e74;
|
|
61
|
+
--brand:#0f4fbf;
|
|
62
|
+
--brand-dark:#0d3f97;
|
|
63
|
+
--ok-bg:#e6f5ee;
|
|
64
|
+
--ok-fg:#085a3a;
|
|
65
|
+
--warn-bg:#fff4df;
|
|
66
|
+
--warn-fg:#9b5d00;
|
|
67
|
+
--high-bg:#ffe5e6;
|
|
68
|
+
--high-fg:#9f1d1d;
|
|
69
|
+
--shadow:0 12px 28px rgba(15, 37, 74, 0.08);
|
|
70
|
+
}
|
|
71
|
+
body {
|
|
72
|
+
margin:0;
|
|
73
|
+
font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
|
|
74
|
+
line-height:1.5;
|
|
75
|
+
background:
|
|
76
|
+
radial-gradient(circle at 0 0, #dce9ff 0, transparent 42%),
|
|
77
|
+
radial-gradient(circle at 100% 15%, #d9f3e5 0, transparent 36%),
|
|
78
|
+
linear-gradient(180deg, var(--bg-1), var(--bg-2));
|
|
79
|
+
color:var(--ink);
|
|
80
|
+
}
|
|
81
|
+
.skip-link {
|
|
82
|
+
position:absolute;
|
|
83
|
+
left:8px;
|
|
84
|
+
top:8px;
|
|
85
|
+
transform:translateY(-140%);
|
|
86
|
+
padding:8px 12px;
|
|
87
|
+
border-radius:8px;
|
|
88
|
+
background:#0f4fbf;
|
|
89
|
+
color:#fff;
|
|
90
|
+
font-weight:700;
|
|
91
|
+
z-index:1000;
|
|
92
|
+
transition:transform .2s ease;
|
|
93
|
+
}
|
|
94
|
+
.skip-link:focus { transform:translateY(0); }
|
|
95
|
+
.wrap { max-width: 1020px; margin: 0 auto; padding: 28px 20px 40px; }
|
|
96
|
+
h1 { margin: 0 0 8px; font-size: 34px; line-height:1.1; letter-spacing:-0.02em; }
|
|
97
|
+
h2 { font-size: 24px; letter-spacing: -0.01em; }
|
|
98
|
+
.sub { color:var(--muted); margin-bottom:18px; overflow-wrap:anywhere; }
|
|
99
|
+
.hero {
|
|
100
|
+
background:linear-gradient(120deg, #11284f 0%, #0f4fbf 58%, #2f7fff 100%);
|
|
101
|
+
color:#fff;
|
|
102
|
+
border-radius:16px;
|
|
103
|
+
padding:18px 18px 16px;
|
|
104
|
+
margin-bottom:16px;
|
|
105
|
+
box-shadow:var(--shadow);
|
|
106
|
+
}
|
|
107
|
+
.hero p { margin:6px 0 0; color:#e9f0ff; }
|
|
108
|
+
.badge {
|
|
109
|
+
display:inline-block;
|
|
110
|
+
padding:5px 9px;
|
|
111
|
+
border-radius:999px;
|
|
112
|
+
background:rgba(255,255,255,0.16);
|
|
113
|
+
border:1px solid rgba(255,255,255,0.25);
|
|
114
|
+
font-size:12px;
|
|
115
|
+
font-weight:700;
|
|
116
|
+
}
|
|
117
|
+
.grid { display:grid; grid-template-columns: repeat(5, minmax(120px,1fr)); gap:12px; margin:18px 0 24px; }
|
|
118
|
+
.kpi { background:var(--panel); border:1px solid var(--border); border-radius:14px; padding:12px 14px; box-shadow:0 8px 18px rgba(15, 37, 74, 0.05); transition:transform .25s ease, box-shadow .25s ease; }
|
|
119
|
+
.kpi:hover { transform:translateY(-2px); box-shadow:0 14px 24px rgba(15, 37, 74, 0.09); }
|
|
120
|
+
.kpi .v { font-size:30px; font-weight:700; line-height:1.05; }
|
|
121
|
+
.kpi .l { font-size:12px; color:var(--muted); margin-top:4px; }
|
|
122
|
+
.box { background:var(--panel); border:1px solid var(--border); border-radius:14px; padding:14px; margin-bottom:16px; box-shadow:0 8px 18px rgba(15, 37, 74, 0.04); }
|
|
123
|
+
.cards { display:grid; grid-template-columns: repeat(auto-fit, minmax(280px,1fr)); gap:12px; }
|
|
124
|
+
.card { background:var(--panel); border:1px solid var(--border); border-radius:14px; padding:14px; box-shadow:0 8px 18px rgba(15, 37, 74, 0.04); transition:transform .25s ease, box-shadow .25s ease, border-color .25s ease; }
|
|
125
|
+
.card:hover { transform:translateY(-3px); box-shadow:0 18px 28px rgba(15, 37, 74, 0.1); border-color:#c6d7f0; }
|
|
126
|
+
.card p, .card li, .where, .where li { overflow-wrap:anywhere; word-break:break-word; }
|
|
127
|
+
.chip { display:inline-block; font-size:11px; font-weight:700; border-radius:999px; padding:4px 8px; margin-bottom:8px; }
|
|
128
|
+
.chip-p1 { background:var(--high-bg); color:var(--high-fg); }
|
|
129
|
+
.chip-p2 { background:var(--warn-bg); color:var(--warn-fg); }
|
|
130
|
+
.chip-p3 { background:#def3ff; color:#0b5470; }
|
|
131
|
+
.meta { font-size:12px; color:var(--muted); margin-top:8px; }
|
|
132
|
+
ul { margin: 8px 0 0 18px; }
|
|
133
|
+
li { margin: 4px 0; }
|
|
134
|
+
.tools { display:flex; flex-wrap:wrap; gap:10px; margin: 8px 0 14px; }
|
|
135
|
+
.btn { border:1px solid #bfd0eb; background:var(--panel); color:#19315a; border-radius:10px; padding:8px 12px; font-weight:700; cursor:pointer; text-decoration:none; transition:all .2s ease; }
|
|
136
|
+
.btn:hover { background:#eef4ff; border-color:#a8c1e8; transform:translateY(-1px); }
|
|
137
|
+
.btn:focus-visible, a:focus-visible, button:focus-visible { outline:3px solid #0f4fbf; outline-offset:2px; }
|
|
138
|
+
.criterion-block { border-top:1px solid var(--border); padding:8px 0; }
|
|
139
|
+
.criterion-block summary { cursor:pointer; line-height:1.5; }
|
|
140
|
+
.issues { list-style:none; padding:0; margin:8px 0 0; }
|
|
141
|
+
.issue { padding:8px 0 8px 12px; border-left:3px solid #d8e1ee; margin:6px 0; overflow-wrap:anywhere; }
|
|
142
|
+
.examples { margin:6px 0 0 18px; font-size:12px; }
|
|
143
|
+
.examples code { font-size:12px; }
|
|
144
|
+
code.snippet { color:var(--muted); }
|
|
145
|
+
.capture { margin:8px 0 0; }
|
|
146
|
+
.capture img { max-width:100%; height:auto; border:1px solid var(--border); border-radius:8px; }
|
|
147
|
+
.capture figcaption { font-size:12px; color:var(--muted); }
|
|
148
|
+
.where { margin-top:8px; font-size:13px; color:#334155; background:#f8fbff; border:1px solid #dfebfb; border-radius:10px; padding:8px; }
|
|
149
|
+
.hint { margin-top:8px; color:var(--muted); font-size:12px; }
|
|
150
|
+
.scope-note { margin:0 0 16px; padding-left:10px; border-left:3px solid var(--border); color:var(--muted); font-size:13px; line-height:1.5; }
|
|
151
|
+
.about { margin-top:24px; padding-top:12px; border-top:1px solid var(--border); color:var(--muted); font-size:12px; line-height:1.6; }
|
|
152
|
+
.about p { margin:0 0 6px; }
|
|
153
|
+
.intro-impact { font-size:16px; margin:0; }
|
|
154
|
+
.pillars { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; margin-top:12px; }
|
|
155
|
+
.pillar { background:#f8fbff; border:1px solid #dbe7f8; border-radius:10px; padding:10px; font-size:13px; }
|
|
156
|
+
.pillar strong { display:block; margin-bottom:3px; color:#17325f; }
|
|
157
|
+
.punchline { margin:10px 0 0; font-weight:700; color:#17325f; }
|
|
158
|
+
.resources a { margin-right:12px; }
|
|
159
|
+
.transparency-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(210px,1fr)); gap:10px; margin-top:10px; }
|
|
160
|
+
.transparency-item { border-radius:10px; padding:10px; border:1px solid #d8e4f8; background:#f6faff; transition:transform .2s ease, border-color .2s ease; }
|
|
161
|
+
.transparency-item:hover { transform:translateY(-2px); border-color:#bad0f2; }
|
|
162
|
+
.transparency-item strong { display:block; color:#16335f; margin-bottom:3px; }
|
|
163
|
+
.transparency-score { margin-top:10px; padding:10px; border-radius:10px; border:1px solid #dce7f8; background:#f9fbff; }
|
|
164
|
+
.sr-only {
|
|
165
|
+
position:absolute;
|
|
166
|
+
width:1px;
|
|
167
|
+
height:1px;
|
|
168
|
+
padding:0;
|
|
169
|
+
margin:-1px;
|
|
170
|
+
overflow:hidden;
|
|
171
|
+
clip:rect(0, 0, 0, 0);
|
|
172
|
+
white-space:nowrap;
|
|
173
|
+
border:0;
|
|
174
|
+
}
|
|
175
|
+
a { color:var(--brand); overflow-wrap:anywhere; word-break:normal; }
|
|
176
|
+
a:hover { color:var(--brand-dark); }
|
|
177
|
+
.reveal {
|
|
178
|
+
opacity:0;
|
|
179
|
+
transform:translateY(12px);
|
|
180
|
+
animation:fadeLift .55s ease forwards;
|
|
181
|
+
}
|
|
182
|
+
.delay-1 { animation-delay:.06s; }
|
|
183
|
+
.delay-2 { animation-delay:.12s; }
|
|
184
|
+
.delay-3 { animation-delay:.18s; }
|
|
185
|
+
.delay-4 { animation-delay:.24s; }
|
|
186
|
+
@keyframes fadeLift {
|
|
187
|
+
from { opacity:0; transform:translateY(12px); }
|
|
188
|
+
to { opacity:1; transform:translateY(0); }
|
|
189
|
+
}
|
|
190
|
+
@media (max-width: 900px) {
|
|
191
|
+
.grid { grid-template-columns: repeat(2, minmax(120px,1fr)); }
|
|
192
|
+
.pillars { grid-template-columns:1fr; }
|
|
193
|
+
h1 { font-size:30px; }
|
|
194
|
+
}
|
|
195
|
+
@media (max-width: 520px) {
|
|
196
|
+
.grid { grid-template-columns: 1fr; }
|
|
197
|
+
h1 { font-size:28px; }
|
|
198
|
+
.hero { padding:14px; }
|
|
199
|
+
}
|
|
200
|
+
@media print {
|
|
201
|
+
.tools { display:none; }
|
|
202
|
+
body { background:#fff; }
|
|
203
|
+
.wrap { max-width: none; }
|
|
204
|
+
.box, .kpi, .card { break-inside: avoid; }
|
|
205
|
+
}
|
|
206
|
+
@media (prefers-reduced-motion: reduce) {
|
|
207
|
+
* { animation:none !important; transition:none !important; }
|
|
208
|
+
.reveal { opacity:1; transform:none; }
|
|
209
|
+
}
|
|
210
|
+
</style>
|
|
211
|
+
</head>
|
|
212
|
+
<body>
|
|
213
|
+
<a href="#main-content" class="skip-link">Aller au contenu principal</a>
|
|
214
|
+
<main id="main-content" class="wrap" tabindex="-1">
|
|
215
|
+
<div class="hero reveal">
|
|
216
|
+
<span class="badge">Pré-audit RGAA vulgarisé</span>
|
|
217
|
+
<h1>Votre accessibilité, en version claire et actionnable</h1>
|
|
218
|
+
<p class="intro-impact">En moins de 3 minutes, vous savez quoi corriger d’abord pour débloquer le plus d’utilisateurs.</p>
|
|
219
|
+
</div>
|
|
220
|
+
<div class="sub reveal delay-1">${esc(safeReport.title || safeReport.url || '')} · ${new Date(safeReport.timestamp || Date.now()).toLocaleString('fr-FR')}</div>
|
|
221
|
+
<p class="scope-note reveal delay-1">Pré-audit automatique selon le RGAA 4.1.2 : un point de départ pour prioriser les corrections. La conformité se confirme ensuite par un audit humain.</p>
|
|
222
|
+
|
|
223
|
+
<div class="tools reveal delay-2">
|
|
224
|
+
<button type="button" class="btn" id="btnDownloadHtml">Télécharger HTML</button>
|
|
225
|
+
<button type="button" class="btn" id="btnExportPdf">Exporter PDF</button>
|
|
226
|
+
<button type="button" class="btn" id="btnDownloadJson">Télécharger JSON</button>
|
|
227
|
+
${hasOds ? '<button type="button" class="btn" id="btnDownloadOds">Télécharger ODS</button>' : ''}
|
|
228
|
+
${hasOds ? `<a class="btn" href="https://products.aspose.app/cells/fr/viewer/ods" target="_blank" rel="noopener noreferrer">Lire ODS en ligne${newWindowHint}</a>` : ''}
|
|
229
|
+
${includeCliLink ? `<a class="btn" href="https://stan69000.github.io/rgaa-audit/" target="_blank" rel="noopener noreferrer">Site du projet RGAA Audit${newWindowHint}</a>` : ''}
|
|
230
|
+
<a class="btn" href="https://lesingedunumerique.fr/" target="_blank" rel="noopener noreferrer">Le Singe Du Numérique${newWindowHint}</a>
|
|
231
|
+
</div>
|
|
232
|
+
${!hasOds ? '<div class="hint">ODS non disponible dans ce rapport.</div>' : ''}
|
|
233
|
+
|
|
234
|
+
<div class="grid reveal delay-2">
|
|
235
|
+
<div class="kpi"><div class="v">${score.taux}%</div><div class="l">Score technique auto</div></div>
|
|
236
|
+
<div class="kpi"><div class="v">${score.nonConformes}</div><div class="l">Critères non conformes</div></div>
|
|
237
|
+
<div class="kpi"><div class="v">${score.aVerifier || 0}</div><div class="l">Critères à vérifier</div></div>
|
|
238
|
+
<div class="kpi"><div class="v">${score.conformes}</div><div class="l">Critères conformes</div></div>
|
|
239
|
+
<div class="kpi"><div class="v">${effortLabel}</div><div class="l">Effort moyen estimé</div></div>
|
|
240
|
+
</div>
|
|
241
|
+
|
|
242
|
+
<div class="box reveal delay-3">
|
|
243
|
+
<strong>Lecture rapide</strong>
|
|
244
|
+
<ul>
|
|
245
|
+
<li>Ce rapport montre où des personnes peuvent être bloquées dès maintenant.</li>
|
|
246
|
+
<li>Le score ne compte que les critères tranchés automatiquement (conformes ou non conformes) : il mesure une progression, il ne certifie pas une conformité RGAA.</li>
|
|
247
|
+
<li>Les critères « à vérifier » signalent des indices à confirmer par une personne ; ils n’entrent pas dans le score.</li>
|
|
248
|
+
<li>Les priorités P1 sont les corrections qui ont le plus d’impact utilisateur immédiat.</li>
|
|
249
|
+
<li>La validation finale reste humaine, surtout sur la compréhension et le sens des contenus.</li>
|
|
250
|
+
</ul>
|
|
251
|
+
<div class="pillars">
|
|
252
|
+
<div class="pillar"><strong>P1</strong>Blocages forts. À corriger en premier.</div>
|
|
253
|
+
<div class="pillar"><strong>P2</strong>Gêne réelle. À traiter juste après.</div>
|
|
254
|
+
<div class="pillar"><strong>P3</strong>Amélioration utile. À planifier ensuite.</div>
|
|
255
|
+
</div>
|
|
256
|
+
<p class="punchline">Logique recommandée: P1 d’abord, puis stabilisation P2/P3.</p>
|
|
257
|
+
</div>
|
|
258
|
+
${transparencyBox}
|
|
259
|
+
|
|
260
|
+
<div class="box">
|
|
261
|
+
<strong>Ce qui fonctionne déjà</strong>
|
|
262
|
+
<ul>
|
|
263
|
+
${positives.map((item) => `<li>${esc(item)}</li>`).join('')}
|
|
264
|
+
</ul>
|
|
265
|
+
<p style="margin-top:10px;color:#334155;"><strong>${esc(encouragement)}</strong></p>
|
|
266
|
+
</div>
|
|
267
|
+
|
|
268
|
+
<h2>Top priorités</h2>
|
|
269
|
+
<div class="cards">
|
|
270
|
+
${cards || '<div class="card"><h3>Aucun point prioritaire détecté</h3><p>Aucun critère non conforme n’a été détecté automatiquement sur cet échantillon.</p></div>'}
|
|
271
|
+
</div>
|
|
272
|
+
|
|
273
|
+
${toCheck}
|
|
274
|
+
|
|
275
|
+
<h2 style="margin-top:16px;">Leviers actionnables</h2>
|
|
276
|
+
<div class="cards">
|
|
277
|
+
${actionLevers || '<div class="card"><h3>Aucun levier critique détecté</h3><p>Les points non conformes sont mineurs ou absents sur cet échantillon.</p></div>'}
|
|
278
|
+
</div>
|
|
279
|
+
|
|
280
|
+
${renderTemplateIssues(safeReport)}
|
|
281
|
+
${renderAllIssues(summary.byCriterion, safeReport)}
|
|
282
|
+
${renderVulgarizedPages(safeReport)}
|
|
283
|
+
${renderVulgarizedSkippedPages(safeReport)}
|
|
284
|
+
|
|
285
|
+
<div class="box" style="margin-top:16px;">
|
|
286
|
+
<strong>Ce qui reste à vérifier manuellement</strong>
|
|
287
|
+
<ul>
|
|
288
|
+
<li>Pertinence rédactionnelle des alternatives (images, liens, formulaires).</li>
|
|
289
|
+
<li>Tests lecteurs d’écran et cohérence de parcours sur des scénarios réels.</li>
|
|
290
|
+
<li>Vérification des contenus/processus non couverts automatiquement.</li>
|
|
291
|
+
</ul>
|
|
292
|
+
</div>
|
|
293
|
+
<div class="box resources reveal delay-4">
|
|
294
|
+
<strong>Ressources utiles</strong>
|
|
295
|
+
<p><a href="https://stan69000.github.io/rgaa-audit/" target="_blank" rel="noopener noreferrer">Site du projet${newWindowHint}</a></p>
|
|
296
|
+
<p><a href="https://lesingedunumerique.fr/" target="_blank" rel="noopener noreferrer">Site de l'association${newWindowHint}</a></p>
|
|
297
|
+
<p><a href="https://stan-bouchet.com/" target="_blank" rel="noopener noreferrer">Le créateur${newWindowHint}</a></p>
|
|
298
|
+
</div>
|
|
299
|
+
<footer class="about">
|
|
300
|
+
<p><strong>À propos de ce rapport.</strong> Il est produit par RGAA Audit, un outil libre développé par Le Singe Du Numérique, association qui œuvre pour un numérique accessible au plus grand nombre.</p>
|
|
301
|
+
<p>Les contrôles automatiques couvrent une partie du référentiel et certains résultats méritent d’être nuancés au regard du contexte. Ce document aide à agir ; il ne vaut pas déclaration de conformité.</p>
|
|
302
|
+
</footer>
|
|
303
|
+
</main>
|
|
304
|
+
|
|
305
|
+
<script>
|
|
306
|
+
const REPORT_DATA = ${reportDataScript};
|
|
307
|
+
const ODS_DOWNLOAD = ${odsDataScript};
|
|
308
|
+
|
|
309
|
+
const btnHtml = document.getElementById('btnDownloadHtml');
|
|
310
|
+
const btnPdf = document.getElementById('btnExportPdf');
|
|
311
|
+
const btnJson = document.getElementById('btnDownloadJson');
|
|
312
|
+
const btnOds = document.getElementById('btnDownloadOds');
|
|
313
|
+
|
|
314
|
+
if (btnHtml) btnHtml.addEventListener('click', downloadHtmlReport);
|
|
315
|
+
if (btnPdf) btnPdf.addEventListener('click', () => window.print());
|
|
316
|
+
if (btnJson) btnJson.addEventListener('click', downloadJson);
|
|
317
|
+
if (btnOds) btnOds.addEventListener('click', downloadOdsReport);
|
|
318
|
+
|
|
319
|
+
function downloadHtmlReport() {
|
|
320
|
+
const html = '<!DOCTYPE html>\\n' + document.documentElement.outerHTML;
|
|
321
|
+
const blob = new Blob([html], { type: 'text/html;charset=utf-8' });
|
|
322
|
+
const url = URL.createObjectURL(blob);
|
|
323
|
+
const a = document.createElement('a');
|
|
324
|
+
a.href = url;
|
|
325
|
+
a.download = 'rapport-vulgarise.html';
|
|
326
|
+
document.body.appendChild(a);
|
|
327
|
+
a.click();
|
|
328
|
+
a.remove();
|
|
329
|
+
URL.revokeObjectURL(url);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function downloadJson() {
|
|
333
|
+
const blob = new Blob([JSON.stringify(REPORT_DATA, null, 2)], { type: 'application/json' });
|
|
334
|
+
const url = URL.createObjectURL(blob);
|
|
335
|
+
const a = document.createElement('a');
|
|
336
|
+
a.href = url;
|
|
337
|
+
a.download = 'rgaa-audit.json';
|
|
338
|
+
document.body.appendChild(a);
|
|
339
|
+
a.click();
|
|
340
|
+
a.remove();
|
|
341
|
+
URL.revokeObjectURL(url);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function downloadOdsReport() {
|
|
345
|
+
if (!ODS_DOWNLOAD || !ODS_DOWNLOAD.base64) return;
|
|
346
|
+
const bin = atob(ODS_DOWNLOAD.base64);
|
|
347
|
+
const bytes = new Uint8Array(bin.length);
|
|
348
|
+
for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
|
|
349
|
+
const blob = new Blob([bytes], { type: ODS_DOWNLOAD.mimeType || 'application/vnd.oasis.opendocument.spreadsheet' });
|
|
350
|
+
const url = URL.createObjectURL(blob);
|
|
351
|
+
const a = document.createElement('a');
|
|
352
|
+
a.href = url;
|
|
353
|
+
a.download = ODS_DOWNLOAD.fileName || 'rgaa-grille.ods';
|
|
354
|
+
document.body.appendChild(a);
|
|
355
|
+
a.click();
|
|
356
|
+
a.remove();
|
|
357
|
+
URL.revokeObjectURL(url);
|
|
358
|
+
}
|
|
359
|
+
</script>
|
|
360
|
+
</body>
|
|
361
|
+
</html>`;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function summarizeCriteria(results) {
|
|
365
|
+
const byCriterion = new Map();
|
|
366
|
+
for (const item of results) {
|
|
367
|
+
if (!item || !item.id) continue;
|
|
368
|
+
if (!byCriterion.has(item.id)) byCriterion.set(item.id, []);
|
|
369
|
+
byCriterion.get(item.id).push(item);
|
|
370
|
+
}
|
|
371
|
+
return { byCriterion };
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function buildTopPriorities(byCriterion) {
|
|
375
|
+
const priorities = [];
|
|
376
|
+
for (const [criterion, items] of byCriterion.entries()) {
|
|
377
|
+
const statuses = items.map((i) => i.status);
|
|
378
|
+
if (!statuses.includes('NC')) continue;
|
|
379
|
+
const ncItems = items.filter((i) => i.status === 'NC');
|
|
380
|
+
const firstMessage = ncItems[0]?.message || 'Non-conformité détectée';
|
|
381
|
+
const occurrences = ncItems.reduce((acc, i) => acc + (Number(i.count) || 1), 0);
|
|
382
|
+
priorities.push({ ...enrichPriority(criterion, firstMessage), occurrences });
|
|
383
|
+
}
|
|
384
|
+
return priorities.sort((a, b) => priorityScore(b.priority) - priorityScore(a.priority) || b.occurrences - a.occurrences);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function enrichPriority(criterion, issue) {
|
|
388
|
+
const key = String(criterion || '').split('.')[0];
|
|
389
|
+
const fallback = {
|
|
390
|
+
title: 'Accessibilité à améliorer',
|
|
391
|
+
impact: 'Certaines personnes peuvent avoir des difficultés à utiliser la page.',
|
|
392
|
+
action: 'Corriger la non-conformité signalée puis valider sur parcours clavier.',
|
|
393
|
+
priority: 'P2',
|
|
394
|
+
effort: 'M',
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
const map = {
|
|
398
|
+
'3': {
|
|
399
|
+
title: 'Lisibilité insuffisante (contrastes)',
|
|
400
|
+
impact: 'Les personnes malvoyantes lisent difficilement le contenu.',
|
|
401
|
+
action: 'Augmenter les contrastes texte/fond pour atteindre les seuils RGAA.',
|
|
402
|
+
priority: 'P1',
|
|
403
|
+
effort: 'M',
|
|
404
|
+
},
|
|
405
|
+
'10': {
|
|
406
|
+
title: 'Mise en page fragile au zoom',
|
|
407
|
+
impact: 'Le contenu devient difficile à lire/atteindre à fort agrandissement.',
|
|
408
|
+
action: 'Supprimer les largeurs fixes et rendre les blocs fluides.',
|
|
409
|
+
priority: 'P1',
|
|
410
|
+
effort: 'M',
|
|
411
|
+
},
|
|
412
|
+
'11': {
|
|
413
|
+
title: 'Formulaire insuffisamment accessible',
|
|
414
|
+
impact: 'Saisie difficile pour clavier/lecteurs d’écran.',
|
|
415
|
+
action: 'Associer chaque champ à une étiquette explicite et un focus visible.',
|
|
416
|
+
priority: 'P1',
|
|
417
|
+
effort: 'M',
|
|
418
|
+
},
|
|
419
|
+
'12': {
|
|
420
|
+
title: 'Navigation clavier imparfaite',
|
|
421
|
+
impact: 'Les utilisateurs clavier perdent du temps ou restent bloqués.',
|
|
422
|
+
action: 'Garantir un ordre de tabulation cohérent et des liens d’évitement fonctionnels.',
|
|
423
|
+
priority: 'P1',
|
|
424
|
+
effort: 'S',
|
|
425
|
+
},
|
|
426
|
+
'6': {
|
|
427
|
+
title: 'Liens incompréhensibles',
|
|
428
|
+
impact: 'Un lien sans intitulé clair est annoncé « lien » sans indiquer où il mène.',
|
|
429
|
+
action: 'Donner à chaque lien un intitulé qui décrit sa destination.',
|
|
430
|
+
priority: 'P1',
|
|
431
|
+
effort: 'S',
|
|
432
|
+
},
|
|
433
|
+
'7': {
|
|
434
|
+
title: 'Composants interactifs mal codés',
|
|
435
|
+
impact: 'Menus, onglets ou boutons personnalisés sont inutilisables au clavier ou au lecteur d’écran.',
|
|
436
|
+
action: 'Préférer les éléments HTML natifs, sinon corriger rôles, états et gestion clavier.',
|
|
437
|
+
priority: 'P1',
|
|
438
|
+
effort: 'M',
|
|
439
|
+
},
|
|
440
|
+
'8': {
|
|
441
|
+
title: 'Éléments obligatoires manquants',
|
|
442
|
+
impact: 'Langue, titre ou validité du code mal définis perturbent les aides techniques.',
|
|
443
|
+
action: 'Corriger la langue, le titre de page et les identifiants en double.',
|
|
444
|
+
priority: 'P2',
|
|
445
|
+
effort: 'S',
|
|
446
|
+
},
|
|
447
|
+
'9': {
|
|
448
|
+
title: 'Structure de page peu lisible',
|
|
449
|
+
impact: 'Sans titres ni zones balisées, la navigation rapide au lecteur d’écran devient impossible.',
|
|
450
|
+
action: 'Baliser titres, listes et zones (header, nav, main, footer).',
|
|
451
|
+
priority: 'P2',
|
|
452
|
+
effort: 'S',
|
|
453
|
+
},
|
|
454
|
+
'13': {
|
|
455
|
+
title: 'Consultation perturbée',
|
|
456
|
+
impact: 'Redirections, rafraîchissements ou animations non contrôlables gênent la lecture.',
|
|
457
|
+
action: 'Laisser l’utilisateur maître du temps et des mouvements.',
|
|
458
|
+
priority: 'P2',
|
|
459
|
+
effort: 'S',
|
|
460
|
+
},
|
|
461
|
+
'1': {
|
|
462
|
+
title: 'Images non accessibles',
|
|
463
|
+
impact: 'Les personnes aveugles ne perçoivent pas l’information portée par les images.',
|
|
464
|
+
action: 'Ajouter des alternatives textuelles pertinentes.',
|
|
465
|
+
priority: 'P2',
|
|
466
|
+
effort: 'S',
|
|
467
|
+
},
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
const preset = map[key] || fallback;
|
|
471
|
+
return { criterion, issue, ...preset };
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function priorityScore(priority) {
|
|
475
|
+
if (priority === 'P1') return 3;
|
|
476
|
+
if (priority === 'P2') return 2;
|
|
477
|
+
return 1;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
function effortToPoints(effort) {
|
|
481
|
+
if (effort === 'S') return 1;
|
|
482
|
+
if (effort === 'M') return 2;
|
|
483
|
+
return 3;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
function buildPositiveSignals(report) {
|
|
487
|
+
const score = report.score || {};
|
|
488
|
+
const positives = [];
|
|
489
|
+
|
|
490
|
+
const decided = Number(score.conformes || 0) + Number(score.nonConformes || 0);
|
|
491
|
+
if (typeof score.conformes === 'number' && decided > 0) {
|
|
492
|
+
positives.push(`${score.conformes} critère(s) conforme(s) sur ${decided} critère(s) tranché(s) automatiquement.`);
|
|
493
|
+
}
|
|
494
|
+
if (typeof score.na === 'number' && score.na > 0) {
|
|
495
|
+
positives.push(`${score.na} critères sont non applicables sur cette page (pas de faux signal à corriger).`);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
const simulation = report.simulation || {};
|
|
499
|
+
if (typeof simulation.c === 'number' && simulation.c > 0) {
|
|
500
|
+
positives.push(`${simulation.c} vérifications utilisateur (clavier, responsive, CSS) sont passées.`);
|
|
501
|
+
}
|
|
502
|
+
const focusOk = (Array.isArray(report.results) ? report.results : [])
|
|
503
|
+
.some((r) => r && r.source === 'simulation' && r.id === '10.7' && r.status === 'C');
|
|
504
|
+
if (focusOk && simulation.focusElementsTested > 0) {
|
|
505
|
+
positives.push(`Le focus clavier est visible sur les ${simulation.focusElementsTested} éléments parcourus.`);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
if (!positives.length) {
|
|
509
|
+
positives.push('Aucun signal positif automatique disponible, mais la base est prête pour progresser rapidement.');
|
|
510
|
+
}
|
|
511
|
+
return positives;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function buildEncouragement(score) {
|
|
515
|
+
const taux = Number(score?.taux || 0);
|
|
516
|
+
if (taux >= 90) return 'Très bonne base: quelques ajustements ciblés suffisent pour consolider un niveau déjà élevé.';
|
|
517
|
+
if (taux >= 75) return 'Bonne dynamique: en traitant les points P1 d’abord, le service peut monter rapidement en qualité d’accès.';
|
|
518
|
+
if (taux >= 50) return 'Base exploitable: prioriser les blocages majeurs donnera des gains utilisateurs visibles.';
|
|
519
|
+
return 'Point de départ clair: en corrigeant les priorités critiques, l’amélioration sera rapidement perceptible.';
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
function buildActionLevers(top, byCriterion) {
|
|
523
|
+
return top.map((item) => {
|
|
524
|
+
const ncItems = (byCriterion.get(item.criterion) || []).filter((i) => i.status === 'NC');
|
|
525
|
+
const where = ncItems.map((entry) => describeWhereToFix(entry)).filter(Boolean).slice(0, 3);
|
|
526
|
+
const fixes = where.length
|
|
527
|
+
? where.map((line) => `<li>${esc(line)}</li>`).join('')
|
|
528
|
+
: '<li>Emplacement précis non fourni: reprendre le message de constat et inspecter les composants liés.</li>';
|
|
529
|
+
|
|
530
|
+
return `
|
|
531
|
+
<div class="card">
|
|
532
|
+
<div class="chip chip-${item.priority.toLowerCase()}">${item.priority}</div>
|
|
533
|
+
<h3>${esc(item.title)}</h3>
|
|
534
|
+
<p><strong>Levier :</strong> ${esc(item.action)}</p>
|
|
535
|
+
<p><strong>Résultat attendu :</strong> ${esc(item.impact)}</p>
|
|
536
|
+
<p class="meta">Critère RGAA ${esc(item.criterion)} · Effort ${esc(item.effort)}</p>
|
|
537
|
+
<div class="where">
|
|
538
|
+
<strong>Où corriger :</strong>
|
|
539
|
+
<ul>${fixes}</ul>
|
|
540
|
+
</div>
|
|
541
|
+
</div>
|
|
542
|
+
`;
|
|
543
|
+
}).join('');
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
function describeWhereToFix(entry) {
|
|
547
|
+
const source = entry?.source || 'dom';
|
|
548
|
+
const message = entry?.message || 'non-conformité détectée';
|
|
549
|
+
|
|
550
|
+
if (source === 'simulation') {
|
|
551
|
+
return `Parcours simulé (zoom/clavier) : ${message}`;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
const snippet = String(entry?.snippet || '').trim();
|
|
555
|
+
if (!snippet) {
|
|
556
|
+
return `Analyse DOM : ${message}`;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
const hint = extractElementHint(snippet);
|
|
560
|
+
if (hint) {
|
|
561
|
+
return `${hint} : ${message}`;
|
|
562
|
+
}
|
|
563
|
+
return `Extrait DOM : ${message}`;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function extractElementHint(snippet) {
|
|
567
|
+
const tag = snippet.match(/^<([a-zA-Z0-9-]+)/)?.[1];
|
|
568
|
+
const id = snippet.match(/\sid="([^"]+)"/)?.[1];
|
|
569
|
+
const cls = snippet.match(/\sclass="([^"]+)"/)?.[1]?.split(/\s+/).filter(Boolean)[0];
|
|
570
|
+
|
|
571
|
+
if (!tag && !id && !cls) return '';
|
|
572
|
+
|
|
573
|
+
let out = tag ? `<${tag}>` : 'élément';
|
|
574
|
+
if (id) out += ` #${id}`;
|
|
575
|
+
if (cls) out += ` .${cls}`;
|
|
576
|
+
return out;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
function renderVulgarizedPages(report) {
|
|
580
|
+
const pages = Array.isArray(report.pages) ? report.pages : [];
|
|
581
|
+
const fallback = report.url ? [{ url: report.url, title: report.title || report.url, score: report.score || {} }] : [];
|
|
582
|
+
const data = pages.length ? pages : fallback;
|
|
583
|
+
if (!data.length) return '';
|
|
584
|
+
|
|
585
|
+
const rows = data.map((p) => {
|
|
586
|
+
const taux = Number(p.score?.taux ?? 0);
|
|
587
|
+
const nc = Number(p.score?.nonConformes ?? p.nonConformes ?? 0);
|
|
588
|
+
const c = Number(p.score?.conformes ?? p.conformes ?? 0);
|
|
589
|
+
const nt = Number(p.score?.aVerifier ?? p.aVerifier ?? 0);
|
|
590
|
+
const href = esc(p.url || '');
|
|
591
|
+
const urlLine = href
|
|
592
|
+
? `<a href="${href}" target="_blank" rel="noopener noreferrer" style="word-break:break-all;">${href}</a>`
|
|
593
|
+
: 'URL indisponible';
|
|
594
|
+
return `<li><strong>${esc(p.title || p.url || 'Page')}</strong><br>${urlLine}<br>Conformité: <strong>${taux}%</strong> · Critères non conformes: <strong>${nc}</strong> · À vérifier: <strong>${nt}</strong> · Critères conformes: <strong>${c}</strong></li>`;
|
|
595
|
+
}).join('');
|
|
596
|
+
|
|
597
|
+
return `
|
|
598
|
+
<div class="box" style="margin-top:16px;">
|
|
599
|
+
<strong>Pages auditées (${data.length})</strong>
|
|
600
|
+
<ul>${rows}</ul>
|
|
601
|
+
</div>
|
|
602
|
+
`;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
function renderTransparency(report) {
|
|
606
|
+
const findings = Array.isArray(report?.results) ? report.results : [];
|
|
607
|
+
const byType = { probable_error: 0, heuristic_warning: 0, good_signal: 0, manual_only: 0, unknown: 0 };
|
|
608
|
+
const byConfidence = { high: 0, medium: 0, low: 0, unknown: 0 };
|
|
609
|
+
let manualRecommended = 0;
|
|
610
|
+
|
|
611
|
+
for (const item of findings) {
|
|
612
|
+
const type = String(item?.resultType || 'unknown');
|
|
613
|
+
const confidence = String(item?.confidence || 'unknown');
|
|
614
|
+
if (Object.prototype.hasOwnProperty.call(byType, type)) byType[type]++;
|
|
615
|
+
else byType.unknown++;
|
|
616
|
+
if (Object.prototype.hasOwnProperty.call(byConfidence, confidence)) byConfidence[confidence]++;
|
|
617
|
+
else byConfidence.unknown++;
|
|
618
|
+
if (item?.manualReviewRecommended) manualRecommended++;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
return `
|
|
622
|
+
<div class="box">
|
|
623
|
+
<strong>Transparence des contrôles: comment lire ces chiffres</strong>
|
|
624
|
+
<p style="margin:8px 0 0;color:#44556f;">Objectif: vous dire clairement ce qui est quasi certain, ce qui est probable, et ce qui doit être confirmé par un humain.</p>
|
|
625
|
+
<div class="transparency-grid">
|
|
626
|
+
<div class="transparency-item">
|
|
627
|
+
<strong>Erreurs probables (${byType.probable_error})</strong>
|
|
628
|
+
Le code montre un problème technique très plausible à corriger.
|
|
629
|
+
</div>
|
|
630
|
+
<div class="transparency-item">
|
|
631
|
+
<strong>Alertes heuristiques (${byType.heuristic_warning})</strong>
|
|
632
|
+
Indices de risque. La piste est utile, mais nécessite une vérification.
|
|
633
|
+
</div>
|
|
634
|
+
<div class="transparency-item">
|
|
635
|
+
<strong>Signaux positifs (${byType.good_signal})</strong>
|
|
636
|
+
Points où un comportement accessible a été détecté automatiquement.
|
|
637
|
+
</div>
|
|
638
|
+
<div class="transparency-item">
|
|
639
|
+
<strong>Manuel uniquement (${byType.manual_only})</strong>
|
|
640
|
+
Sujets impossibles à certifier automatiquement (sens, contexte, compréhension).
|
|
641
|
+
</div>
|
|
642
|
+
</div>
|
|
643
|
+
<div class="transparency-score">
|
|
644
|
+
<strong>Niveau de confiance de la détection</strong>
|
|
645
|
+
<p style="margin:6px 0 0;">Haute: <strong>${byConfidence.high}</strong> · Moyenne: <strong>${byConfidence.medium}</strong> · Basse: <strong>${byConfidence.low}</strong></p>
|
|
646
|
+
<p style="margin:6px 0 0;">Vérification manuelle recommandée: <strong>${manualRecommended}</strong> résultat(s).</p>
|
|
647
|
+
</div>
|
|
648
|
+
</div>
|
|
649
|
+
`;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
function criteriaTitles() {
|
|
653
|
+
if (typeof globalThis !== 'undefined' && globalThis.RgaaCriteria) return globalThis.RgaaCriteria.RGAA_CRITERIA;
|
|
654
|
+
try {
|
|
655
|
+
return require('./rgaa-criteria.js').RGAA_CRITERIA;
|
|
656
|
+
} catch {
|
|
657
|
+
return {};
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
function compareIds(a, b) {
|
|
662
|
+
const [ta, ca] = String(a).split('.').map(Number);
|
|
663
|
+
const [tb, cb] = String(b).split('.').map(Number);
|
|
664
|
+
return ta - tb || ca - cb;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
function pagePathOf(url) {
|
|
668
|
+
try {
|
|
669
|
+
const u = new URL(url);
|
|
670
|
+
return u.pathname + u.search;
|
|
671
|
+
} catch {
|
|
672
|
+
return String(url || '');
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
function renderTemplateIssues(report) {
|
|
677
|
+
const issues = Array.isArray(report.templateIssues) ? report.templateIssues : [];
|
|
678
|
+
if (!issues.length) return '';
|
|
679
|
+
const total = Array.isArray(report.pages) ? report.pages.length : 0;
|
|
680
|
+
const rows = issues.slice(0, 15).map((i) => `<li><strong>${esc(i.id)}</strong> — ${esc(i.message)} <span class="meta">(${i.pageCount}${total ? `/${total}` : ''} pages)</span></li>`).join('');
|
|
681
|
+
return `
|
|
682
|
+
<h2 style="margin-top:16px;">Défauts de gabarit</h2>
|
|
683
|
+
<div class="box">
|
|
684
|
+
<p style="margin:0 0 8px;color:#44556f;">Ces non-conformités se répètent sur plusieurs pages : elles viennent sans doute d’un élément commun (en-tête, pied de page, composant). Une seule correction les fait disparaître partout.</p>
|
|
685
|
+
<ul>${rows}</ul>
|
|
686
|
+
</div>
|
|
687
|
+
`;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
function renderAllIssues(byCriterion, report) {
|
|
691
|
+
const titles = criteriaTitles();
|
|
692
|
+
const captures = report.captures || {};
|
|
693
|
+
const multiPage = Array.isArray(report.pages) && report.pages.length > 1;
|
|
694
|
+
const ids = [...byCriterion.keys()].filter((id) => byCriterion.get(id).some((i) => i.status === 'NC')).sort(compareIds);
|
|
695
|
+
if (!ids.length) return '';
|
|
696
|
+
const total = ids.reduce((n, id) => n + byCriterion.get(id).filter((i) => i.status === 'NC').length, 0);
|
|
697
|
+
const blocks = ids.map((id) => {
|
|
698
|
+
const items = byCriterion.get(id).filter((i) => i.status === 'NC');
|
|
699
|
+
const list = items.map((item) => {
|
|
700
|
+
const examples = (Array.isArray(item.examples) && item.examples.length ? item.examples : (item.snippet ? [{ selector: item.selector, snippet: item.snippet }] : []))
|
|
701
|
+
.slice(0, 3)
|
|
702
|
+
.map((e) => `<li>${e.selector ? `<code>${esc(e.selector)}</code><br>` : ''}${e.snippet ? `<code class="snippet">${esc(e.snippet)}</code>` : ''}</li>`).join('');
|
|
703
|
+
const capture = item.capture && captures[item.capture]
|
|
704
|
+
? `<figure class="capture"><img src="${esc(captures[item.capture])}" alt="Capture de l’élément signalé, entouré en magenta${item.selector ? ` (${esc(item.selector)})` : ''}" loading="lazy"><figcaption>Élément entouré en magenta</figcaption></figure>`
|
|
705
|
+
: '';
|
|
706
|
+
return `<li class="issue">
|
|
707
|
+
<p><strong>${esc(item.message)}</strong>${multiPage && item.pageUrl ? ` <span class="meta">— ${esc(pagePathOf(item.pageUrl))}</span>` : ''}</p>
|
|
708
|
+
${item.remediationHint ? `<p class="meta">Piste : ${esc(item.remediationHint)}</p>` : ''}
|
|
709
|
+
${examples ? `<ul class="examples">${examples}</ul>` : ''}
|
|
710
|
+
${capture}
|
|
711
|
+
</li>`;
|
|
712
|
+
}).join('');
|
|
713
|
+
return `<details class="criterion-block"${items.length <= 3 ? ' open' : ''}>
|
|
714
|
+
<summary><strong>${esc(id)}</strong> ${esc(titles[id] || '')} <span class="meta">(${items.length})</span></summary>
|
|
715
|
+
<ul class="issues">${list}</ul>
|
|
716
|
+
</details>`;
|
|
717
|
+
}).join('');
|
|
718
|
+
return `
|
|
719
|
+
<h2 style="margin-top:16px;">Toutes les non-conformités (${total})</h2>
|
|
720
|
+
<div class="box all-issues">${blocks}</div>
|
|
721
|
+
`;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
function renderToCheck(byCriterion) {
|
|
725
|
+
const rows = [];
|
|
726
|
+
for (const [criterion, items] of byCriterion.entries()) {
|
|
727
|
+
if (items.some((i) => i.status === 'NC')) continue;
|
|
728
|
+
items
|
|
729
|
+
.filter((i) => i.status === 'NT' && i.resultType === 'heuristic_warning')
|
|
730
|
+
.forEach((i) => rows.push({ criterion, message: i.message, hint: i.remediationHint }));
|
|
731
|
+
}
|
|
732
|
+
if (!rows.length) return '';
|
|
733
|
+
const list = rows.slice(0, 12).map((r) => `<li><strong>${esc(r.criterion)}</strong> — ${esc(r.message)}${r.hint ? `<br><span class="meta">${esc(r.hint)}</span>` : ''}</li>`).join('');
|
|
734
|
+
return `
|
|
735
|
+
<h2 style="margin-top:16px;">À vérifier par une personne</h2>
|
|
736
|
+
<div class="box">
|
|
737
|
+
<p style="margin:0 0 8px;color:#44556f;">Indices détectés automatiquement mais qui dépendent du contexte : à confirmer avant de les corriger.</p>
|
|
738
|
+
<ul>${list}</ul>
|
|
739
|
+
${rows.length > 12 ? `<p class="meta">${rows.length - 12} autre(s) point(s) dans le rapport JSON.</p>` : ''}
|
|
740
|
+
</div>
|
|
741
|
+
`;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
function renderVulgarizedSkippedPages(report) {
|
|
745
|
+
const skipped = Array.isArray(report.pagesSkipped) ? report.pagesSkipped : [];
|
|
746
|
+
if (!skipped.length) return '';
|
|
747
|
+
|
|
748
|
+
const rows = skipped.map((p) => {
|
|
749
|
+
const href = esc(p.url || '');
|
|
750
|
+
const urlLine = href
|
|
751
|
+
? `<a href="${href}" target="_blank" rel="noopener noreferrer">${href}</a>`
|
|
752
|
+
: 'URL indisponible';
|
|
753
|
+
return `<li>${urlLine} — ${esc(p.reason || 'erreur')}</li>`;
|
|
754
|
+
}).join('');
|
|
755
|
+
|
|
756
|
+
return `
|
|
757
|
+
<div class="box" style="margin-top:16px;">
|
|
758
|
+
<strong>Pages non auditées (${skipped.length})</strong>
|
|
759
|
+
<ul>${rows}</ul>
|
|
760
|
+
<p style="margin-top:8px;color:#5b6476;">Ces pages ont été détectées mais ignorées (ex: timeout). Le reste de l'audit est conservé.</p>
|
|
761
|
+
</div>
|
|
762
|
+
`;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
function esc(str) {
|
|
766
|
+
return (str || '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
function toInlineJson(value) {
|
|
770
|
+
return JSON.stringify(value)
|
|
771
|
+
.replace(/</g, '\\u003C')
|
|
772
|
+
.replace(/>/g, '\\u003E')
|
|
773
|
+
.replace(/&/g, '\\u0026')
|
|
774
|
+
.replace(/\u2028/g, '\\u2028')
|
|
775
|
+
.replace(/\u2029/g, '\\u2029');
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
return { generateVulgarizedReport };
|
|
779
|
+
});
|