PageSourceSearch

https://www.nexans.co.nz/.resources/nexans-base/webresources/js/didomi.js?t=06.16

js nexans.co.nz collected 2026-10-07 00:05:59 UTC 2,724 bytes, 69 lines download raw bytes

1function playVideoAndHideOverlay(videoContainer) {
2
3	// Get the youtube iframe with a 'data-src' attribute
4	var iframe = videoContainer.querySelector('iframe[data-src]');
5	if(iframe) {
6		
7		// Set the 'data-src' value to the 'src' attribute
8		iframe.setAttribute('src', iframe.getAttribute('data-src'));
9		
10		// Hide the overlay
11		videoContainer.querySelector('.video-consent-overlay').style.display = 'none';
12	}
13}
14function disableVideoAndShowOverlay(videoContainer) {
15	var iframe = videoContainer.querySelector('iframe');
16	if(iframe) {
17		iframe.setAttribute('src', '');
18		videoContainer.querySelector('.video-consent-overlay').style.display = 'flex';
19	}
20}
21
22function setPositiveConsentStatusForVendor(vendor) {
23
24	// Enable the vendor and its purposes at once using a transaction
25	var transaction = Didomi.openCurrentUserStatusTransaction();
26	transaction.enableVendor(vendor.didomiId);
27	transaction.enablePurposes(vendor.purposeIds);
28	transaction.commit();
29}
30
31// Create the "didomiOnReady" listener
32window.didomiOnReady = window.didomiOnReady || [];
33window.didomiOnReady.push(function(Didomi) {
34
35	// check current user consent and display videos if enabled
36	let currentVendorStatus = Didomi.getCurrentUserStatus().vendors['youtube'];
37	if (currentVendorStatus && currentVendorStatus.enabled) {
38		document.querySelectorAll('div.youtube-container').forEach((videoContainer) => playVideoAndHideOverlay(videoContainer));
39	}
40
41	// Listen to the vendor status : It triggers the listener each time the status is changed for this vendor.
42	Didomi.addVendorStatusListener('youtube', function(consentStatus) {
43		// Check if the "consentStatus" is enabled (eg. the user agreed to the vendor and its purposes)
44		if (consentStatus.enabled === true) {
45			// Enable all YouTube videos
46			document.querySelectorAll('div.youtube-container').forEach((videoContainer) => playVideoAndHideOverlay(videoContainer));
47		} else {
48			document.querySelectorAll('div.youtube-container').forEach((videoContainer) => disableVideoAndShowOverlay(videoContainer));
49		}
50	});
51
52	// An event listener is attached to each button element
53	document.querySelectorAll('.video-consent-overlay-accept-button').forEach(function(button) {
54		button.addEventListener('click', function() {
55
56			// set-up user consent
57			Didomi.getVendors().forEach(function(vendor) {
58				if (vendor.didomiId == 'youtube') {
59					setPositiveConsentStatusForVendor(vendor);
60					return true;
61				}
62			});
63
64			// if cannot be done from didomi, display the video anyway (as user has clicked) 
65			document.querySelectorAll('div.youtube-container').forEach((videoContainer) => playVideoAndHideOverlay(videoContainer));
66		})
67	})
68
69});

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.