PageSourceSearch

https://www.socialchamp.com/wp-content/themes/bricks-child/src/js/home-a11y.js?ver=fccf46484daa

js socialchamp.com collected 2026-10-02 03:02:41 UTC 2,980 bytes, 61 lines download raw bytes

1/* Homepage a11y/media: video posters + prefers-reduced-motion handling.
2   Shipped 2026-07-24 with the preview-promotion (design plan Phase 0.6). */
3(function () {
4  function run() {
5    var posters = {
6      'brxe-xrbzbt': 'https://www.socialchamp.com/wp-content/uploads/2026/07/hero-poster.jpg',
7      'brxe-vgihuo': 'https://www.socialchamp.com/wp-content/uploads/2026/07/walkthrough-poster.jpg'
8    };
9    Object.keys(posters).forEach(function (id) {
10      var host = document.getElementById(id);
11      var v = host ? (host.tagName === 'VIDEO' ? host : host.querySelector('video')) : null;
12      if (v && !v.getAttribute('poster')) v.setAttribute('poster', posters[id]);
13    });
14    /* Six links all named exactly "Learn more", pointing at six DIFFERENT
15       feature pages. In a screen reader's link list that reads as six
16       identical entries with no way to tell them apart (WCAG 2.4.4 / 2.4.9).
17       The visible text stays "Learn more" — the design is unchanged — and an
18       aria-label supplies the distinguishing name.
19
20       The label is derived from the href slug, not from a nearby heading:
21       every one of these cards sits under the SAME section heading
22       ("Everything you need to scale your agency"), so heading-based labels
23       would all collide again. The slug is the only per-card signal.
24       href values are trimmed because at least one carries a leading space. */
25    var ACRONYMS = { ai: 'AI', seo: 'SEO', crm: 'CRM' };
26    document.querySelectorAll('a[href*="/features/"]').forEach(function (a) {
27      if (!/^learn more$/i.test((a.textContent || '').trim())) return;
28      if (a.getAttribute('aria-label')) return;
29      var href = (a.getAttribute('href') || '').trim();
30      var m = href.replace(/[?#].*$/, '').replace(/\/+$/, '').split('/').pop();
31      if (!m) return;
32      var name = m.split('-').map(function (w) {
33        if (ACRONYMS[w]) return ACRONYMS[w];
34        return w.charAt(0).toUpperCase() + w.slice(1);
35      }).join(' ');
36      a.setAttribute('aria-label', 'Learn more about ' + name);
37    });
38
39    if (window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
40      document.querySelectorAll('video[autoplay]').forEach(function (v) {
41        v.removeAttribute('autoplay');
42        v.pause();
43      });
44      var pauseSplide = function () {
45        var inst = window.bricksData && window.bricksData.splideInstances;
46        if (!inst) return false;
47        Object.keys(inst).forEach(function (k) {
48          var sp = inst[k];
49          if (sp && sp.Components && sp.Components.Autoplay) {
50            try { sp.Components.Autoplay.pause(); } catch (e) { /* not started */ }
51          }
52        });
53        return true;
54      };
55      if (!pauseSplide()) {
56        window.addEventListener('load', function () { setTimeout(pauseSplide, 400); });
57      }
58    }
59  }
60  if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', run); } else { run(); }
61})();

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.