PageSourceSearch

https://currentebikes.com/wp-content/plugins/aria-accessibility-toolkit/assets/js/ariaat-frontend.js?ver=1.7.0

js currentebikes.com collected 2026-10-04 13:26:10 UTC 6,191 bytes, 172 lines download raw bytes

1document.addEventListener("DOMContentLoaded", function () {
2
3    if (!Ariaat_Data) return;
4    //console.log(Ariaat_Data)
5    // Existing ARIA logic
6    Ariaat_Data.aria.forEach(function (item) {
7        try {
8            const elements = document.querySelectorAll(item.selector);
9            elements.forEach(el => {
10                if (!el.hasAttribute(item.attribute)) {
11                    el.setAttribute(item.attribute, item.value);
12                }
13            });
14        } catch (e) {
15            console.warn("Invalid selector for aria attribute:", item.selector);
16        }
17    });
18
19    // Existing role logic
20    Ariaat_Data.roles.forEach(function (item) {
21        try {
22            const elements = document.querySelectorAll(item.selector);
23            elements.forEach(el => {
24                if (!el.hasAttribute("role")) {
25                    el.setAttribute("role", item.role);
26                }
27            });
28        } catch (e) {
29            console.warn("Invalid selector for role:", item.selector);
30        }
31    });
32
33    // New skip link target logic
34    if (Ariaat_Data.skip_link) {
35        try {
36            const el = document.querySelector(Ariaat_Data.skip_link);
37
38            if (el) {
39                const isId = Ariaat_Data.skip_link.startsWith('#');
40
41                // If it's not an ID selector and element doesn't already have an ID, assign one
42                if (!isId && !el.id) {
43                    el.id = 'ariaat-main-content';
44                }
45            }
46        } catch (e) {
47            console.warn("Invalid skip link selector:", Ariaat_Data.skip_link);
48        }
49    }
50
51    // Fix positive tabindex values (tab order accessibility)
52    if (Ariaat_Data.fix_tabindex) {
53        try {
54            const all = document.querySelectorAll('[tabindex]');
55            all.forEach(el => {
56                const value = parseInt(el.getAttribute('tabindex'), 10);
57                if (value > 0) {
58                    el.setAttribute('tabindex', '0');
59                    el.setAttribute('data-ariaat-fixed', 'tabindex');
60                }
61            });
62        } catch (e) {
63            console.warn('ARIAAT: Error fixing tabindex values:', e);
64        }
65    }
66
67    // Add accessible names/fallbacks for object, embed, svg, and canvas.
68    if (Ariaat_Data.fix_non_text_fallback) {
69        try {
70            const hasAccessibleName = (el) => {
71                const ariaLabel = (el.getAttribute('aria-label') || '').trim();
72                if (ariaLabel) {
73                    return true;
74                }
75
76                const labelledBy = (el.getAttribute('aria-labelledby') || '').trim();
77                if (labelledBy) {
78                    return labelledBy
79                        .split(/\s+/)
80                        .filter(Boolean)
81                        .some((id) => {
82                            const ref = document.getElementById(id);
83                            return !!ref && ref.textContent && ref.textContent.trim().length > 0;
84                        });
85                }
86
87                const titleAttr = (el.getAttribute('title') || '').trim();
88                return titleAttr.length > 0;
89            };
90
91            const readableLabelFromSource = (el) => {
92                const src = el.getAttribute('data') || el.getAttribute('src') || '';
93                if (!src) {
94                    return 'Media content';
95                }
96
97                const clean = src.split(/[?#]/)[0].split('/').pop() || '';
98                const name = clean
99                    .replace(/\.[a-z0-9]+$/i, '')
100                    .replace(/[-_]+/g, ' ')
101                    .trim();
102
103                return name || 'Media content';
104            };
105
106            const ensureAriaLabel = (el) => {
107                if (!hasAccessibleName(el)) {
108                    el.setAttribute('aria-label', readableLabelFromSource(el));
109                    el.setAttribute('data-ariaat-fixed', 'non_text_fallback');
110                }
111            };
112
113            const hasTextFallback = (el) => {
114                return Array.from(el.childNodes).some((node) => {
115                    return node.nodeType === Node.TEXT_NODE && node.textContent.trim().length > 0;
116                });
117            };
118
119            const ensureTextFallback = (el) => {
120                if (!hasTextFallback(el)) {
121                    const fallback = document.createTextNode(readableLabelFromSource(el));
122                    el.appendChild(fallback);
123                    el.setAttribute('data-ariaat-fixed', 'non_text_fallback');
124                }
125            };
126
127            const hasSvgAccessibleContent = (svg) => {
128                if (hasAccessibleName(svg)) {
129                    return true;
130                }
131
132                return !!svg.querySelector('title, desc');
133            };
134
135            const markSvgDecorative = (svg) => {
136                svg.setAttribute('aria-hidden', 'true');
137                svg.setAttribute('focusable', 'false');
138                svg.setAttribute('role', 'presentation');
139                svg.removeAttribute('aria-label');
140                svg.removeAttribute('aria-labelledby');
141                svg.setAttribute('data-ariaat-fixed', 'non_text_fallback');
142            };
143
144            document.querySelectorAll('object, embed, svg, canvas').forEach((el) => {
145                const tag = el.tagName.toLowerCase();
146
147                if (tag === 'svg') {
148                    if (!hasSvgAccessibleContent(el)) {
149                        markSvgDecorative(el);
150                    }
151                    return;
152                }
153
154                if (tag === 'embed') {
155                    ensureAriaLabel(el);
156                    if (!el.getAttribute('title')) {
157                        el.setAttribute('title', el.getAttribute('aria-label') || readableLabelFromSource(el));
158                        el.setAttribute('data-ariaat-fixed', 'non_text_fallback');
159                    }
160                    return;
161                }
162
163                ensureAriaLabel(el);
164                ensureTextFallback(el);
165            });
166        } catch (e) {
167            console.warn('ARIAAT: Error fixing non-text fallback issues:', e);
168        }
169    }
170
171
172});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.