accessibility-checker 3.1.49 → 3.1.51

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.
Files changed (94) hide show
  1. package/README.md +75 -67
  2. package/bin/achecker.js +14 -17
  3. package/bin/achecker.js.map +1 -1
  4. package/index.d.ts +6 -4
  5. package/index.js +9 -8
  6. package/index.js.map +1 -1
  7. package/lib/ACBrowserManager.d.ts +2 -2
  8. package/lib/ACBrowserManager.js +2 -3
  9. package/lib/ACBrowserManager.js.map +1 -1
  10. package/lib/ACEngineManager.d.ts +1 -12
  11. package/lib/ACEngineManager.js +72 -40
  12. package/lib/ACEngineManager.js.map +1 -1
  13. package/lib/ACHelper.js +126 -137
  14. package/lib/ACHelper.js.map +1 -1
  15. package/lib/api/IChecker.d.ts +3 -114
  16. package/lib/api/IChecker.js +1 -1
  17. package/lib/api/IChecker.js.map +1 -1
  18. package/lib/common/api-ext/Fetch.d.ts +16 -0
  19. package/lib/common/api-ext/Fetch.js +83 -0
  20. package/lib/common/api-ext/Fetch.js.map +1 -0
  21. package/lib/common/api-ext/IAbstractAPI.d.ts +34 -0
  22. package/lib/common/api-ext/IAbstractAPI.js +18 -0
  23. package/lib/common/api-ext/IAbstractAPI.js.map +1 -0
  24. package/lib/common/config/ACConfigManager.d.ts +7 -0
  25. package/lib/{ACConfigManager.js → common/config/ACConfigManager.js} +28 -19
  26. package/lib/common/config/ACConfigManager.js.map +1 -0
  27. package/lib/{ACConstants.d.ts → common/config/ACConstants.d.ts} +2 -2
  28. package/lib/{ACConstants.js → common/config/ACConstants.js} +7 -5
  29. package/lib/common/config/ACConstants.js.map +1 -0
  30. package/lib/common/config/IArchive.d.ts +37 -0
  31. package/lib/{reporters/multiScanReportUtil.d.ts → common/config/IArchive.js} +4 -5
  32. package/lib/common/config/IArchive.js.map +1 -0
  33. package/lib/common/config/IConfig.d.ts +146 -0
  34. package/lib/common/config/IConfig.js +36 -0
  35. package/lib/common/config/IConfig.js.map +1 -0
  36. package/lib/common/report/ACReporterCSV.d.ts +27 -0
  37. package/lib/common/report/ACReporterCSV.js +105 -0
  38. package/lib/common/report/ACReporterCSV.js.map +1 -0
  39. package/lib/common/report/ACReporterHTML.d.ts +26 -0
  40. package/lib/common/report/ACReporterHTML.js +94 -0
  41. package/lib/common/report/ACReporterHTML.js.map +1 -0
  42. package/lib/common/report/ACReporterJSON.d.ts +46 -0
  43. package/lib/common/report/ACReporterJSON.js +140 -0
  44. package/lib/common/report/ACReporterJSON.js.map +1 -0
  45. package/lib/{log/ACMetricsLogger.d.ts → common/report/ACReporterMetrics.d.ts} +11 -6
  46. package/lib/{log/ACMetricsLogger.js → common/report/ACReporterMetrics.js} +85 -70
  47. package/lib/common/report/ACReporterMetrics.js.map +1 -0
  48. package/lib/common/report/ACReporterXLSX.d.ts +37 -0
  49. package/lib/common/report/ACReporterXLSX.js +1004 -0
  50. package/lib/common/report/ACReporterXLSX.js.map +1 -0
  51. package/lib/common/report/BaselineManager.d.ts +169 -0
  52. package/lib/common/report/BaselineManager.js +355 -0
  53. package/lib/common/report/BaselineManager.js.map +1 -0
  54. package/lib/common/report/ReporterManager.d.ts +79 -0
  55. package/lib/common/report/ReporterManager.js +552 -0
  56. package/lib/common/report/ReporterManager.js.map +1 -0
  57. package/lib/common/report/genReport.js.map +1 -0
  58. package/package.json +1 -1
  59. package/lib/ACConfigManager.d.ts +0 -7
  60. package/lib/ACConfigManager.js.map +0 -1
  61. package/lib/ACConstants.js.map +0 -1
  62. package/lib/ACReportManager.d.ts +0 -590
  63. package/lib/ACReportManager.js +0 -1201
  64. package/lib/ACReportManager.js.map +0 -1
  65. package/lib/api/IEngine.d.ts +0 -129
  66. package/lib/api/IEngine.js +0 -110
  67. package/lib/api/IEngine.js.map +0 -1
  68. package/lib/log/ACMetricsLogger.js.map +0 -1
  69. package/lib/reporters/ACReporterCSV.d.ts +0 -103
  70. package/lib/reporters/ACReporterCSV.js +0 -193
  71. package/lib/reporters/ACReporterCSV.js.map +0 -1
  72. package/lib/reporters/ACReporterHTML.d.ts +0 -114
  73. package/lib/reporters/ACReporterHTML.js +0 -360
  74. package/lib/reporters/ACReporterHTML.js.map +0 -1
  75. package/lib/reporters/ACReporterJSON.d.ts +0 -114
  76. package/lib/reporters/ACReporterJSON.js +0 -277
  77. package/lib/reporters/ACReporterJSON.js.map +0 -1
  78. package/lib/reporters/ACReporterXLSX.d.ts +0 -109
  79. package/lib/reporters/ACReporterXLSX.js +0 -405
  80. package/lib/reporters/ACReporterXLSX.js.map +0 -1
  81. package/lib/reporters/ReportUtil.d.ts +0 -33
  82. package/lib/reporters/ReportUtil.js +0 -65
  83. package/lib/reporters/ReportUtil.js.map +0 -1
  84. package/lib/reporters/genReport.js.map +0 -1
  85. package/lib/reporters/multiScanData.d.ts +0 -27
  86. package/lib/reporters/multiScanData.js +0 -190
  87. package/lib/reporters/multiScanData.js.map +0 -1
  88. package/lib/reporters/multiScanReport.d.ts +0 -25
  89. package/lib/reporters/multiScanReport.js +0 -1729
  90. package/lib/reporters/multiScanReport.js.map +0 -1
  91. package/lib/reporters/multiScanReportUtil.js +0 -49
  92. package/lib/reporters/multiScanReportUtil.js.map +0 -1
  93. /package/lib/{reporters → common/report}/genReport.d.ts +0 -0
  94. /package/lib/{reporters → common/report}/genReport.js +0 -0
