apostrophecms-plugin-all-in-one-accessibility 1.0.7 → 2.0.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.
Files changed (78) hide show
  1. package/README.md +173 -168
  2. package/app/config.js +134 -0
  3. package/app/helpers.js +62 -0
  4. package/app/skynet-widget.js +509 -0
  5. package/assets/css/banners.css +77 -0
  6. package/assets/css/base.css +50 -0
  7. package/assets/css/components.css +91 -0
  8. package/assets/css/paid.css +53 -0
  9. package/assets/css/responsive.css +70 -0
  10. package/assets/css/score.css +42 -0
  11. package/assets/css/settings.css +154 -0
  12. package/assets/css/tabs.css +52 -0
  13. package/assets/css/tokens.css +53 -0
  14. package/assets/images/icons/aioa-icon-type-1.svg +1 -0
  15. package/assets/images/icons/aioa-icon-type-10.svg +1 -0
  16. package/assets/images/icons/aioa-icon-type-11.svg +1 -0
  17. package/assets/images/icons/aioa-icon-type-12.svg +1 -0
  18. package/assets/images/icons/aioa-icon-type-13.svg +1 -0
  19. package/assets/images/icons/aioa-icon-type-14.svg +29 -0
  20. package/assets/images/icons/aioa-icon-type-15.svg +26 -0
  21. package/assets/images/icons/aioa-icon-type-16.svg +17 -0
  22. package/assets/images/icons/aioa-icon-type-17.svg +24 -0
  23. package/assets/images/icons/aioa-icon-type-18.svg +20 -0
  24. package/assets/images/icons/aioa-icon-type-19.svg +25 -0
  25. package/assets/images/icons/aioa-icon-type-2.svg +1 -0
  26. package/assets/images/icons/aioa-icon-type-20.svg +24 -0
  27. package/assets/images/icons/aioa-icon-type-21.svg +28 -0
  28. package/assets/images/icons/aioa-icon-type-22.svg +21 -0
  29. package/assets/images/icons/aioa-icon-type-23.svg +21 -0
  30. package/assets/images/icons/aioa-icon-type-24.svg +21 -0
  31. package/assets/images/icons/aioa-icon-type-25.svg +15 -0
  32. package/assets/images/icons/aioa-icon-type-26.svg +23 -0
  33. package/assets/images/icons/aioa-icon-type-27.svg +21 -0
  34. package/assets/images/icons/aioa-icon-type-28.svg +27 -0
  35. package/assets/images/icons/aioa-icon-type-29.svg +25 -0
  36. package/assets/images/icons/aioa-icon-type-3.svg +1 -0
  37. package/assets/images/icons/aioa-icon-type-4.svg +16 -0
  38. package/assets/images/icons/aioa-icon-type-5.svg +1 -0
  39. package/assets/images/icons/aioa-icon-type-6.svg +1 -0
  40. package/assets/images/icons/aioa-icon-type-7.svg +1 -0
  41. package/assets/images/icons/aioa-icon-type-8.svg +1 -0
  42. package/assets/images/icons/aioa-icon-type-9.svg +1 -0
  43. package/assets/js/app.js +152 -0
  44. package/assets/js/core.js +249 -0
  45. package/assets/js/dashboard.js +97 -0
  46. package/assets/js/paid-features.js +237 -0
  47. package/assets/js/plan.js +65 -0
  48. package/assets/js/save.js +35 -0
  49. package/assets/js/score.js +130 -0
  50. package/assets/js/settings-form.js +371 -0
  51. package/assets/js/tabs.js +108 -0
  52. package/assets/js/ui.js +90 -0
  53. package/index.js +301 -15
  54. package/package.json +19 -9
  55. package/ui/apos/components/AllInOneAccessibilitySettings.vue +126 -679
  56. package/views/layout.ejs +97 -0
  57. package/views/partials/accessibility-score.ejs +37 -0
  58. package/views/partials/header.ejs +13 -0
  59. package/views/partials/lock.ejs +20 -0
  60. package/views/partials/paid/links.ejs +33 -0
  61. package/views/partials/paid/mobile-position.ejs +80 -0
  62. package/views/partials/paid/toggles.ejs +20 -0
  63. package/views/partials/paid-banner.ejs +19 -0
  64. package/views/partials/paid-features.ejs +14 -0
  65. package/views/partials/score/card.ejs +61 -0
  66. package/views/partials/settings/color.ejs +37 -0
  67. package/views/partials/settings/icon-size.ejs +43 -0
  68. package/views/partials/settings/icon-type.ejs +24 -0
  69. package/views/partials/settings/position.ejs +70 -0
  70. package/views/partials/settings/save-bar.ejs +9 -0
  71. package/views/partials/settings/widget-size.ejs +38 -0
  72. package/views/partials/settings-form.ejs +39 -0
  73. package/views/partials/site-strip.ejs +5 -0
  74. package/views/partials/status.ejs +16 -0
  75. package/views/partials/tabs.ejs +32 -0
  76. package/views/partials/upgrade-banner.ejs +34 -0
  77. package/views/scriptTag.html +7 -1
  78. package/ui/apos/apps/AllInOneAccessibilitySettings.js +0 -8
