-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
409 lines (363 loc) · 16.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ARG</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 700px;
margin: 0 auto;
padding: 20px;
color: #ffffff;
background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
background-size: 400% 400%;
animation: gradientBG 10s ease infinite;
}
@keyframes gradientBG {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
h1 {
text-align: center;
color: #ffffff;
font-size: 2.5em;
margin-bottom: 10px;
}
p {
text-align: center;
margin-bottom: 20px;
font-size: 1.2em;
}
textarea {
width: 100%;
height: 100px;
padding: 10px;
border-radius: 8px;
border: none;
background: #0f3460;
color: #ffffff;
font-size: 1em;
margin-bottom: 15px;
resize: vertical;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}
button {
width: 100%;
padding: 12px;
color: #ffffff;
background: linear-gradient(90deg, #6a11cb, #2575fc);
border: none;
border-radius: 8px;
cursor: pointer;
font-size: 1.2em;
margin: 10px 0;
transition: transform 0.3s ease, background 0.3s ease;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}
button:hover {
transform: scale(1.05);
background: linear-gradient(90deg, #2575fc, #6a11cb);
}
#loader {
display: none;
text-align: center;
font-weight: bold;
margin-top: 20px;
color: #ffffff;
}
#results,
#stats {
margin-top: 20px;
}
.grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 15px;
margin-bottom: 20px;
}
.grid-button-item {
background: #1f4068;
color: #ffffff;
padding: 15px;
border-radius: 8px;
text-align: center;
font-weight: bold;
transition: background 0.3s ease;
}
.grid-button-item:hover {
background: #16213e;
}
.grid-item {
background: #16213e;
padding: 15px;
border-radius: 8px;
text-align: center;
font-weight: bold;
color: #ffffff;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}
details {
margin-bottom: 10px;
border: 1px solid #1f4068;
border-radius: 8px;
padding: 10px;
background-color: tomato;
color: #ffffff;
}
details[open] {
background-color: #1a1a2e;
}
summary {
font-weight: bold;
cursor: pointer;
display: flex;
align-items: center;
}
.dropdown-icon {
margin-right: 8px;
font-size: 1.2em;
color: #ffffff;
}
.success {
color: #28a745;
}
.error {
color: #dc3545;
}
.violation {
color: #ffc107;
}
code {
display: block;
background-color: #1a1a2e;
color: #ffffff;
padding: 5px;
border-radius: 3px;
margin-top: 5px;
overflow-wrap: break-word;
}
textarea {
resize: none;
overflow: hidden;
transition: height 0.2s ease;
}
</style>
</head>
<body>
<h1>Accessibility Report Generator</h1>
<p>Generate detailed accessibility reports for any website. Identify issues, get recommendations, and improve
user experience.</p>
<textarea id="urlInput" placeholder="Enter URLs here, one per line"></textarea>
<button id="checkButton">Generate Report</button>
<div class="grid">
<button id="ViewFullReport" style="display: none;" class="grid-button-item">View Full Report</button>
<button id="ViewMiniReport" style="display: none;" class="grid-button-item">View Mini Report</button>
<button id="PrintFullReport" style="display: none;" class="grid-button-item">Print Full Report</button>
<button id="PrintMiniReport" style="display: none;" class="grid-button-item">Print Mini Report</button>
</div>
<div id="loader">Checking accessibility... <span id="timer">0</span> seconds elapsed</div>
<div id="stats" class="grid"></div>
<div id="results"></div>
<script>
document.getElementById('checkButton').addEventListener('click', function () {
const urls = document.getElementById('urlInput').value.trim().split('\n').map(url => url.trim()).filter(url => url);
const resultsDiv = document.getElementById('results');
const loader = document.getElementById('loader');
const timerSpan = document.getElementById('timer');
const statsDiv = document.getElementById('stats');
const ViewFullReport = document.getElementById('ViewFullReport');
const ViewMiniReport = document.getElementById('ViewMiniReport');
const PrintFullReport = document.getElementById('PrintFullReport');
const PrintMiniReport = document.getElementById('PrintMiniReport');
let errorUrls = []; // To store URLs with errors
if (urls.length === 0) {
alert('Please enter at least one URL');
return;
}
resultsDiv.innerHTML = '';
statsDiv.innerHTML = '';
loader.style.display = 'block';
ViewFullReport.style.display = 'none';
ViewMiniReport.style.display = 'none';
PrintFullReport.style.display = 'none';
PrintMiniReport.style.display = 'none';
let secondsElapsed = 0;
const timer = setInterval(() => {
secondsElapsed++;
timerSpan.textContent = secondsElapsed;
}, 1000);
fetch('/analyze-multiple', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ urls })
})
.then(response => response.json())
.then(data => {
clearInterval(timer);
loader.style.display = 'none';
if (data.error) {
resultsDiv.innerHTML = `<p class="error">Error: ${data.error}</p>`;
return;
}
let issues = 0, noIssues = 0, errors = 0;
errorUrls = []; // Reset error URLs
const sortResults = {
noIssues: [],
issues: [],
errors: []
};
data.results.forEach(result => {
if (result.error) {
errors++;
sortResults.errors.push(result);
errorUrls.push(result.url);
} else if (result.violations.length === 0) {
noIssues++;
sortResults.noIssues.push(result);
} else {
issues++;
sortResults.issues.push(result);
}
});
statsDiv.innerHTML = `
<div class="grid-item">Total URLs Scanned: ${urls.length}</div>
<div class="grid-item">URLs with No Issues: ${noIssues}</div>
<div class="grid-item">URLs with Issues: ${issues}</div>
<div class="grid-item">Rerun tests for ${errors} URLS</div>
<div class="grid-item">Time Elapsed: ${secondsElapsed} Seconds</div>
`;
// Render each category in sorted order
['issues', 'noIssues', 'errors'].forEach(category => {
const categoryDiv = document.createElement('details');
categoryDiv.className = 'result-category';
categoryDiv.innerHTML = `<summary><span class="dropdown-icon"> ▸ </span> ${category === 'issues' ? 'URLs with Issues' : category === 'noIssues' ? 'URLs with No Issues' : 'URLs with Errors'
} (${sortResults[category].length})</summary>`;
sortResults[category].forEach(result => {
const resultItem = document.createElement('details');
const summary = document.createElement('summary');
const icon = document.createElement('span');
icon.classList.add('dropdown-icon');
const icon2 = document.createElement('span');
icon2.textContent = '▸';
icon2.classList.add('dropdown-icon');
summary.appendChild(icon2);
resultItem.className = `results-item`;
if (result.error) {
icon.textContent = '⚠️';
icon.classList.add('error');
summary.appendChild(icon);
summary.append(`${result.url} (Error)`);
} else if (result.violations.length === 0) {
icon.textContent = '✔️';
icon.classList.add('success');
summary.appendChild(icon);
summary.append(`${result.url} (No Issues)`);
} else {
icon.textContent = '❌';
icon.classList.add('violation');
summary.appendChild(icon);
const urlLink = document.createElement('a');
urlLink.href = result.url;
urlLink.target = '_blank';
urlLink.textContent = `${result.url}`;
summary.append(urlLink);
summary.append(` (${result.violations ? result.violations.length : 0} Issues)`);
}
resultItem.appendChild(summary);
if (result.error) {
const errorText = document.createElement('p');
errorText.className = 'error';
errorText.textContent = `Error: ${result.error}`;
resultItem.appendChild(errorText);
} else if (result.violations.length > 0) {
const violationList = document.createElement('ol');
result.violations.forEach(violation => {
const li = document.createElement('li');
const description = document.createElement('p');
description.textContent = `${violation.description} (Impact: ${violation.impact})`;
description.classList.add('violation');
li.appendChild(description);
const codeList = document.createElement('ul');
violation.nodes.forEach(node => {
const nodeItem = document.createElement('li');
const elementHtml = document.createElement('code');
elementHtml.textContent = node.html.trim();
nodeItem.appendChild(elementHtml);
codeList.appendChild(nodeItem);
});
li.appendChild(codeList);
violationList.appendChild(li);
});
resultItem.appendChild(violationList);
} else {
const noIssuesText = document.createElement('p');
noIssuesText.className = 'success';
noIssuesText.textContent = 'No accessibility violations found.';
resultItem.appendChild(noIssuesText);
}
categoryDiv.appendChild(resultItem);
});
resultsDiv.appendChild(categoryDiv);
});
ViewFullReport.style.display = 'block';
ViewMiniReport.style.display = 'block';
PrintFullReport.style.display = 'block';
PrintMiniReport.style.display = 'block';
// Button to re-run analysis for URLs with errors
if (errorUrls.length > 0) {
const rerunButton = document.createElement('button');
rerunButton.textContent = 'Re-run Analysis for URLs with Errors';
rerunButton.style.marginTop = '15px';
rerunButton.onclick = function () {
document.getElementById('urlInput').value = errorUrls.join('\n');
document.getElementById('checkButton').click();
};
resultsDiv.appendChild(rerunButton);
}
})
.catch(err => {
clearInterval(timer);
loader.style.display = 'none';
resultsDiv.innerHTML = `<p class="error">Error: ${err.message}</p>`;
});
});
document.getElementById('ViewFullReport').addEventListener('click', function () {
document.querySelectorAll('details').forEach(detail => detail.open = true);
const textarea = document.getElementById('urlInput');
textarea.style.height = 'auto';
textarea.style.height = textarea.scrollHeight + 'px';
});
document.getElementById('ViewMiniReport').addEventListener('click', function () {
document.querySelectorAll('details').forEach(detail => detail.open = false);
document.querySelectorAll('.result-category').forEach(detail => detail.open = true);
const textarea = document.getElementById('urlInput');
textarea.style.height = 'auto';
textarea.style.height = textarea.scrollHeight + 'px';
});
document.getElementById('PrintFullReport').addEventListener('click', function () {
document.querySelectorAll('details').forEach(detail => detail.open = true);
const textarea = document.getElementById('urlInput');
textarea.style.height = 'auto';
textarea.style.height = textarea.scrollHeight + 'px';
window.print();
});
document.getElementById('PrintMiniReport').addEventListener('click', function () {
document.querySelectorAll('details').forEach(detail => detail.open = false);
document.querySelectorAll('.result-category').forEach(detail => detail.open = true);
const textarea = document.getElementById('urlInput');
textarea.style.height = 'auto';
textarea.style.height = textarea.scrollHeight + 'px';
window.print();
});
</script>
</body>
</html>