PageSourceSearch

https://go.walsall.gov.uk/modules/site/wc_can/js/wc_can.js?tm2z7r

js walsall.gov.uk collected 2026-10-02 04:05:50 UTC 3,074 bytes, 95 lines download raw bytes

1/**
2 * @file
3 * Adds js functionality for making privacy and ad images accessible.
4 */
5(function ($, Drupal, once) {
6  function setPrivacyIconAlt() {
7    var privacyIcon = document.querySelector('#qc-cmp2-persistent-link img');
8    if (privacyIcon && privacyIcon.alt !== 'Settings') {
9      privacyIcon.setAttribute('alt', 'Settings');
10          }
11    else {
12      // Retry in case the icon is loaded dynamically
13      setTimeout(setPrivacyIconAlt, 500);
14    }
15  }
16  document.addEventListener("DOMContentLoaded", setPrivacyIconAlt);
17  const observer = new MutationObserver((mutations) => {
18    mutations.forEach((mutation) => {
19      if (mutation.type === "attributes" && mutation.attributeName === "alt") {
20        setPrivacyIconAlt();
21      }
22    });
23  });
24  function startObserving() {
25    var privacyIcon = document.querySelector('#qc-cmp2-persistent-link img');
26    if (privacyIcon) {
27      observer.observe(privacyIcon, { attributes: true });
28    } else {
29      setTimeout(startObserving, 500);
30    }
31  }
32  startObserving();
33
34  Drupal.behaviors.WCCan_accessiblePrivacyAndAds = {
35    attach: function (context, settings) {
36      once('accessiblePrivacy', '#qc-cmp2-container', context).forEach(
37        function (element) {
38          setPrivacyIconAlt();
39          window.__canGDPR(function () {
40            setPrivacyIconAlt(); // Ensure alt remains even after GDPR changes
41          });
42          //var privacyIcon = '#qc-cmp2-persistent-link img';
43          //$(privacyIcon).attr('alt', 'Privacy Icon');
44        /*  window.__canGDPR(function () {
45
46            var waitForEl = function (selector, callback) {
47              if ($(selector).length) {
48                callback();
49              } else {
50                setTimeout(function () {
51                  waitForEl(selector, callback);
52                }, 100);
53              }
54            };
55
56            waitForEl(privacyIcon, function () {
57              $(privacyIcon).attr('alt', 'Privacy Icon');
58            });
59          });*/
60
61        }
62      );
63
64      once('accessibleAdImages', 'body', context).forEach(
65        function (element) {
66          window.__canGDPR(function () {
67            function replaceAltText() {
68              var images = $('body img');
69              $(images).each(function (index, e) {
70                var altText = $(e).attr('alt');
71                var src = $(e).attr('src');
72
73                if (!altText) {
74                  if (src && (src.indexOf('ad-delivery.net') >= 0 || src.indexOf('ad.doubleclick.net') >= 0)) {
75                    //console.log("Does not have alt text", e);
76                    $(e).attr('alt', 'Advertisement spacer');
77                  }
78                }
79              });
80            }
81
82            replaceAltText();
83            const observer = new MutationObserver(replaceAltText);
84            observer.observe(document.body, { childList: true, subtree: true });
85          /*  $(element).on('DOMSubtreeModified', function () {
86              replaceAltText();
87            });*/
88
89          });
90
91        }
92      );
93    }
94  };
95})(jQuery, Drupal, once);

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.