package/app/helpers.js ADDED
@@ -0,0 +1,62 @@
1
+ /**
2
+ * ---------------------------------------------------------------------------
3
+ * All in One Accessibility - view helpers
4
+ * ---------------------------------------------------------------------------
5
+ * Small functions used by index.js and the templates in views/.
6
+ */
7
+
8
+ import fs from 'node:fs';
9
+ import path from 'node:path';
10
+ import { AIOA_ROOT } from './config.js';
11
+
12
+ /** Last value of a query / form field ("a=1&a=2" gives "2"), '' when missing or not text */
13
+ export function lastValue(value) {
14
+ if (Array.isArray(value)) {
15
+ value = value[value.length - 1];
16
+ }
17
+ return typeof value === 'string' ? value : '';
18
+ }
19
+
20
+ /**
21
+ * Clean the query string sent by the platform.
22
+ *
23
+ * Platforms that cannot provide the admin details (for example headless
24
+ * setups) may send raw placeholders such as "{email}". Those are treated as
25
+ * missing values, so the website is registered with no-reply@<website>.
26
+ */
27
+ export function aioaRequest(query) {
28
+ const cleaned = {};
29
+ for (const [key, raw] of Object.entries(query || {})) {
30
+ const value = lastValue(raw);
31
+ cleaned[key] = /^\{.*\}$/.test(value.trim()) ? '' : value.replace(/[{}]/g, '').trim();
32
+ }
33
+ return cleaned;
34
+ }
35
+
36
+ /**
37
+ * URL of a file in /assets with a version stamp (file modified time), so
38
+ * browsers always load the latest CSS / JS after an update.
39
+ */
40
+ export function asset(file) {
41
+ let stamp = 1;
42
+ try {
43
+ stamp = Math.floor(fs.statSync(path.join(AIOA_ROOT, 'assets', file)).mtimeMs / 1000);
44
+ } catch (err) {
45
+ // missing file: keep 1
46
+ }
47
+ return 'assets/' + file + '?v=' + stamp;
48
+ }
49
+
50
+ /** Element id slug: "top_left" => "top-left", "aioa-extra-small-icon" => "extra-small". */
51
+ export function aioaSlug(value) {
52
+ return value.replaceAll('aioa-', '').replaceAll('-icon', '').replaceAll('_', '-');
53
+ }
54
+
55
+ /** JSON for a <script type="application/json"> block: <, >, & and ' are escaped */
56
+ export function jsonForScript(value) {
57
+ return JSON.stringify(value)
58
+ .replace(/</g, '\\u003C')
59
+ .replace(/>/g, '\\u003E')
60
+ .replace(/&/g, '\\u0026')
61
+ .replace(/'/g, '\\u0027');
62
+ }
@@ -0,0 +1,509 @@
1
+ /**
2
+ * ---------------------------------------------------------------------------
3
+ * All in One Accessibility - API service
4
+ * ---------------------------------------------------------------------------
5
+ * Server side calls to the Skynet Technologies API. Used by the route in
6
+ * index.js (POST <settingsPath>/route?action=<name>), which the settings page
7
+ * calls with fetch(). Every exported action resolves with an object that the
8
+ * route sends back as JSON. index.js also asks getWidgetRegion() which widget
9
+ * script (global or EU) the website needs.
10
+ *
11
+ * Loading never registers: fetchWidgetSettings answers {"not_registered": true}
12
+ * for a new website. The page then calls registerDomain once, with the EU flag
13
+ * (no_required_eu, from ipapi.co in the browser) and the admin's name and email
14
+ * from the platform, or the website and no-reply@<website>.
15
+ *
16
+ * Saving the widget settings is done by the browser directly
17
+ * (assets/js/save.js -> widget-setting-update-platform).
18
+ *
19
+ * No dependencies: it uses Node's built-in fetch (Node.js 18+).
20
+ */
21
+
22
+ import * as config from './config.js';
23
+
24
+ // Widget position for mobile (Paid Features): missing from widget-settings, see withMobileFields()
25
+ const MOBILE_FIELDS = [
26
+ 'is_mobile_position',
27
+ 'is_widget_custom_position_mobile',
28
+ 'widget_position_mobile',
29
+ 'widget_position_top_mobile',
30
+ 'widget_position_bottom_mobile',
31
+ 'widget_position_left_mobile',
32
+ 'widget_position_right_mobile',
33
+ 'widget_position_vertical_center_offset_mobile',
34
+ 'widget_position_horizontal_center_offset_mobile',
35
+ ];
36
+
37
+ // Website host: a domain name such as "example.com", or "localhost". Same rule in every language.
38
+ const DOMAIN_RE = /^(?:localhost|(?=.{3,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63})$/;
39
+
40
+ // An email address the registration accepts (the same cases as PHP's FILTER_VALIDATE_EMAIL)
41
+ const EMAIL_RE = /^(?=.{1,254}$)(?=[^@]{1,64}@)[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\.)+(?![0-9]+$)[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?$/;
42
+
43
+ /* =======================================================================
44
+ * Validation helpers
45
+ * ===================================================================== */
46
+
47
+ /** Normalize user input such as "https://www.Example.com/shop" to "www.example.com". */
48
+ export function normalizeDomain(value) {
49
+ return String(value ?? '').trim().toLowerCase()
50
+ .replace(/^[a-z][a-z0-9+.-]*:\/\//, '') // scheme
51
+ .replace(/[/?#].*$/, '') // path, query, hash
52
+ .replace(/:\d+$/, '') // port
53
+ .replace(/^\.+|\.+$/g, '');
54
+ }
55
+
56
+ /**
57
+ * True for a website host: a domain name such as "example.com", or "localhost"
58
+ * (platforms that run on a local machine). IP addresses such as "127.0.0.1" are not
59
+ * accepted. Skynet keeps one registration per host, without the port.
60
+ */
61
+ export function isValidDomain(domain) {
62
+ return DOMAIN_RE.test(domain);
63
+ }
64
+
65
+ export function isValidEmail(email) {
66
+ return EMAIL_RE.test(email);
67
+ }
68
+
69
+ /* =======================================================================
70
+ * Actions (called from the route in index.js)
71
+ * ===================================================================== */
72
+
73
+ /**
74
+ * Load the widget settings of a domain. Never registers anything: a domain that
75
+ * is not registered yet answers {"not_registered": true}, and the page then calls
76
+ * registerDomain (once).
77
+ *
78
+ * @param {{url?: string}} req
79
+ * @returns {Promise<object>} settings | {not_registered: true} | {error}
80
+ */
81
+ export async function fetchWidgetSettings(req) {
82
+ const url = normalizeDomain(req.url);
83
+
84
+ if (!isValidDomain(url)) {
85
+ return { error: 'A valid domain is required, for example example.com or localhost.' };
86
+ }
87
+
88
+ const data = await getSettingsData(url);
89
+
90
+ if (data === false) {
91
+ return { error: 'Unable to load widget settings. Please try again.' };
92
+ }
93
+
94
+ if (data === null) {
95
+ return { not_registered: true };
96
+ }
97
+
98
+ return data;
99
+ }
100
+
101
+ /**
102
+ * Register the free widget for a domain (add-user-domain), then wait for its settings.
103
+ * The page calls it only after fetchWidgetSettings answered not_registered, and at
104
+ * most once per website (assets/js/app.js). widget-settings is checked again first,
105
+ * so a website that is already registered is never registered twice, and nothing is
106
+ * registered when the API can't be reached.
107
+ *
108
+ * @param {{url?: string, username?: string, email?: string, no_required_eu?: string}} req
109
+ * no_required_eu: "0" EU (ipapi.co in_eu true) | "1" not EU (anything else)
110
+ * @returns {Promise<object>} settings | {error, pending: true} | {error}
111
+ */
112
+ export async function registerDomain(req) {
113
+ const url = normalizeDomain(req.url);
114
+
115
+ if (!isValidDomain(url)) {
116
+ return { error: 'A valid domain is required, for example example.com or localhost.' };
117
+ }
118
+
119
+ let data = await getSettingsData(url);
120
+
121
+ // API not reachable: never register a website that may already be registered
122
+ if (data === false) {
123
+ return { error: 'Unable to load widget settings. Please try again.' };
124
+ }
125
+
126
+ if (data === null) {
127
+ const noRequiredEu = req.no_required_eu === '0' ? '0' : '1';
128
+ await register(url, req.username ?? '', req.email ?? '', noRequiredEu);
129
+ data = await waitForSettings(url);
130
+ }
131
+
132
+ // Registered, but the settings did not appear yet: the page waits instead of registering again
133
+ if (data === null) {
134
+ return {
135
+ error: 'Your website was registered, but its settings are not ready yet. Please try again in a moment.',
136
+ pending: true,
137
+ };
138
+ }
139
+
140
+ return data;
141
+ }
142
+
143
+ /**
144
+ * Dashboard sign-in link of a paid plan: "manage_domain" from check-website.
145
+ * The page loads it once the plan is known as paid, so the "Dashboard" button
146
+ * opens it at once. Only the link is passed on; api_key and the rest stay here.
147
+ * An unknown website gets an empty manage_domain.
148
+ *
149
+ * @param {{url?: string}} req
150
+ * @returns {Promise<object>} {link: "https://..."} | {error}
151
+ */
152
+ export async function getDashboardLink(req) {
153
+ const url = normalizeDomain(req.url);
154
+ if (!isValidDomain(url)) {
155
+ return { error: 'A valid domain is required, for example example.com or localhost.' };
156
+ }
157
+
158
+ const res = await post(config.AIOA_CHECK_WEBSITE_API, { domain: url });
159
+ if (res === null) {
160
+ return { error: 'Unable to load the dashboard link right now.' };
161
+ }
162
+
163
+ const link = toStr(res.manage_domain);
164
+ if (!/^https:\/\//i.test(link)) {
165
+ return { error: 'No dashboard link was found for ' + url + '.' };
166
+ }
167
+
168
+ return { link: link };
169
+ }
170
+
171
+ /**
172
+ * Accessibility Score tab: the scan results of a domain, trimmed to what the score card shows,
173
+ * with Alt Text Remediated from check-website's alt_count (asked only when there are scan results).
174
+ *
175
+ * No finished results yet (the page shows "Scanning in progress"):
176
+ * not scanned yet {"Data": [], "status": 404, "msg": "Domain details not found or package information is unavailable."}
177
+ * scan running {"Data": {...partial...}, "status": 201, "msg": "Domain scan is currently in progress. ..."}
178
+ * The partial Data has a running score but no summary, page counts or last scan.
179
+ *
180
+ * @param {{url?: string}} req
181
+ * @returns {Promise<object>} score summary | {no_scan: true, in_progress, message} | {error}
182
+ */
183
+ export async function getScanDetails(req) {
184
+ const url = normalizeDomain(req.url);
185
+ if (!isValidDomain(url)) {
186
+ return { error: 'Enter a valid domain, for example example.com or localhost' };
187
+ }
188
+
189
+ const res = await post(config.AIOA_SCAN_API, { lang_code: config.AIOA_SCAN_LANG, website: base64(url) });
190
+ if (res === null) {
191
+ return { error: 'Unable to load the accessibility score right now. Please try again.' };
192
+ }
193
+
194
+ const data = res.Data;
195
+ const inProgress = toInt(res.status) === 201;
196
+ if (inProgress || isEmpty(data) || typeof data !== 'object') {
197
+ return { no_scan: true, in_progress: inProgress, message: toStr(res.msg) };
198
+ }
199
+
200
+ // Alt Text Remediated comes from check-website (alt_count)
201
+ const site = await post(config.AIOA_CHECK_WEBSITE_API, { domain: url });
202
+
203
+ return scoreSummary(Array.isArray(data) ? {} : data, isObject(site) ? site.alt_count : null);
204
+ }
205
+
206
+ /**
207
+ * Widget script region of a registered website, read by index.js for the widget script tag:
208
+ * "eu" registered by an admin in the EU (no_required_eu = 0): the EU widget script
209
+ * "global" any other registered website
210
+ * null not registered yet, invalid domain or the API could not be reached
211
+ *
212
+ * @param {string} domain
213
+ * @param {number} [timeoutSeconds] defaults to AIOA_HTTP_TIMEOUT
214
+ * @returns {Promise<"eu"|"global"|null>}
215
+ */
216
+ export async function getWidgetRegion(domain, timeoutSeconds) {
217
+ const url = normalizeDomain(domain);
218
+ if (!isValidDomain(url)) {
219
+ return null;
220
+ }
221
+ const res = await post(config.AIOA_API_BASE + 'widget-settings', { website_url: url }, timeoutSeconds);
222
+ const data = res ? res.Data : null;
223
+ if (!isObject(data) || isEmpty(data)) {
224
+ return null;
225
+ }
226
+ return toStr(data.no_required_eu) === '0' ? 'eu' : 'global';
227
+ }
228
+
229
+ /* =======================================================================
230
+ * Internal
231
+ * ===================================================================== */
232
+
233
+ /**
234
+ * Register the free widget for a domain (add-user-domain).
235
+ * name the admin's name, or the website when the platform sent none
236
+ * email the admin's email, or no-reply@<website> (without "www.") when the platform sent none
237
+ * no_required_eu '0' the admin is in the EU, '1' not in the EU (ipapi.co in_eu, checked by the browser)
238
+ * aioa_icon_type, aioa_icon_size, aioa_icon_size_mb
239
+ * the widget icon defaults for a new website: icon type 1, Medium size on desktop and mobile
240
+ *
241
+ * @returns {Promise<object|null>} Raw API response
242
+ */
243
+ function register(url, name, email, noRequiredEu) {
244
+ name = String(name).trim();
245
+ email = String(email).trim();
246
+
247
+ const postFields = {
248
+ name: name !== '' ? name : url,
249
+ email: isValidEmail(email) ? email : 'no-reply@' + url.replace(/^www\./, ''),
250
+ company_name: '',
251
+ website: base64(url),
252
+ package_type: 'free-widget',
253
+ start_date: new Date().toISOString().slice(0, 19) + '+0000', // UTC, e.g. 2026-11-02T09:30:00+0000
254
+ end_date: '',
255
+ price: '',
256
+ discount_price: '0',
257
+ platform: config.AIOA_PLATFORM,
258
+ api_key: '',
259
+ is_trial_period: '',
260
+ is_free_widget: '1',
261
+ no_required_eu: noRequiredEu,
262
+ bill_address: '',
263
+ country: '',
264
+ state: '',
265
+ city: '',
266
+ post_code: '',
267
+ transaction_id: '',
268
+ subscr_id: '',
269
+ payment_source: '',
270
+ // Widget icon defaults for a new website: icon type 1, Medium size on desktop and mobile
271
+ aioa_icon_type: 'aioa-icon-type-1',
272
+ aioa_icon_size: 'aioa-medium-icon',
273
+ aioa_icon_size_mb: 'aioa-medium-icon',
274
+ };
275
+
276
+ return apiPost('add-user-domain', postFields);
277
+ }
278
+
279
+ /**
280
+ * Settings of a registered domain, null when the domain is not registered,
281
+ * or false when the API could not be reached or did not answer with JSON.
282
+ *
283
+ * @returns {Promise<object|false|null>}
284
+ */
285
+ async function getSettingsData(url) {
286
+ const res = await apiPost('widget-settings', { website_url: url });
287
+ if (res === null) {
288
+ return false;
289
+ }
290
+ const data = res.Data;
291
+ if (isEmpty(data) || typeof data !== 'object' || Array.isArray(data)) {
292
+ return null;
293
+ }
294
+ return withMobileFields(url, data);
295
+ }
296
+
297
+ /**
298
+ * Add the widget position for mobile (Paid Features) to the settings of a paid plan.
299
+ * widget-settings leaves these fields out; the widget's own settings endpoint
300
+ * (AIOA_WIDGET_SETTINGS_API) returns them. Fields widget-settings already sent win.
301
+ * When the call fails the settings are returned as they are and the page uses its defaults.
302
+ */
303
+ async function withMobileFields(url, data) {
304
+ // Same rule as the page: anything but is_free_widget = 1 is a paid plan
305
+ if (toInt(data.is_free_widget) === 1) {
306
+ return data;
307
+ }
308
+
309
+ const res = await post(config.AIOA_WIDGET_SETTINGS_API, { website_url: url });
310
+ const widget = res ? res.Data : null;
311
+ if (!widget || typeof widget !== 'object' || Array.isArray(widget)) {
312
+ return data;
313
+ }
314
+
315
+ for (const field of MOBILE_FIELDS) {
316
+ if (!Object.hasOwn(data, field) && Object.hasOwn(widget, field)) {
317
+ data[field] = widget[field];
318
+ }
319
+ }
320
+ return data;
321
+ }
322
+
323
+ /** Poll for the settings of a domain that was just registered (the API needs a moment to sync). */
324
+ async function waitForSettings(url, attempts = 3) {
325
+ for (let i = 0; i < attempts; i++) {
326
+ await new Promise((resolve) => setTimeout(resolve, 1000));
327
+ const data = await getSettingsData(url);
328
+ if (data && typeof data === 'object') {
329
+ return data;
330
+ }
331
+ }
332
+ return null;
333
+ }
334
+
335
+ /**
336
+ * Score card values from the scanner's "Data":
337
+ * score success_percentage, rounded, 0 - 99 (100 is shown as 99), labeled with AIOA_SCORE_LEVELS
338
+ * violations fixed / total violations (summary)
339
+ * alt_text images from check-website's alt_count (see altText)
340
+ * pages scanned / selected pages
341
+ * A check's total is its fixed plus its still open (total_error) violations.
342
+ */
343
+ function scoreSummary(data, altCount) {
344
+ // Up to 99, never 100: a scanner score of 100 is shown as 99
345
+ const score = Math.max(0, Math.min(99, phpRound(toFloat(data.success_percentage))));
346
+
347
+ let level = config.AIOA_SCORE_LEVELS[config.AIOA_SCORE_LEVELS.length - 1];
348
+ for (const candidate of config.AIOA_SCORE_LEVELS) {
349
+ if (score >= candidate[0]) {
350
+ level = candidate;
351
+ break;
352
+ }
353
+ }
354
+
355
+ // Every check: fixed by the widget, or still waiting for a manual fix
356
+ const groups = isObject(data.acessibility_voilation) ? data.acessibility_voilation : {}; // API spelling
357
+ const checks = [...asList(groups.voilation_remediated), ...asList(groups.require_manual_action)];
358
+
359
+ let fixed = 0;
360
+ let total = 0;
361
+ for (const check of checks) {
362
+ if (!isObject(check)) {
363
+ continue;
364
+ }
365
+ const checkFixed = toInt(check.total_fixed);
366
+ const checkTotal = checkFixed + toInt(check.total_error);
367
+ fixed += checkFixed;
368
+ total += checkTotal;
369
+ }
370
+
371
+ // The summary wins when the API sends it
372
+ const summary = data.summary;
373
+ if (isObject(summary) && summary.total_violations != null && summary.total_fixed != null) {
374
+ fixed = toInt(summary.total_fixed);
375
+ total = toInt(summary.total_violations);
376
+ }
377
+
378
+ const reportUrl = toStr(data.pdf_report_url);
379
+
380
+ return {
381
+ domain: toStr(data.domain),
382
+ score: score,
383
+ level: level[1],
384
+ status: level[2],
385
+ violations: ratio(fixed, total),
386
+ alt_text: altText(altCount),
387
+ pages: {
388
+ scanned: toInt(data.total_scan_pages),
389
+ total: toInt(data.total_selected_pages ?? data.total_pages ?? 0),
390
+ },
391
+ last_scan: toStr(data.last_scan),
392
+ report_url: /^https:\/\//i.test(reportUrl) ? reportUrl : '',
393
+ };
394
+ }
395
+
396
+ /**
397
+ * Alt Text Remediated from check-website's alt_count. Only images with a missing alt tag
398
+ * still need work:
399
+ * fixed total_decorative_images + total_update_alt_text + total_other_images
400
+ * total fixed + total_missing_alt_tag
401
+ * No alt_count (check-website failed or sent none): 0 / 0.
402
+ */
403
+ function altText(altCount) {
404
+ const count = isObject(altCount) ? altCount : {};
405
+ const images = (key) => Math.max(0, toInt(count[key]));
406
+
407
+ const fixed = images('total_decorative_images') + images('total_update_alt_text') + images('total_other_images');
408
+ return ratio(fixed, fixed + images('total_missing_alt_tag'));
409
+ }
410
+
411
+ /** {fixed: 38, total: 44, percentage: 86.36} */
412
+ function ratio(fixed, total) {
413
+ return {
414
+ fixed: fixed,
415
+ total: total,
416
+ percentage: total > 0 ? phpRound(fixed / total * 100, 2) : 0,
417
+ };
418
+ }
419
+
420
+ /** POST form fields to a Skynet API endpoint (relative to AIOA_API_BASE). */
421
+ function apiPost(endpoint, fields) {
422
+ return post(config.AIOA_API_BASE + endpoint, fields);
423
+ }
424
+
425
+ /**
426
+ * POST form fields to a URL and decode the JSON answer.
427
+ *
428
+ * @returns {Promise<object|null>} Decoded JSON object (also for 4xx answers with a JSON body),
429
+ * or null on a network / JSON error. Redirects are not followed; TLS certificates are verified.
430
+ */
431
+ async function post(url, fields, timeoutSeconds = config.AIOA_HTTP_TIMEOUT) {
432
+ try {
433
+ const response = await fetch(url, {
434
+ method: 'POST',
435
+ headers: {
436
+ // The API firewall rejects requests without a User-Agent (HTTP 406)
437
+ 'User-Agent': config.AIOA_USER_AGENT,
438
+ 'Accept': 'application/json',
439
+ 'Content-Type': 'application/x-www-form-urlencoded',
440
+ },
441
+ body: new URLSearchParams(fields).toString(),
442
+ redirect: 'manual',
443
+ signal: AbortSignal.timeout(timeoutSeconds * 1000),
444
+ });
445
+ const decoded = JSON.parse(await response.text());
446
+ return isObject(decoded) ? decoded : null;
447
+ } catch (err) {
448
+ return null; // network error, timeout or not JSON
449
+ }
450
+ }
451
+
452
+ /* ---------- Small conversions (API values may be numbers, numeric strings or null) ---------- */
453
+
454
+ function toFloat(value) {
455
+ if (typeof value === 'boolean') {
456
+ return value ? 1 : 0;
457
+ }
458
+ if (typeof value === 'number') {
459
+ return Number.isFinite(value) ? value : 0;
460
+ }
461
+ if (typeof value === 'string') {
462
+ const match = /^\s*[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/.exec(value);
463
+ return match ? parseFloat(match[0]) : 0;
464
+ }
465
+ return 0;
466
+ }
467
+
468
+ function toInt(value) {
469
+ const number = toFloat(value);
470
+ return Number.isFinite(number) ? Math.trunc(number) : 0;
471
+ }
472
+
473
+ function toStr(value) {
474
+ if (value === null || value === undefined || value === false || typeof value === 'object') {
475
+ return '';
476
+ }
477
+ return value === true ? '1' : String(value);
478
+ }
479
+
480
+ function isObject(value) {
481
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
482
+ }
483
+
484
+ function asList(value) {
485
+ return Array.isArray(value) ? value : [];
486
+ }
487
+
488
+ /** Empty like PHP's empty(): missing, null, false, 0, "", "0", [] or {} */
489
+ function isEmpty(value) {
490
+ if (value === null || value === undefined || value === false || value === 0 || value === '' || value === '0') {
491
+ return true;
492
+ }
493
+ if (typeof value === 'object') {
494
+ return Object.keys(value).length === 0;
495
+ }
496
+ return false;
497
+ }
498
+
499
+ /** Round half away from zero, like PHP's round() */
500
+ function phpRound(value, precision = 0) {
501
+ const factor = 10 ** precision;
502
+ const shifted = Number((Math.abs(value) * factor).toPrecision(15));
503
+ const result = Math.floor(shifted + 0.5) / factor;
504
+ return value < 0 ? -result : result;
505
+ }
506
+
507
+ function base64(value) {
508
+ return Buffer.from(value, 'utf8').toString('base64');
509
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * All in One Accessibility settings
3
+ * banners.css
4
+ *
5
+ * Plan notices above the settings (only one is visible):
6
+ * #free_plan_upgrade_block free plan - purple "Upgrade to Paid Plan" banner + NOTE
7
+ * #paid_plan_block paid plan - "Dashboard"
8
+ * and the "Widget installed on <domain>" line.
9
+ */
10
+
11
+ /* ---------- Notice ---------- */
12
+
13
+ .aioa-notice {
14
+ display: flex; align-items: center; flex-wrap: wrap; gap: 14px 24px; padding: 20px 22px;
15
+ border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
16
+ }
17
+ .aioa-notice-body { flex: 1; min-width: 240px; }
18
+ .aioa-notice h2 { margin: 7px 0 3px; font-size: 18px; font-weight: 700; }
19
+ .aioa-notice-body p:last-child { color: var(--muted); }
20
+ .aioa-notice-action { display: flex; flex-direction: column; align-items: center; gap: 5px; }
21
+
22
+ /* Small status label: "Paid plan active" */
23
+ .aioa-tag {
24
+ display: inline-block; padding: 2px 9px; border-radius: 5px;
25
+ font-size: 12.5px; font-weight: 600; background: var(--accent-soft); color: var(--accent);
26
+ }
27
+ .aioa-tag.is-success { background: var(--success-soft); color: var(--success); }
28
+
29
+ /* ---------- Upgrade banner (free plan) ---------- */
30
+
31
+ /* Solid brand purple (no gradient or glows) with a faded figure in the corner */
32
+ .aioa-upgrade {
33
+ position: relative; overflow: hidden; isolation: isolate; padding: 23px 26px 18px; border-radius: var(--radius); color: #fff;
34
+ background: #420083;
35
+ }
36
+ .aioa-upgrade-watermark { position: absolute; right: -35px; top: -27px; z-index: -1; width: 205px; height: 205px; opacity: .08; pointer-events: none; }
37
+
38
+ .aioa-upgrade-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 18px 24px; }
39
+ .aioa-upgrade-intro { flex: 1; min-width: 240px; }
40
+ .aioa-upgrade-intro > p:not(.aioa-upgrade-tag) { color: #e6dbff; }
41
+ .aioa-upgrade-intro strong { color: #fff; }
42
+ .aioa-upgrade h2 { margin: 10px 0 3px; font-size: 23px; font-weight: 700; }
43
+
44
+ /* "Free plan active" label with a green dot */
45
+ .aioa-upgrade-tag {
46
+ display: inline-flex; align-items: center; gap: 7px; padding: 2px 9px; border-radius: 5px;
47
+ font-size: 12.5px; font-weight: 600; background: rgba(255, 255, 255, .14); color: #f0e8ff;
48
+ }
49
+ .aioa-upgrade-tag i { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; }
50
+
51
+ /* 190+ languages / 12 profiles */
52
+ .aioa-upgrade-points { display: flex; flex-wrap: wrap; gap: 5px 20px; margin: 12px 0 0; padding: 0; list-style: none; font-weight: 600; }
53
+ .aioa-upgrade-points li { display: flex; align-items: center; gap: 7px; }
54
+ .aioa-upgrade-points li::before {
55
+ content: ""; width: 18px; height: 18px; flex-shrink: 0; border-radius: 50%;
56
+ background: rgba(255, 255, 255, .2) var(--check-white) center / 11px no-repeat;
57
+ }
58
+
59
+ .aioa-upgrade-cta { display: flex; flex-direction: column; align-items: center; gap: 7px; }
60
+ .aioa-upgrade-cta small { font-size: 12.5px; color: #dccbff; }
61
+ .aioa-btn-white {
62
+ display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 44px; padding: 0 20px;
63
+ border-radius: var(--radius-sm); background: #fff; color: #420083; font-weight: 700; text-decoration: none; white-space: nowrap;
64
+ }
65
+ .aioa-btn-white:hover { background: #f3eefa; }
66
+ .aioa-btn-white svg { width: 17px; height: 17px; }
67
+
68
+ .aioa-upgrade-note { margin-top: 16px; padding-top: 13px; border-top: 1px solid rgba(255, 255, 255, .16); font-size: 13.5px; color: #d3c1f3; }
69
+ .aioa-upgrade-note b { color: #fff; }
70
+
71
+ /* ---------- Site line ---------- */
72
+
73
+ /* Dot and text on one row; a long domain wraps inside the text */
74
+ .aioa-site { display: flex; align-items: flex-start; gap: 9px; margin: 14px 2px 0; color: var(--muted); }
75
+ .aioa-site strong { color: var(--text); font-weight: 600; word-break: break-all; }
76
+ .aioa-site-dot { width: 9px; height: 9px; flex-shrink: 0; margin-top: 7px; border-radius: 50%; background: var(--success); }
77
+ #site-text { min-width: 0; }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * All in One Accessibility settings
3
+ * base.css
4
+ *
5
+ * Reset, typography (system font), page layout and the header.
6
+ */
7
+
8
+ /* ---------- Reset ---------- */
9
+
10
+ *, *::before, *::after { box-sizing: border-box; }
11
+ [hidden] { display: none !important; }
12
+
13
+ body {
14
+ margin: 0;
15
+ font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
16
+ font-size: 15px;
17
+ line-height: 1.5;
18
+ color: var(--text);
19
+ background: var(--bg);
20
+ -webkit-font-smoothing: antialiased;
21
+ }
22
+
23
+ h1, h2, h3, p { margin: 0; }
24
+ a { color: var(--link); }
25
+ button, input, select { font: inherit; color: inherit; }
26
+ :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
27
+
28
+ /* Hidden on screen, still read by screen readers */
29
+ .visually-hidden {
30
+ position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
31
+ overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
32
+ }
33
+
34
+ /* ---------- Page ---------- */
35
+
36
+ .aioa-page { max-width: 900px; margin: 0 auto; padding: 24px 20px 44px; }
37
+
38
+ /* ---------- Header ---------- */
39
+
40
+ .aioa-header {
41
+ display: flex; align-items: center; justify-content: space-between; gap: 16px;
42
+ margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--border);
43
+ }
44
+ .aioa-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
45
+ .aioa-logo { width: 48px; height: 48px; flex-shrink: 0; }
46
+ .aioa-logo-circle { fill: var(--brand); } /* official logo purple */
47
+ .aioa-brand h1 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; line-height: 1.2; }
48
+ .aioa-brand h1 sup { font-size: .55em; font-weight: 700; }
49
+ .aioa-brand p { font-size: 13.5px; color: var(--muted); }
50
+