1/** 2 * @file 3 * Defines Javascript behaviors for the cookies module. 4 */ 5(function (Drupal) { 6 'use strict'; 7 8 /** 9 * Define defaults. 10 */ 11 Drupal.behaviors.cookiesMatomo = { 12 13 consentGiven: function () { 14 var scriptIds = [ 15 'cookies_matomo' 16 ]; 17 for (var i in scriptIds) { 18 var script = document.getElementById(scriptIds[i]); 19 if (script && script.nodeName === 'SCRIPT') { 20 var content = script.innerHTML; 21 var newScript = document.createElement('script'); 22 var attributes = Array.from(script.attributes); 23 for (var attr in attributes) { 24 var name = attributes[attr].nodeName; 25 if (name !== 'type' && name !== 'id') { 26 newScript.setAttribute(name, attributes[attr].nodeValue); 27 } 28 } 29 newScript.innerHTML = content; 30 script.parentNode.replaceChild(newScript, script); 31 } 32 } 33 }, 34 35 attach: function (context) { 36 var self = this; 37 document.addEventListener('cookiesjsrUserConsent', function (event) { 38 var service = (typeof event.detail.services === 'object') ? event.detail.services : {}; 39 if (typeof service.matomo !== 'undefined' && service.matomo) { 40 self.consentGiven(context); 41 } 42 }); 43 } 44 }; 45})(Drupal);
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.