PageSourceSearch

https://migreeni.org/wp-content/plugins/pwd-cookie-consent/assets/js/pwd-cookie-consent.js?ver=1.1.27

js migreeni.org collected 2026-10-01 12:24:28 UTC 5,240 bytes, 179 lines download raw bytes

1var _pwdcc = {
2	// Initialize consent module
3	init: function () {
4		var bannerButtonReject = document.querySelector('.button-reject-cookies');
5		var bannerButtonAccept = document.querySelectorAll('.button-accept-cookies');
6		var bannerButtonUpdate = document.querySelector('.button-update-consent');
7		var bannerButtonClose = document.querySelector('.button-close-consent');
8		var consentValue = document.cookie.match(/pwd-cookie-consent\s*=\s*(0[^;]+)/);
9
10		if (!document.cookie.match(/show-cookie-banner\s*=\s*[^;]/)) {
11			_pwdcc.showBanner();
12		}
13
14		if (consentValue) {
15			consentValue = consentValue.pop();
16			_pwdcc.setForm(consentValue);
17			if (consentValue.includes(2)) {
18				_pwdcc.pushPaq('setCookieConsentGiven');
19			}
20		}
21
22		if (bannerButtonReject) {
23			bannerButtonReject.addEventListener('click', rejectAllCookies);
24		}
25
26		if (bannerButtonUpdate) {
27			bannerButtonUpdate.addEventListener('click', saveCustomizeConsent);
28		}
29
30		if (bannerButtonClose) {
31			bannerButtonClose.addEventListener('click', closeCustomizeConsent);
32		}
33
34		if (bannerButtonAccept) {
35			bannerButtonAccept.forEach(function(element) {
36				element.addEventListener('click', acceptAllCookies);
37			});
38		}
39	},
40	// Set cookie consent settings form to given state
41	setForm: function (consentValue) {
42		var inputValues = document.getElementsByClassName('cookie-consent-input');
43
44		for (var i = 0; i < inputValues.length; i++) {
45			if (consentValue.match(inputValues[i].value)) {
46				inputValues[i].checked = true;
47			} else {
48				inputValues[i].checked = false;
49			}
50		}
51	},
52	// Set cookie values based on consent form
53	setCookies: function() {
54		var days = 90;
55		var date = new Date();
56		var cookieDomain = document.domain.replace(/^www\./, '');
57
58		if (cookieDomain !== document.domain) {
59			document.cookie = 'pwd-cookie-consent=0;path=/;domain=.' + document.domain + ';expires=;expires=Thu, 01 Jan 1970 00:00:01 GMT';
60			document.cookie = 'show-cookie-banner=0;path=/;domain=.' + document.domain + ';expires=;expires=Thu, 01 Jan 1970 00:00:01 GMT';
61		}
62
63		var res = date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
64
65		date = new Date(res);
66
67		var inputValues = document.getElementsByClassName('cookie-consent-input');
68		var consentValue = [];
69
70		for (var i = 0; i < inputValues.length; i++) {
71			if (inputValues[i].checked) {
72				var selectionValue = parseInt(inputValues[i].value, 10);
73
74				consentValue.push(selectionValue);
75			}
76		}
77
78		document.cookie = 'pwd-cookie-consent=' + consentValue + ';path=/;domain=.' + cookieDomain + ';expires=' + date;
79		document.cookie = 'show-cookie-banner=1;path=/;domain=.' + cookieDomain + ';expires=' + date;
80
81		return consentValue;
82	},
83	// Hide cookie consent banner
84	hideBanner: function () {
85		var banner = document.getElementById('pwd-cookie-banner');
86		if (banner) {
87			banner.style.visibility = "hidden";
88			banner.hidden = true;
89		}
90	},
91	// Show cookie consent banner
92	showBanner: function () {
93		var banner = document.getElementById('pwd-cookie-banner');
94		if (banner) {
95    		banner.style.visibility = "visible";
96			banner.hidden = false;
97		}
98	},
99    // Push consent value requireCookieConsent     setCookieConsentGiven to Matomo _paq array
100    pushPaq: function (paqValue) {
101		if (typeof _paq !== 'undefined') {
102			_paq.push([paqValue]);
103		}
104	},
105	// Push analytics and ad storage denied/granted to GTM
106	pushGtag: function (analyticsStorage, adStorage) {
107		if (typeof gtag !== 'undefined') {
108			gtag('consent', 'update', { 'analytics_storage': analyticsStorage, 'ad_storage': adStorage, 'ad_personalization': adStorage, 'ad_user_data': adStorage });
109		}
110	}
111}
112
113function acceptAllCookies() {
114	_pwdcc.setForm('0,1,2,4');
115	_pwdcc.setCookies();
116    _pwdcc.hideBanner();
117	_pwdcc.pushGtag('granted', 'granted');
118    _pwdcc.pushPaq('rememberCookieConsentGiven');
119    _pwdcc.pushPaq('setCookieConsentGiven');
120	location.reload(true);
121}
122
123function rejectAllCookies() {
124	_pwdcc.setForm('0');
125	_pwdcc.setCookies();
126    _pwdcc.hideBanner();
127    _pwdcc.pushGtag('denied', 'denied');
128    _pwdcc.pushPaq('forgetCookieConsentGiven');
129	location.reload(true);
130}
131
132function saveCustomizeConsent() {
133    var consentValue = _pwdcc.setCookies();
134	var analyticsStorage = 'denied';
135	var adStorage = 'denied';
136
137	if (consentValue.includes(2)) {
138		analyticsStorage = 'granted';
139		_pwdcc.pushPaq('rememberCookieConsentGiven');
140		_pwdcc.pushPaq('setCookieConsentGiven');
141	} else {
142		_pwdcc.pushPaq('forgetCookieConsentGiven');
143	}
144
145	if (consentValue.includes(4)) {
146		adStorage = 'granted';
147	}
148
149	_pwdcc.pushGtag(analyticsStorage, adStorage);
150	location.reload(true);
151}
152
153function closeCustomizeConsent() {
154	if (!document.cookie.match(/show-cookie-banner\s*=\s*[^;]/)) {
155		_pwdcc.showBanner();
156	}
157
158	var consentValue = document.cookie.match(/pwd-cookie-consent\s*=\s*(0[^;
158]+)/);
159
160	if (consentValue) {
161		_pwdcc.setForm(consentValue.pop());
162	} else {
163		_pwdcc.setForm('0');
164	}
165}
166
167if (document.readyState !== 'loading') {
168	_pwdcc.init();
169} else {
170    document.addEventListener('DOMContentLoaded', function () {
171		_pwdcc.init();
172		var a11yDialogElement = document.getElementById('pwd-cookie-consent-customize');
173		a11yDialogElement.hidden = false;
174
175		if (a11yDialogElement) {
176			var a11yDialog = new A11yDialog(a11yDialogElement);
177		}
178	});
179}

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.