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.cookiesGa = { 12 13 activate: function () { 14 var scriptIds = [ 15 'cookies_google_analytics_tracking_script', 16 'cookies_google_analytics_tracking_file' 17 ]; 18 for (var i in scriptIds) { 19 var script = document.getElementById(scriptIds[i]); 20 if (script) { 21 var content = script.innerHTML; 22 var newScript = document.createElement('script'); 23 var attributes = Array.from(script.attributes); 24 for (var attr in attributes) { 25 var name = attributes[attr].nodeName; 26 if (name !== 'type' && name !== 'id') { 27 newScript.setAttribute(name, attributes[attr].nodeValue); 28 } 29 } 30 newScript.innerHTML = content; 31 script.parentNode.replaceChild(newScript, script); 32 } 33 } 34 }, 35 36 attach: function (context) { 37 var self = this; 38 document.addEventListener('cookiesjsrUserConsent', function (event) { 39 var service = (typeof event.detail.services === 'object') ? event.detail.services : {}; 40 if (typeof service.analytics !== 'undefined' && service.analytics) { 41 self.activate(context); 42 } 43 }); 44 } 45 }; 46})(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.