@@ -0,0 +1,1004 @@
1
+ "use strict";
2
+ /******************************************************************************
3
+ Copyright:: 2020- IBM, Inc
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ *****************************************************************************/
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.ACReporterXLSX = void 0;
55
+ var IConfig_1 = require("../config/IConfig");
56
+ var IReport_1 = require("../engine/IReport");
57
+ var ReporterManager_1 = require("./ReporterManager");
58
+ var ExcelJS = require("exceljs");
59
+ function dropDupes(arr) {
60
+ var dupes = {};
61
+ return arr.filter(function (item) {
62
+ if (item.toString() in dupes) {
63
+ return false;
64
+ }
65
+ {
66
+ return dupes[item.toString()] = true;
67
+ }
68
+ });
69
+ }
70
+ var ACReporterXLSX = /** @class */ (function () {
71
+ function ACReporterXLSX() {
72
+ }
73
+ ACReporterXLSX.prototype.name = function () {
74
+ return "xlsx";
75
+ };
76
+ ACReporterXLSX.prototype.generateReport = function (_reportData) {
77
+ };
78
+ ACReporterXLSX.prototype.generateSummary = function (config, rulesets, endReport, summaryData) {
79
+ return __awaiter(this, void 0, void 0, function () {
80
+ var storedReport, cfgRulesets, policyInfo, _i, cfgRulesets_1, rs, _a, _b, cp, _c, _d, rule, ruleId, startScan;
81
+ var _this = this;
82
+ return __generator(this, function (_e) {
83
+ storedReport = ReporterManager_1.ReporterManager.uncompressReport(summaryData[0]);
84
+ cfgRulesets = rulesets.filter(function (rs) { return config.policies.includes(rs.id); });
85
+ policyInfo = {};
86
+ for (_i = 0, cfgRulesets_1 = cfgRulesets; _i < cfgRulesets_1.length; _i++) {
87
+ rs = cfgRulesets_1[_i];
88
+ for (_a = 0, _b = rs.checkpoints; _a < _b.length; _a++) {
89
+ cp = _b[_a];
90
+ for (_c = 0, _d = cp.rules; _c < _d.length; _c++) {
91
+ rule = _d[_c];
92
+ policyInfo[rule.id] = policyInfo[rule.id] || {
93
+ tkLevels: [],
94
+ wcagLevels: [],
95
+ cps: []
96
+ };
97
+ policyInfo[rule.id].tkLevels.push(rule.toolkitLevel);
98
+ policyInfo[rule.id].wcagLevels.push(cp.wcagLevel);
99
+ policyInfo[rule.id].cps.push("".concat(cp.num));
100
+ }
101
+ }
102
+ }
103
+ for (ruleId in policyInfo) {
104
+ policyInfo[ruleId].tkLevels = dropDupes(policyInfo[ruleId].tkLevels);
105
+ policyInfo[ruleId].cps = dropDupes(policyInfo[ruleId].cps);
106
+ policyInfo[ruleId].wcagLevels = dropDupes(policyInfo[ruleId].wcagLevels);
107
+ policyInfo[ruleId].tkLevels.sort();
108
+ policyInfo[ruleId].cps.sort();
109
+ policyInfo[ruleId].wcagLevels.sort();
110
+ }
111
+ startScan = new Date(storedReport.engineReport.summary.startScan);
112
+ return [2 /*return*/, {
113
+ summaryPath: "results_".concat(startScan.toISOString(), ".xlsx"),
114
+ summary: function (filename) { return __awaiter(_this, void 0, void 0, function () {
115
+ var workbook;
116
+ return __generator(this, function (_a) {
117
+ workbook = new ExcelJS.stream.xlsx.WorkbookWriter({ filename: filename, useStyles: true });
118
+ // const workbook = new ExcelJS.Workbook({ useStyles: true });
119
+ ACReporterXLSX.createOverviewSheet(config, summaryData, workbook);
120
+ ACReporterXLSX.createScanSummarySheet(config, summaryData, workbook);
121
+ ACReporterXLSX.createIssueSummarySheet(config, policyInfo, summaryData, workbook);
122
+ ACReporterXLSX.createIssuesSheet(config, policyInfo, summaryData, workbook);
123
+ ACReporterXLSX.createDefinitionsSheet(workbook);
124
+ workbook.commit();
125
+ return [2 /*return*/];
126
+ });
127
+ }); }
128
+ }];
129
+ });
130
+ });
131
+ };
132
+ ACReporterXLSX.createOverviewSheet = function (config, compressedScans, workbook) {
133
+ var violations = 0;
134
+ var needsReviews = 0;
135
+ var recommendations = 0;
136
+ var archived = 0;
137
+ var totalIssues = 0;
138
+ var startScan = 0;
139
+ // BIG QUESTION: is report
140
+ // 1. for current scan (from menu)
141
+ // 2. all stored scans (from menu)
142
+ // 3. selected stored scans (from scan manager)
143
+ for (var _i = 0, compressedScans_1 = compressedScans; _i < compressedScans_1.length; _i++) {
144
+ var compressedScan = compressedScans_1[_i];
145
+ var storedScan = ReporterManager_1.ReporterManager.uncompressReport(compressedScan);
146
+ if (startScan === 0)
147
+ startScan = storedScan.engineReport.summary.startScan;
148
+ var counts = storedScan.engineReport.summary.counts;
149
+ violations += counts.violation;
150
+ needsReviews += counts.potentialviolation + counts.manual;
151
+ recommendations += counts.recommendation + counts.potentialrecommendation;
152
+ archived += counts.ignored;
153
+ }
154
+ totalIssues = violations + needsReviews + recommendations + archived;
155
+ var worksheet = workbook.addWorksheet("Overview");
156
+ // Report Title
157
+ worksheet.mergeCells('A1', "E1");
158
+ var titleRow = worksheet.getRow(1);
159
+ titleRow.height = 27;
160
+ var cellA1 = worksheet.getCell('A1');
161
+ cellA1.value = "Accessibility Scan Report";
162
+ cellA1.alignment = { vertical: "middle", horizontal: "left" };
163
+ cellA1.font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 16 };
164
+ cellA1.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
165
+ // what are column widths - can't get it till you set it
166
+ var colWidthData = [
167
+ { col: 'A', width: 15.1 },
168
+ { col: 'B', width: 15.9 },
169
+ { col: 'C', width: 16.23 },
170
+ { col: 'D', width: 19.4 },
171
+ ];
172
+ for (var i = 0; i < 4; i++) {
173
+ worksheet.getColumn(colWidthData[i].col).width = colWidthData[i].width;
174
+ }
175
+ // note except for Report Date this is the same for all scans
176
+ var rowData = [
177
+ { key1: 'Tool:', key2: 'IBM Equal Access Accessibility Checker' },
178
+ // {key1: 'Version:', key2: "chrome.runtime.getManifest().version"},
179
+ { key1: 'Version:', key2: config.toolID },
180
+ //@ts-ignore
181
+ // {key1: 'Rule set:', key2: (theCurrentScan.ruleSet === "Latest Deployment") ? archives[1].name : theCurrentScan.ruleSet },
182
+ { key1: 'Rule set:', key2: config.ruleArchiveLabel },
183
+ { key1: 'Guidelines:', key2: config.policies.join(", ") },
184
+ { key1: 'Report date:', key2: new Date(startScan).toLocaleString() },
185
+ { key1: 'Scans:', key2: "" + compressedScans.length }, // *** NEED TO FIX FOR selected
186
+ // { key1: 'Pages:', key2: "" }
187
+ ];
188
+ for (var idx = 0; idx < rowData.length; ++idx) {
189
+ worksheet.mergeCells("B".concat(idx + 2), "E".concat(idx + 2));
190
+ var i = idx + 2;
191
+ worksheet.getRow(i).height = 12; // results in a row height of 16
192
+ worksheet.getRow(i).getCell(1).font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
193
+ worksheet.getRow(i).getCell(2).font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
194
+ worksheet.getRow(i).getCell(1).alignment = { horizontal: "left" };
195
+ worksheet.getRow(i).getCell(2).alignment = { horizontal: "left" };
196
+ // if (i == 7) {
197
+ // worksheet.getRow(i).getCell(1).alignment = { vertical: "top" };
198
+ // worksheet.getRow(i).getCell(2).alignment = { wrapText: true };
199
+ // }
200
+ worksheet.getRow(i).getCell(1).value = rowData[i - 2].key1;
201
+ worksheet.getRow(i).getCell(2).value = rowData[i - 2].key2;
202
+ }
203
+ // Summary Title
204
+ worksheet.mergeCells('A11', "E11");
205
+ var summaryRow = worksheet.getRow(11);
206
+ summaryRow.height = 27;
207
+ var cellA11 = worksheet.getCell('A11');
208
+ cellA11.value = "Summary";
209
+ cellA11.alignment = { vertical: "middle", horizontal: "left" };
210
+ cellA11.font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 16 };
211
+ cellA11.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
212
+ // Scans info Headers
213
+ worksheet.getRow(12).height = 16; // actual height is
214
+ var cellA12 = worksheet.getCell('A12');
215
+ cellA12.value = "Total issues";
216
+ var cellB12 = worksheet.getCell('B12');
217
+ cellB12.value = "Violations";
218
+ var cellC12 = worksheet.getCell('C12');
219
+ cellC12.value = "Needs review";
220
+ var cellD12 = worksheet.getCell('D12');
221
+ cellD12.value = "Recommendations";
222
+ var cellE12 = worksheet.getCell('E12');
223
+ cellE12.value = "Archived";
224
+ var cellObjects1 = [cellA12, cellB12, cellC12, cellD12, cellE12];
225
+ for (var i = 0; i < cellObjects1.length; i++) {
226
+ cellObjects1[i].alignment = { vertical: "middle", horizontal: "center" };
227
+ if (i == 1 || i == 2 || i == 3 || i === 4) {
228
+ cellObjects1[i].font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
229
+ }
230
+ else {
231
+ cellObjects1[i].font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 12 };
232
+ }
233
+ // cellObjects1[i].fill = { type: 'pattern', pattern: 'solid', fgColor:{argb:'FFC65911'} };
234
+ cellObjects1[i].border = {
235
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
236
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
237
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
238
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
239
+ };
240
+ }
241
+ cellA12.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF000000' } };
242
+ cellB12.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFE4AAAF' } };
243
+ cellC12.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFF4E08A' } };
244
+ cellD12.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF96A9D7' } };
245
+ // Scans info Values
246
+ worksheet.getRow(13).height = 27; // actual height is
247
+ var cellA13 = worksheet.getCell('A13');
248
+ cellA13.value = totalIssues;
249
+ var cellB13 = worksheet.getCell('B13');
250
+ cellB13.value = violations;
251
+ var cellC13 = worksheet.getCell('C13');
252
+ cellC13.value = needsReviews;
253
+ var cellD13 = worksheet.getCell('D13');
254
+ cellD13.value = recommendations;
255
+ var cellE13 = worksheet.getCell('E13');
256
+ cellE13.value = archived;
257
+ var cellObjects2 = [cellA13, cellB13, cellC13, cellD13, cellE13];
258
+ for (var i = 0; i < cellObjects2.length; i++) {
259
+ cellObjects2[i].alignment = { vertical: "middle", horizontal: "center" };
260
+ cellObjects2[i].font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
261
+ // cellObjects2[i].fill = { type: 'pattern', pattern: 'solid', fgColor:{argb:'FFf8cbad'} };
262
+ cellObjects2[i].border = {
263
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
264
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
265
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
266
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
267
+ };
268
+ }
269
+ };
270
+ ACReporterXLSX.createScanSummarySheet = function (config, compressedScans, workbook) {
271
+ var worksheet = workbook.addWorksheet("Scan summary");
272
+ // Scans info Headers
273
+ worksheet.getRow(1).height = 39; // actual height is 52
274
+ var colWidthData = [
275
+ { col: 'A', width: 27.0 },
276
+ { col: 'B', width: 46.0 },
277
+ { col: 'C', width: 20.17 },
278
+ { col: 'D', width: 18.5 },
279
+ { col: 'E', width: 17.17 },
280
+ { col: 'F', width: 17.17 },
281
+ { col: 'G', width: 17.17 },
282
+ { col: 'H', width: 17.17 },
283
+ { col: 'I', width: 17.17 },
284
+ ];
285
+ for (var i = 0; i < 9; i++) {
286
+ worksheet.getColumn(colWidthData[i].col).width = colWidthData[i].width;
287
+ }
288
+ var cellA1 = worksheet.getCell('A1');
289
+ cellA1.value = "Page title";
290
+ var cellB1 = worksheet.getCell('B1');
291
+ cellB1.value = "Page url";
292
+ var cellC1 = worksheet.getCell('C1');
293
+ cellC1.value = "Scan label";
294
+ var cellObjects1 = [cellA1, cellB1, cellC1];
295
+ for (var i = 0; i < cellObjects1.length; i++) {
296
+ cellObjects1[i].alignment = { vertical: "middle", horizontal: "left" };
297
+ cellObjects1[i].font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 12 };
298
+ cellObjects1[i].fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
299
+ cellObjects1[i].border = {
300
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
301
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
302
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
303
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
304
+ };
305
+ }
306
+ var cellD1 = worksheet.getCell('D1');
307
+ cellD1.value = "Violations";
308
+ var cellE1 = worksheet.getCell('E1');
309
+ cellE1.value = "Needs review";
310
+ var cellF1 = worksheet.getCell('F1');
311
+ cellF1.value = "Recommendations";
312
+ var cellG1 = worksheet.getCell('G1');
313
+ cellG1.value = "Archived";
314
+ var cellH1 = worksheet.getCell('H1');
315
+ cellH1.value = "% elements without violations";
316
+ var cellI1 = worksheet.getCell('I1');
317
+ cellI1.value = "% elements without violations or items to review";
318
+ var cellObjects2 = [cellD1, cellE1, cellF1, cellG1, cellH1, cellI1];
319
+ for (var i = 0; i < cellObjects2.length; i++) {
320
+ cellObjects2[i].alignment = { vertical: "middle", horizontal: "center", wrapText: true };
321
+ if (i == 0 || i == 1 || i == 2 || i == 3) {
322
+ cellObjects2[i].font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
323
+ }
324
+ else {
325
+ cellObjects2[i].font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 12 };
326
+ }
327
+ // cellObjects2[i].fill = { type: 'pattern', pattern: 'solid', fgColor:{argb:'FFC65911'} };
328
+ cellObjects2[i].border = {
329
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
330
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
331
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
332
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
333
+ };
334
+ }
335
+ cellD1.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFE4AAAF' } };
336
+ cellE1.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFF4E08A' } };
337
+ cellF1.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF96A9D7' } };
338
+ cellG1.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFFFFFFF' } };
339
+ cellH1.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF000000' } };
340
+ cellI1.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF000000' } };
341
+ for (var _i = 0, compressedScans_2 = compressedScans; _i < compressedScans_2.length; _i++) {
342
+ var compressedScan = compressedScans_2[_i];
343
+ var storedScan = ReporterManager_1.ReporterManager.uncompressReport(compressedScan);
344
+ var counts = storedScan.engineReport.summary.counts;
345
+ var row = worksheet.addRow([
346
+ storedScan.pageTitle,
347
+ storedScan.engineReport.summary.URL,
348
+ storedScan.label,
349
+ counts.violation,
350
+ counts.potentialviolation + counts.manual,
351
+ counts.recommendation + counts.potentialrecommendation,
352
+ counts.ignored,
353
+ (100 * (counts.elements - counts.elementsViolation) / counts.elements).toFixed(0),
354
+ (100 * (counts.elements - counts.elementsViolationReview) / counts.elements).toFixed(0),
355
+ ]);
356
+ row.height = 37; // actual height is
357
+ for (var i = 1; i < 4; i++) {
358
+ row.getCell(i).alignment = { vertical: "middle", horizontal: "left", wrapText: true };
359
+ row.getCell(i).font = { name: "Calibri", color: { argb: "00000000" }, size: 12 };
360
+ }
361
+ for (var i = 4; i < 10; i++) {
362
+ row.getCell(i).alignment = { vertical: "middle", horizontal: "center", wrapText: true };
363
+ row.getCell(i).font = { name: "Calibri", color: { argb: "00000000" }, size: 12 };
364
+ // row.getCell(i).fill = { type: 'pattern', pattern: 'solid', fgColor:{argb:'FFf8cbad'} };
365
+ row.getCell(i).border = {
366
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
367
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
368
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
369
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
370
+ };
371
+ }
372
+ row.commit();
373
+ }
374
+ worksheet.commit();
375
+ };
376
+ ACReporterXLSX.buildIssueSummaryLevel = function (worksheet, fillColor, title, levelCount, levelrowValues) {
377
+ // Level 1 Violation title
378
+ var level1ViolationRow = worksheet.addRow(["", 0]);
379
+ level1ViolationRow.height = 18; // target is 21
380
+ var cellA6 = level1ViolationRow.getCell(1);
381
+ cellA6.value = " ".concat(title);
382
+ cellA6.alignment = { vertical: "middle", horizontal: "left" };
383
+ cellA6.font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
384
+ cellA6.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: fillColor } };
385
+ level1ViolationRow.getCell(1).border = {
386
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
387
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
388
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
389
+ // right: {style:'thin', color: {argb: 'FFA6A6A6'}}
390
+ };
391
+ var cellB6 = level1ViolationRow.getCell(2);
392
+ cellB6.value = levelCount; // total level violations
393
+ cellB6.alignment = { vertical: "middle", horizontal: "right" };
394
+ cellB6.font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
395
+ cellB6.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: fillColor } };
396
+ level1ViolationRow.getCell(2).border = {
397
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
398
+ // left: {style:'thin', color: {argb: 'FFA6A6A6'}},
399
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
400
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
401
+ };
402
+ // Level 1 Violation Rows
403
+ // build rows
404
+ var rowArray = [];
405
+ // let row:any =[];
406
+ for (var property in levelrowValues) {
407
+ var row = [" " + "".concat(property), parseInt("".concat(levelrowValues[property]))
408
+ ];
409
+ rowArray.push(row);
410
+ }
411
+ // sort array according to count
412
+ rowArray.sort(function (a, b) { return (a[1] < b[1]) ? 1 : -1; });
413
+ // add array of rows
414
+ for (var _i = 0, rowArray_1 = rowArray; _i < rowArray_1.length; _i++) {
415
+ var rowInfo = rowArray_1[_i];
416
+ var row = worksheet.addRow(rowInfo);
417
+ row.height = 14;
418
+ row.getCell(1).alignment = { vertical: "middle", horizontal: "left" };
419
+ row.getCell(2).alignment = { vertical: "middle", horizontal: "right" };
420
+ row.font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
421
+ // row.getCell(1).fill = { type: 'pattern', pattern: 'solid', fgColor:{argb:'FFf8cbad'} };
422
+ // row.getCell(2).fill = { type: 'pattern', pattern: 'solid', fgColor:{argb:'FFf8cbad'} };
423
+ row.getCell(1).border = {
424
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
425
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
426
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
427
+ // right: {style:'thin', color: {argb: 'FFA6A6A6'}}
428
+ };
429
+ row.getCell(2).border = {
430
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
431
+ // left: {style:'thin', color: {argb: 'FFA6A6A6'}},
432
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
433
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
434
+ };
435
+ row.commit();
436
+ }
437
+ };
438
+ ACReporterXLSX.buildIssueSummaryTKLevel = function (worksheet, title, levelCounts, levelVrowValues, levelNRrowValues, levelRrowValues, levelArowValues) {
439
+ /////////////////////////////
440
+ // build Level title
441
+ /////////////////////////////
442
+ var level1Row = worksheet.addRow(["", 0]);
443
+ level1Row.height = 27; // actual is 36
444
+ var cellA5 = level1Row.getCell(1);
445
+ cellA5.value = title;
446
+ cellA5.alignment = { vertical: "middle", horizontal: "left" };
447
+ cellA5.font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 16 };
448
+ cellA5.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
449
+ var cellB5 = level1Row.getCell(2);
450
+ cellB5.value = levelCounts[0]; // total Level 1 issues
451
+ cellB5.alignment = { vertical: "middle", horizontal: "right" };
452
+ cellB5.font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 16 };
453
+ cellB5.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
454
+ ACReporterXLSX.buildIssueSummaryLevel(worksheet, "FFE4AAAF", "Violation", levelCounts[1], levelVrowValues);
455
+ ACReporterXLSX.buildIssueSummaryLevel(worksheet, "FFF4E08A", "Needs review", levelCounts[2], levelNRrowValues);
456
+ ACReporterXLSX.buildIssueSummaryLevel(worksheet, "FF96A9D7", "Recommendation", levelCounts[3], levelRrowValues);
457
+ if (levelCounts[4] > 0) {
458
+ ACReporterXLSX.buildIssueSummaryLevel(worksheet, "FFCCCCCC", "Archived", levelCounts[4], levelArowValues);
459
+ }
460
+ };
461
+ ACReporterXLSX.createIssueSummarySheet = function (config, policyInfo, compressedScans, workbook) {
462
+ var violations = 0;
463
+ var needsReviews = 0;
464
+ var recommendations = 0;
465
+ var archive = 0;
466
+ var totalIssues = 0;
467
+ for (var i = 0; i < compressedScans.length; i++) {
468
+ var storedScan = ReporterManager_1.ReporterManager.uncompressReport(compressedScans[i]);
469
+ var counts = storedScan.engineReport.summary.counts;
470
+ violations += counts.violation;
471
+ needsReviews += counts.potentialviolation + counts.manual;
472
+ recommendations += counts.recommendation + counts.potentialrecommendation;
473
+ archive += counts.ignored;
474
+ }
475
+ totalIssues = violations + needsReviews + recommendations;
476
+ // counts
477
+ var level1Counts = [0, 0, 0, 0, 0]; // level 1 total issues, violations, needs reviews, recommendations
478
+ var level2Counts = [0, 0, 0, 0, 0];
479
+ var level3Counts = [0, 0, 0, 0, 0];
480
+ var level4Counts = [0, 0, 0, 0, 0];
481
+ var level1V = [];
482
+ var level2V = [];
483
+ var level3V = [];
484
+ var level4V = [];
485
+ var level1NR = [];
486
+ var level2NR = [];
487
+ var level3NR = [];
488
+ var level4NR = [];
489
+ var level1R = [];
490
+ var level2R = [];
491
+ var level3R = [];
492
+ var level4R = [];
493
+ var level1A = [];
494
+ var level2A = [];
495
+ var level3A = [];
496
+ var level4A = [];
497
+ for (var _i = 0, compressedScans_3 = compressedScans; _i < compressedScans_3.length; _i++) {
498
+ var compressedScan = compressedScans_3[_i];
499
+ var scan = ReporterManager_1.ReporterManager.uncompressReport(compressedScan);
500
+ for (var _a = 0, _b = scan.engineReport.results; _a < _b.length; _a++) {
501
+ var issue = _b[_a];
502
+ if (!(issue.ruleId in policyInfo)) {
503
+ policyInfo[issue.ruleId] = {
504
+ tkLevels: [],
505
+ wcagLevels: [],
506
+ cps: []
507
+ };
508
+ }
509
+ var levelCounts = void 0, levelV = void 0, levelNR = void 0, levelR = void 0, levelA = void 0;
510
+ var issuePolicyInfo = policyInfo[issue.ruleId];
511
+ if (issuePolicyInfo.tkLevels.includes(IReport_1.eToolkitLevel.LEVEL_ONE)) {
512
+ levelCounts = level1Counts;
513
+ levelV = level1V;
514
+ levelNR = level1NR;
515
+ levelR = level1R;
516
+ levelA = level1A;
517
+ }
518
+ else if (issuePolicyInfo.tkLevels.includes(IReport_1.eToolkitLevel.LEVEL_TWO)) {
519
+ levelCounts = level2Counts;
520
+ levelV = level2V;
521
+ levelNR = level2NR;
522
+ levelR = level2R;
523
+ levelA = level2A;
524
+ }
525
+ else if (issuePolicyInfo.tkLevels.includes(IReport_1.eToolkitLevel.LEVEL_THREE)) {
526
+ levelCounts = level3Counts;
527
+ levelV = level3V;
528
+ levelNR = level3NR;
529
+ levelR = level3R;
530
+ levelA = level3A;
531
+ }
532
+ else if (issuePolicyInfo.tkLevels.includes(IReport_1.eToolkitLevel.LEVEL_FOUR)) {
533
+ levelCounts = level4Counts;
534
+ levelV = level4V;
535
+ levelNR = level4NR;
536
+ levelR = level4R;
537
+ levelA = level4A;
538
+ }
539
+ if (issue.value[1] !== IReport_1.eRuleConfidence.PASS) {
540
+ ++levelCounts[0];
541
+ }
542
+ if (issue.ignored) {
543
+ ++levelCounts[4];
544
+ levelA.push(issue.message.substring(0, 32767));
545
+ }
546
+ else if (issue.level === IConfig_1.eRuleLevel.violation) {
547
+ ++levelCounts[1];
548
+ levelV.push(issue.message.substring(0, 32767));
549
+ }
550
+ else if (issue.level === IConfig_1.eRuleLevel.potentialviolation || issue.level === IConfig_1.eRuleLevel.manual) {
551
+ ++levelCounts[2];
552
+ levelNR.push(issue.message.substring(0, 32767));
553
+ }
554
+ else if (issue.level === IConfig_1.eRuleLevel.recommendation || issue.level === IConfig_1.eRuleLevel.potentialrecommendation) {
555
+ ++levelCounts[3];
556
+ levelR.push(issue.message.substring(0, 32767));
557
+ }
558
+ }
559
+ }
560
+ // @ts-ignore
561
+ var level1VrowValues = this.countDuplicatesInArray(level1V); // note this returns an object
562
+ // @ts-ignore
563
+ var level1NRrowValues = this.countDuplicatesInArray(level1NR);
564
+ // @ts-ignore
565
+ var level1RrowValues = this.countDuplicatesInArray(level1R);
566
+ // @ts-ignore
567
+ var level1ArowValues = this.countDuplicatesInArray(level1A);
568
+ // @ts-ignore
569
+ var level2VrowValues = this.countDuplicatesInArray(level2V); // note this returns an object
570
+ // @ts-ignore
571
+ var level2NRrowValues = this.countDuplicatesInArray(level2NR);
572
+ // @ts-ignore
573
+ var level2RrowValues = this.countDuplicatesInArray(level2R);
574
+ // @ts-ignore
575
+ var level2ArowValues = this.countDuplicatesInArray(level2A);
576
+ // @ts-ignore
577
+ var level3VrowValues = this.countDuplicatesInArray(level3V); // note this returns an object
578
+ // @ts-ignore
579
+ var level3NRrowValues = this.countDuplicatesInArray(level3NR);
580
+ // @ts-ignore
581
+ var level3RrowValues = this.countDuplicatesInArray(level3R);
582
+ // @ts-ignore
583
+ var level3ArowValues = this.countDuplicatesInArray(level3A);
584
+ // @ts-ignore
585
+ var level4VrowValues = this.countDuplicatesInArray(level4V); // note this returns an object
586
+ // @ts-ignore
587
+ var level4NRrowValues = this.countDuplicatesInArray(level4NR);
588
+ // @ts-ignore
589
+ var level4RrowValues = this.countDuplicatesInArray(level4R);
590
+ // @ts-ignore
591
+ var level4ArowValues = this.countDuplicatesInArray(level4A);
592
+ var worksheet = workbook.addWorksheet("Issue summary");
593
+ // Approach:
594
+ // 1. sort by levels
595
+ // 2. for each level sort by V, NR and R
596
+ // 3. for each V, NR, and R in a level get issue dup counts
597
+ // 4. build the rows
598
+ // build Issue summary title
599
+ worksheet.mergeCells('A1', "B1");
600
+ var titleRow = worksheet.getRow(1);
601
+ titleRow.height = 27; // actual is 36
602
+ var cellA1 = worksheet.getCell('A1');
603
+ cellA1.value = "Issue summary";
604
+ cellA1.alignment = { vertical: "middle", horizontal: "left" };
605
+ cellA1.font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 16 };
606
+ cellA1.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
607
+ var colWidthData = [
608
+ { col: 'A', width: 155.51 },
609
+ { col: 'B', width: 21.16 },
610
+ ];
611
+ for (var i = 0; i < 2; i++) {
612
+ worksheet.getColumn(colWidthData[i].col).width = colWidthData[i].width;
613
+ }
614
+ // build Description title
615
+ worksheet.mergeCells('A2', "B2");
616
+ var descriptionRow = worksheet.getRow(2);
617
+ descriptionRow.height = 20.25; // actual is 27
618
+ var cellA2 = worksheet.getCell("A2");
619
+ cellA2.value = " In the IBM Equal Access Toolkit, issues are divided into three levels (1-3). Tackle the levels in order to address some of the most impactful issues first.";
620
+ cellA2.alignment = { vertical: "middle", horizontal: "left" };
621
+ cellA2.font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
622
+ // cellA2.fill = { type: 'pattern', pattern: 'solid', fgColor:{argb:'FFCCC0DA'} };
623
+ // build Total issues found: title
624
+ // worksheet.mergeCells('A3', "B3");
625
+ var totalIssuesRow = worksheet.getRow(3);
626
+ totalIssuesRow.height = 27; // actual is 36
627
+ var cellA3 = worksheet.getCell("A3");
628
+ cellA3.value = "Total issues found:";
629
+ cellA3.alignment = { vertical: "middle", horizontal: "left" };
630
+ cellA3.font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 16 };
631
+ cellA3.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF000000' } };
632
+ var cellB3 = worksheet.getCell("B3");
633
+ cellB3.value = totalIssues;
634
+ cellB3.alignment = { vertical: "middle", horizontal: "right" };
635
+ cellB3.font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 16 };
636
+ cellB3.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF000000' } };
637
+ // build Number of issues title
638
+ var numberOfIssuesRow = worksheet.getRow(4);
639
+ numberOfIssuesRow.height = 20.25; // actual is 27
640
+ var cellA4 = worksheet.getCell("A4");
641
+ // no value
642
+ cellA4.alignment = { vertical: "middle", horizontal: "left" };
643
+ cellA4.border = {
644
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
645
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
646
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
647
+ right: { style: 'thin', color: { argb: 'FFFFFFFF' } }
648
+ };
649
+ var cellB4 = worksheet.getCell("B4");
650
+ cellB4.value = "Number of issues";
651
+ cellB4.alignment = { vertical: "middle", horizontal: "right" };
652
+ cellB4.font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
653
+ cellB4.border = {
654
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
655
+ left: { style: 'thin', color: { argb: 'FFFFFFFF' } },
656
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
657
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
658
+ };
659
+ ACReporterXLSX.buildIssueSummaryTKLevel(worksheet, "Level 1 - the most essential issues to address", level1Counts, level1VrowValues, level1NRrowValues, level1RrowValues, level1ArowValues);
660
+ ACReporterXLSX.buildIssueSummaryTKLevel(worksheet, "Level 2 - the next most important issues", level2Counts, level2VrowValues, level2NRrowValues, level2RrowValues, level2ArowValues);
661
+ ACReporterXLSX.buildIssueSummaryTKLevel(worksheet, "Level 3 - necessary to meet requirements", level3Counts, level3VrowValues, level3NRrowValues, level3RrowValues, level3ArowValues);
662
+ ACReporterXLSX.buildIssueSummaryTKLevel(worksheet, "Level 4 - further recommended improvements to accessibility", level4Counts, level4VrowValues, level4NRrowValues, level4RrowValues, level4ArowValues);
663
+ worksheet.commit();
664
+ };
665
+ ACReporterXLSX.createIssuesSheet = function (config, policyInfo, compressedScans, workbook) {
666
+ var valueMap = {
667
+ "VIOLATION": {
668
+ "POTENTIAL": "Needs review",
669
+ "FAIL": "Violation",
670
+ "PASS": "Pass",
671
+ "MANUAL": "Needs review"
672
+ },
673
+ "RECOMMENDATION": {
674
+ "POTENTIAL": "Recommendation",
675
+ "FAIL": "Recommendation",
676
+ "PASS": "Pass",
677
+ "MANUAL": "Recommendation"
678
+ },
679
+ "INFORMATION": {
680
+ "POTENTIAL": "Needs review",
681
+ "FAIL": "Violation",
682
+ "PASS": "Pass",
683
+ "MANUAL": "Recommendation"
684
+ }
685
+ };
686
+ var worksheet = workbook.addWorksheet("Issues");
687
+ // build rows
688
+ var rowArray = [];
689
+ for (var _i = 0, compressedScans_4 = compressedScans; _i < compressedScans_4.length; _i++) {
690
+ var compressedScan = compressedScans_4[_i];
691
+ var storedScan = ReporterManager_1.ReporterManager.uncompressReport(compressedScan);
692
+ for (var _a = 0, _b = storedScan.engineReport.results; _a < _b.length; _a++) {
693
+ var item = _b[_a];
694
+ if (!(item.ruleId in policyInfo)) {
695
+ policyInfo[item.ruleId] = {
696
+ tkLevels: [],
697
+ wcagLevels: [],
698
+ cps: []
699
+ };
700
+ }
701
+ var row = [
702
+ storedScan.pageTitle,
703
+ storedScan.engineReport.summary.URL,
704
+ storedScan.label,
705
+ this.stringHash(item.ruleId + item.path.dom),
706
+ "".concat(valueMap[item.value[0]][item.value[1]]).concat(item.ignored ? " (Archived)" : ""),
707
+ policyInfo[item.ruleId].tkLevels.join(", "),
708
+ policyInfo[item.ruleId].cps.join(", "),
709
+ policyInfo[item.ruleId].wcagLevels.join(", "),
710
+ item.ruleId,
711
+ item.message.substring(0, 32767),
712
+ this.get_element(item.snippet),
713
+ item.snippet.substring(0, 32767),
714
+ item.path.dom,
715
+ item.help
716
+ // engine_end_point + '/tools/help/' + item.ruleId
717
+ ];
718
+ // let row = [myStoredData[i][0], myStoredData[i][1], storedScans[j].label,
719
+ // myStoredData[i][3], myStoredData[i][4], Number.isNaN(myStoredData[i][5]) ? "n/a" : myStoredData[i][5],
720
+ // myStoredData[i][6], Number.isNaN(myStoredData[i][5]) ? "n/a" : myStoredData[i][7], myStoredData[i][8],
721
+ // myStoredData[i][9], myStoredData[i][10], myStoredData[i][11],
722
+ // myStoredData[i][12], myStoredData[i][13]
723
+ // ];
724
+ rowArray.push(row);
725
+ }
726
+ }
727
+ // column widths
728
+ var colWidthData = [
729
+ { col: 'A', width: 18.0, alignment: { vertical: "middle", horizontal: "left" } },
730
+ { col: 'B', width: 20.5, alignment: { vertical: "middle", horizontal: "left" } },
731
+ { col: 'C', width: 21.0, alignment: { vertical: "middle", horizontal: "center" } },
732
+ { col: 'D', width: 18.5, alignment: { vertical: "middle", horizontal: "left" } },
733
+ { col: 'E', width: 17.0, alignment: { vertical: "middle", horizontal: "center" } },
734
+ { col: 'F', width: 17.17, alignment: { vertical: "middle", horizontal: "center" } },
735
+ { col: 'G', width: 17.17, alignment: { vertical: "middle", horizontal: "left" } },
736
+ { col: 'H', width: 17.17, alignment: { vertical: "middle", horizontal: "center" } },
737
+ { col: 'I', width: 17.17, alignment: { vertical: "middle", horizontal: "left" } },
738
+ { col: 'J', width: 17.17, alignment: { vertical: "middle", horizontal: "left" } },
739
+ { col: 'K', width: 14.00, alignment: { vertical: "middle", horizontal: "center" } },
740
+ { col: 'L', width: 17.17, alignment: { vertical: "middle", horizontal: "left" } },
741
+ { col: 'M', width: 43.00, alignment: { vertical: "middle", horizontal: "left" } },
742
+ { col: 'N', width: 17.17, alignment: { vertical: "middle", horizontal: "fill" } },
743
+ ];
744
+ for (var i = 0; i < 14; i++) {
745
+ worksheet.getColumn(colWidthData[i].col).width = colWidthData[i].width;
746
+ worksheet.getColumn(colWidthData[i].col).alignment = colWidthData[i].alignment;
747
+ }
748
+ // add table to a sheet
749
+ var headRow = worksheet.addRow([
750
+ "Page title",
751
+ "Page URL",
752
+ "Scan label",
753
+ "Issue ID",
754
+ "Issue type",
755
+ "Toolkit level",
756
+ "Checkpoint",
757
+ "WCAG level",
758
+ "Rule",
759
+ "Issue",
760
+ "Element",
761
+ "Code",
762
+ "Xpath",
763
+ "Help",
764
+ ""
765
+ ]);
766
+ // set font and alignment for the header cells
767
+ for (var i = 1; i < 15; i++) {
768
+ headRow.getCell(i).alignment = { vertical: "middle", horizontal: "center", wrapText: true };
769
+ headRow.getCell(i).font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 12 };
770
+ headRow.getCell(i).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
771
+ headRow.getCell(i).border = {
772
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
773
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
774
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
775
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
776
+ };
777
+ }
778
+ // height for header row
779
+ headRow.height = 24;
780
+ headRow.commit();
781
+ for (var _c = 0, rowArray_2 = rowArray; _c < rowArray_2.length; _c++) {
782
+ var rowInfo = rowArray_2[_c];
783
+ var row = worksheet.addRow(rowInfo);
784
+ row.height = 14;
785
+ for (var j = 1; j <= 14; j++) {
786
+ row.getCell(j).border = {
787
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
788
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
789
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
790
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
791
+ };
792
+ }
793
+ row.commit();
794
+ }
795
+ for (var key in worksheet) {
796
+ if (typeof worksheet[key] === "function") {
797
+ console.log(key);
798
+ }
799
+ }
800
+ // worksheet.addTable({
801
+ // name: 'MyTable',
802
+ // ref: 'A1',
803
+ // headerRow: true,
804
+ // // totalsRow: true,
805
+ // style: {
806
+ // theme: 'TableStyleMedium2',
807
+ // showRowStripes: true,
808
+ // },
809
+ // columns: [
810
+ // { name: 'Page title', filterButton: true },
811
+ // { name: 'Page URL', filterButton: true },
812
+ // { name: 'Scan label', filterButton: true },
813
+ // { name: 'Issue ID', filterButton: true },
814
+ // { name: 'Issue type', filterButton: true },
815
+ // { name: 'Toolkit level', filterButton: true },
816
+ // { name: 'Checkpoint', filterButton: true },
817
+ // { name: 'WCAG level', filterButton: true },
818
+ // { name: 'Rule', filterButton: true },
819
+ // { name: 'Issue', filterButton: true },
820
+ // { name: 'Element', filterButton: true },
821
+ // { name: 'Code', filterButton: true },
822
+ // { name: 'Xpath', filterButton: true },
823
+ // { name: 'Help', filterButton: true },
824
+ // ],
825
+ // rows: rowArray
826
+ // });
827
+ // for (let i = 2; i <= rowArray.length + 1; i++) {
828
+ // worksheet.getRow(i).height = 14;
829
+ // for (let j = 1; j <= 14; j++) {
830
+ // worksheet.getRow(i).getCell(j).border = {
831
+ // top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
832
+ // left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
833
+ // bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
834
+ // right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
835
+ // }
836
+ // }
837
+ // worksheet.getRow(i).commit();
838
+ // }
839
+ worksheet.commit();
840
+ };
841
+ ACReporterXLSX.createDefinitionsSheet = function (workbook) {
842
+ var worksheet = workbook.addWorksheet("Definition of fields");
843
+ // "Definition of fields" title
844
+ worksheet.mergeCells('A1', "B1");
845
+ var titleRow = worksheet.getRow(1);
846
+ titleRow.height = 36; // actual is 48
847
+ titleRow.getCell(1).value = "Definition of fields";
848
+ titleRow.getCell(1).alignment = { vertical: "middle", horizontal: "left" };
849
+ titleRow.getCell(1).font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: "20" };
850
+ titleRow.getCell(1).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
851
+ var colWidthData = [
852
+ { col: 'A', width: '41.51' },
853
+ { col: 'B', width: '119.51' },
854
+ ];
855
+ for (var i = 0; i < 2; i++) {
856
+ worksheet.getColumn(colWidthData[i].col).width = colWidthData[i].width;
857
+ }
858
+ // blank row
859
+ worksheet.mergeCells('A2', "B2");
860
+ var blankRow = worksheet.getRow(2);
861
+ blankRow.height = 12; // actual is 16
862
+ // "Scan summary and Issue summary" title
863
+ worksheet.mergeCells('A3', "B3");
864
+ var summaryRow = worksheet.getRow(3);
865
+ summaryRow.height = 20; // actual is 26.75
866
+ summaryRow.getCell(1).value = "Scan summary and Issue summary";
867
+ summaryRow.getCell(1).alignment = { vertical: "middle", horizontal: "left" };
868
+ summaryRow.getCell(1).font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 16 };
869
+ summaryRow.getCell(1).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
870
+ // row 4 Field / Definition
871
+ var row4 = worksheet.getRow(4);
872
+ row4.height = 16; // actual is
873
+ row4.getCell(1).value = "Field";
874
+ row4.getCell(2).value = "Definition";
875
+ row4.getCell(1).alignment = row4.getCell(2).alignment = { vertical: "middle", horizontal: "left" };
876
+ row4.getCell(1).font = row4.getCell(2).font = { name: "Calibri", color: { argb: "FF000000" }, size: 16 };
877
+ row4.getCell(1).fill = row4.getCell(2).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFCCC0DA' } };
878
+ row4.getCell(1).border = row4.getCell(2).border = {
879
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
880
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
881
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
882
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
883
+ };
884
+ // rows 5-13
885
+ // set row height for rows 5-13
886
+ for (var i = 5; i < 14; i++) {
887
+ worksheet.getRow(i).height = 12; // results in a row height of 16
888
+ }
889
+ var rowData = [
890
+ { key1: 'Page', key2: 'Identifies the page or html file that was scanned.' },
891
+ { key1: 'Scan label', key2: 'Label for the scan. Default values can be edited in the Accessibility Checker before saving this report, or programmatically assigned in automated testing.' },
892
+ { key1: 'Violations', key2: 'Accessibility failures that need to be corrected.' },
893
+ { key1: 'Needs review', key2: 'Issues that may not be a violation. These need a manual review to identify whether there is an accessibility problem.' },
894
+ { key1: 'Recommendations', key2: 'Opportunities to apply best practices to further improve accessibility.' },
895
+ { key1: '% elements without violations', key2: 'Percentage of elements on the page that had no violations found.' },
896
+ { key1: '% elements without violations or items to review', key2: 'Percentage of elements on the page that had no violations found and no items to review.' },
897
+ { key1: 'Level 1,2,3', key2: 'Priority level defined by the IBM Equal Access Toolkit. See https://www.ibm.com/able/toolkit/plan#pace-of-completion for details.' }
898
+ ];
899
+ for (var i = 5; i < rowData.length + 5; i++) {
900
+ worksheet.getRow(i).getCell(1).font = worksheet.getRow(i).getCell(2).font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
901
+ worksheet.getRow(i).getCell(1).alignment = worksheet.getRow(i).getCell(2).alignment = { horizontal: "left" };
902
+ }
903
+ for (var i = 5; i < rowData.length + 5; i++) {
904
+ worksheet.getRow(i).getCell(1).value = rowData[i - 5].key1;
905
+ worksheet.getRow(i).getCell(2).value = rowData[i - 5].key2;
906
+ }
907
+ // "Scan summary and Issue summary" title
908
+ worksheet.mergeCells('A14', "B14");
909
+ var issuesRow = worksheet.getRow(14);
910
+ issuesRow.height = 20; // actual is 26.75
911
+ issuesRow.getCell(1).value = "Issues";
912
+ issuesRow.getCell(1).alignment = { vertical: "middle", horizontal: "left" };
913
+ issuesRow.getCell(1).font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 16 };
914
+ issuesRow.getCell(1).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
915
+ // row 15 Field / Definition
916
+ var row15 = worksheet.getRow(15);
917
+ row15.height = 16; // actual is
918
+ row15.getCell(1).value = "Field";
919
+ row15.getCell(2).value = "Definition";
920
+ row15.getCell(1).alignment = row15.getCell(2).alignment = { vertical: "middle", horizontal: "left" };
921
+ row15.getCell(1).font = row15.getCell(2).font = { name: "Calibri", color: { argb: "FF000000" }, size: 16 };
922
+ row15.getCell(1).fill = row15.getCell(2).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFCCC0DA' } };
923
+ row15.getCell(1).border = row15.getCell(2).border = {
924
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
925
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
926
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
927
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
928
+ };
929
+ // rows 16-28
930
+ // set row height for rows 16-28
931
+ for (var i = 16; i < 29; i++) {
932
+ worksheet.getRow(i).height = 12; // results in a row height of 16
933
+ }
934
+ rowData = [];
935
+ rowData = [
936
+ { key1: 'Page', key2: 'Identifies the page or html file that was scanned.' },
937
+ { key1: 'Scan label', key2: 'Label for the scan. Default values can be edited in the Accessibility Checker before saving this report, or programmatically assigned in automated testing.' },
938
+ { key1: 'Issue ID', key2: 'Identifier for this issue within this page. Rescanning the same page will produce the same issue ID. ' },
939
+ { key1: 'Issue type', key2: 'Violation, needs review, or recommendation' },
940
+ { key1: 'Toolkit level', key2: '1, 2 or 3. Priority level defined by the IBM Equal Access Toolkit. See https://www.ibm.com/able/toolkit/plan#pace-of-completion for details' },
941
+ { key1: 'Checkpoint', key2: 'Web Content Accessibility Guidelines (WCAG) checkpoints this issue falls into.' },
942
+ { key1: 'WCAG level', key2: 'A, AA or AAA. WCAG level for this issue.' },
943
+ { key1: 'Rule', key2: 'Name of the accessibility test rule that detected this issue.' },
944
+ { key1: 'Issue', key2: 'Message describing the issue.' },
945
+ { key1: 'Element', key2: 'Type of HTML element where the issue is found.' },
946
+ { key1: 'Code', key2: 'Actual HTML element where the issue is found.' },
947
+ { key1: 'Xpath', key2: 'Xpath of the HTML element where the issue is found.' },
948
+ { key1: 'Help', key2: 'Link to a more detailed description of the issue and suggested solutions.' },
949
+ ];
950
+ for (var i = 16; i < 29; i++) {
951
+ worksheet.getRow(i).getCell(1).font = worksheet.getRow(i).getCell(2).font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
952
+ worksheet.getRow(i).getCell(1).alignment = worksheet.getRow(i).getCell(2).alignment = { horizontal: "left" };
953
+ }
954
+ for (var i = 16; i < 29; i++) {
955
+ worksheet.getRow(i).getCell(1).value = rowData[i - 16].key1;
956
+ worksheet.getRow(i).getCell(2).value = rowData[i - 16].key2;
957
+ }
958
+ worksheet.commit();
959
+ };
960
+ ACReporterXLSX.countDuplicatesInArray = function (array) {
961
+ var count = {};
962
+ // let result = [];
963
+ array.forEach(function (item) {
964
+ if (count[item]) {
965
+ //@ts-ignore
966
+ count[item] += 1;
967
+ return;
968
+ }
969
+ //@ts-ignore
970
+ count[item] = 1;
971
+ });
972
+ return count;
973
+ };
974
+ ACReporterXLSX.get_element = function (code) {
975
+ if (code) {
976
+ var ind_s = code.indexOf(' ');
977
+ var ind_br = code.indexOf('>');
978
+ return (ind_s > 0 && ind_s < ind_br) ? code.substring(1, ind_s) : code.substring(1, ind_br);
979
+ }
980
+ return '';
981
+ };
982
+ ACReporterXLSX.format_date = function (timestamp) {
983
+ var date = new Date(timestamp);
984
+ return date.getFullYear() + '-' + ("00" + (date.getMonth() + 1)).slice(-2) + "-" +
985
+ ("00" + date.getDate()).slice(-2) + "-" +
986
+ ("00" + date.getHours()).slice(-2) + "-" +
987
+ ("00" + date.getMinutes()).slice(-2) + "-" +
988
+ ("00" + date.getSeconds()).slice(-2);
989
+ };
990
+ // From https://github.com/darkskyapp/string-hash/blob/master/index.js
991
+ ACReporterXLSX.stringHash = function (str) {
992
+ var hash = 5381, i = str.length;
993
+ while (i) {
994
+ hash = (hash * 33) ^ str.charCodeAt(--i);
995
+ }
996
+ /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
997
+ * integers. Since we want the results to be always positive, convert the
998
+ * signed int to an unsigned by doing an unsigned bitshift. */
999
+ return hash >>> 0;
1000
+ };
1001
+ return ACReporterXLSX;
1002
+ }());
1003
+ exports.ACReporterXLSX = ACReporterXLSX;
1004
+ //# sourceMappingURL=ACReporterXLSX.js.map