const ConsentEmbedded = (function () { function init() { manageIframes(); manageVideos(); } function manageIframes() { const iframes = document.querySelectorAll('iframe'); iframes.forEach(function (iframe) { if (iframe.src != "" && (!hasAcceptedVendor(iframe.src)||!hasAcceptedAllPurposes())) stopIframe(iframe); }); } function manageVideos() { const videos = document.querySelectorAll('video'); videos.forEach(function (video) { const source = video.querySelector('source').getAttribute('src'); if (!source.match('vidal.fr')&&(!hasAcceptedVendor(source)||!hasAcceptedAllPurposes())) stopVideo(video); }); } function stopIframe(iframe) { const src = iframe.getAttribute("src"); getHtmlUnAuthorized(src,function (content){replaceElement(content,iframe);}); } function stopVideo(video) { const src = video.querySelector('source').getAttribute('src'); getHtmlUnAuthorized(src,function (content){replaceElement(content,video);}); } function getHtmlUnAuthorized(url, after) { const href = "tiers-non-autorise.html?render=true&url=" + url; makeRequest(href, function (response){ if (response.content.error) { after("

Une erreur est apparue. Veuillez réessayer.

"); } else { after(response.html); } }); return ''; } function makeRequest(pUrl, pCallback){ var xhr = new XMLHttpRequest(); xhr.open('GET', pUrl, true); xhr.onload = function() { if (xhr.readyState === 4) { const response = JSON.parse(xhr.responseText); pCallback(response); } }; xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); xhr.send(null); } function dispatchUnauthorized(element) { const event = new CustomEvent("unAuthorizedEmbedded", { detail: element }); dispatchEvent(event); } function replaceElement(content,element) { const div = document.createElement('div'); div.innerHTML = content; element.parentNode.insertBefore(div,element); element.remove(); dispatchUnauthorized(div); } function hasAcceptedAllPurposes() { if (window.Didomi) return Didomi.getUserStatus().purposes.consent.disabled.length == 0; return false; } function hasAcceptedVendor(url) { if(window.Didomi) { if(url.match('dailymotion')) return Didomi.getUserStatus().vendors.consent.disabled.indexOf(573)==-1; if(url.match('youtube')) return Didomi.getUserStatus().vendors.consent.disabled.indexOf('google')==-1; return true; } return false; } return { setup:init }; })(); (function () { window.VIDALConsent = { optoutTracking:()=>{ track('Désactiver les cookies de la mesure d\'audience strictement nécessaire'); const cookies = parseStr(getCookie(MAIN_COOKIE)); cookies[COOKIE_DATE] = new Date().getTime(); cookies[COOKIE_TRACKING] = 0; cookies[COOKIE_OPTOUT] = 1; setCookie(MAIN_COOKIE,cookies); setPreferences(cookies, 'by_button'); }, hasOptout:()=>{ const cookies = parseStr(getCookie(MAIN_COOKIE)); return cookies[COOKIE_OPTOUT]&&cookies[COOKIE_OPTOUT]==="1"; }, handleOptoutButton:(pParentNode)=>{ let optoutButton = `Désactiver la mesure d'audience strictement nécessaire`; let hasOptOutInfo = `Vous êtes opposés à l'utilisation des cookies exemptés de consentement "AT INTERNET (PIANO ANALYTICS)"`; document.querySelector(pParentNode).innerHTML = VIDALConsent.hasOptout()?hasOptOutInfo:optoutButton; } }; function initConsent(pIsMain) { applyDomainSpecificStyles(); document.querySelectorAll('#vidal_consent .choices a').forEach(function (value) { value.addEventListener('click', function (e) { e.preventDefault(); }); }); const vidal_consent_main = document.querySelector('#vidal_consent'); const refuse_all = document.querySelector('#vidal_consent .refuse-all'); const accept_all = document.querySelector('#vidal_consent .accept-all'); const close = document.querySelector('#vidal_consent .icon-close'); const choices = document.querySelectorAll('#vidal_consent input[type="radio"]:checked'); const yes_all = document.querySelectorAll('#vidal_consent .yes'); const no_all = document.querySelectorAll('#vidal_consent .no'); const settings = document.querySelector('#vidal_consent .settings'); const save = document.querySelector('#vidal_consent .save'); const refuse = document.querySelector('#vidal_consent .btn_cookie.refuse'); const valid = document.querySelector('#vidal_consent .btn_cookie.valid'); const cookies_data = parseStr(getCookie(MAIN_COOKIE)); if(Object.getOwnPropertyNames(cookies_data).length > 1){ for(let property in cookies_data){ if(!cookies_data.hasOwnProperty(property)){ continue; } var radios = document.querySelectorAll('#vidal_consent [name="'+property+'"]'); radios.forEach(function (radio) { if(radio.value === cookies_data[property]) radio.checked = 1; }); } if(Object.getOwnPropertyNames(cookies_data).length >= COOKIE_NUMBER){ if(valid.classList.contains('disabled')) valid.classList.remove('disabled'); } } document.body.classList.add('modal-open'); if(settings){ settings.addEventListener('click', function (e) { track(e.currentTarget.innerText); document.querySelector('#vidal_consent .modal.second').classList.toggle('hidden'); document.querySelector('#vidal_consent .modal.second').classList.toggle('active'); }); } if(document.querySelectorAll('input[type="radio"]')){ document.querySelectorAll('input[type="radio"]').forEach(function (choice) { choice.addEventListener('click', (e) => { let attributeName = e.currentTarget.getAttribute("name"); if (isManabuDomain()) { attributeName = COOKIE_PUB_MANABU; didomi_specific_choices = false; } else { attributeName = COOKIE_PUB; didomi_specific_choices = false; } checkMainRadioCheckedCount(); }) }); } if (valid){ valid.addEventListener('click', function (e) { track(e.currentTarget.innerText); e.preventDefault(); const choices = document.querySelectorAll('#vidal_consent input[type="radio"]:checked'); const cookies = {}; choices.forEach(function (item) { let attributeName = item.getAttribute("name"); if(!didomi_specific_choices && [COOKIE_PUB, COOKIE_PUB_MANABU].indexOf(attributeName)>-1){ handDidomiGlobalConsent(item.value); } cookies[item.name] = item.value; }); cookies[COOKIE_DATE] = new Date().getTime(); setCookie(MAIN_COOKIE,cookies); setPreferences(cookies, 'by_form'); window.location.reload(); }); } if(close){ close.addEventListener('click', function (e) { e.preventDefault(); if(window.location.pathname.indexOf(URL_COOKIE) === -1){ document.querySelector('#vidal_consent .modal.second').classList.toggle('hidden'); document.querySelector('#vidal_consent .modal.second').classList.toggle('active'); } else { vidal_consent_main.classList.add('hide'); document.body.classList.remove('modal-open'); window.location.reload(); } }); } if(!pIsMain){ const modal_second = document.querySelector('#vidal_consent .modal.second'); if(modal_second.classList.contains('hidden')){ modal_second.classList.remove('hidden'); modal_second.classList.add('active'); } } if(save){ save.addEventListener('click', function (e) { track(e.currentTarget.innerText); vidal_consent_main.classList.add('hide'); document.body.classList.remove('modal-open'); handDidomiGlobalConsent("1"); const cookies = getAcceptedCookieData(); setCookie(MAIN_COOKIE, cookies); setPreferences(cookies, 'by_button'); window.location.reload(); }); } if(refuse){ refuse.addEventListener('click', function (e) { track(e.currentTarget.innerText); vidal_consent_main.classList.add('hide'); document.body.classList.remove('modal-open'); handDidomiGlobalConsent("0"); const cookies = getRefusedCookieData(); setCookie(MAIN_COOKIE,cookies,ONE_MONTH); setPreferences(cookies, 'by_button',ONE_MONTH); window.location.reload(); }); } if(yes_all){ yes_all.forEach(function (value) { value.addEventListener('click', function (e) { var no = e.target.previousSibling; if(!value.classList.contains('accepted')){ value.classList.add('accepted'); if(no.classList.contains('refused')) no.classList.remove('refused'); } }) }); } if(no_all){ no_all.forEach(function (value) { value.addEventListener('click', function (e) { var yes = e.target.nextSibling; if(!value.classList.contains('refused')){ value.classList.add('refused'); if(yes.classList.contains('accepted')) yes.classList.remove('accepted'); } }) }); } if(refuse_all){ refuse_all.addEventListener('click', function (e) { e.preventDefault(); track(e.currentTarget.innerText); refuseAll(yes_all,no_all); if(valid.classList.contains('disabled')) valid.classList.remove('disabled'); }); } if(accept_all){ accept_all.addEventListener('click', function (e) { e.preventDefault(); track(e.currentTarget.innerText); acceptAll(yes_all, no_all); if(valid.classList.contains('disabled')) valid.classList.remove('disabled'); }); } } document.addEventListener('DOMContentLoaded', getPreferences); const MAIN_COOKIE = "vidal_consent"; const COOKIE_COMMUNICATION = "comm"; const COOKIE_CONTENT = "content"; const COOKIE_TRACKING = "tracking"; const COOKIE_OPTOUT = "optout"; const COOKIE_PUB = "pub"; const COOKIE_PUB_MANABU = "pub_manabu"; const COOKIE_SOCIAL = "social"; const COOKIE_DATE = "date_consent"; const COOKIE_VALIDITY_DATE = "validity_date_consent"; const COOKIE_NUMBER = 4; const ONE_MONTH = 1; const SIX_MONTHS = 6; const URL_COOKIE = '/politique-cookies.html'; const URL_OAUTH = 'https://oauth2.vidal.fr/'; const VIDAL_FR = 'vidal.fr'; const MANABU = 'manabu'; let didomi_specific_choices = false; function didomiMainFlagHandler(pDidomi){ let userStatus = pDidomi.getUserStatus(); if(userStatus.purposes.consent.enabled.length === 0 && userStatus.purposes.consent.disabled.length === 0){ return; } let btn_on = userStatus.purposes.consent.enabled.length>0?'yes':'no'; let btn_off = btn_on==='yes'?'no':'yes'; if(!document.querySelector('#vidal_consent #pub'+btn_off)){ return; } document.querySelector('#vidal_consent #pub'+btn_off).checked = 0; document.querySelector('#vidal_consent #pub'+btn_on).checked = 1; checkMainRadioCheckedCount(); } function consentEmbeddedHandler(){ if(typeof ConsentEmbedded !== 'undefined') ConsentEmbedded.setup(); } function checkMainRadioCheckedCount(){ let valid = document.querySelector('#vidal_consent .btn_cookie.valid'); if(document.querySelectorAll('#vidal_consent input[type="radio"]:checked').length === parseInt(COOKIE_NUMBER)+1){ if(valid.classList.contains('disabled')) valid.classList.remove('disabled'); } } function track(pLabel){ if(!window.pa){ return; } pLabel = pLabel.toLowerCase(); pLabel = pLabel[0].toUpperCase()+pLabel.slice(1); pa.sendEvent('click.action', { click:pLabel, click_chapter1:'Bannière de consentement', click_chapter2:'' }); } function acceptAll(pYes, pNo) { pYes.forEach(function (value) { if(!value.checked) value.checked = 1; }); pNo.forEach(function (value) { if(value.checked) value.checked = 0; }); } function refuseAll(pYes, pNo) { pNo.forEach(function (value) { if(!value.checked) value.checked = 1; }); pYes.forEach(function (value) { if(value.checked) value.checked = 0; }); } function getPreferences() { window.didomiConfig = { notice: { enable: false } }; if (isManabuDomain()) { window.gdprAppliesGlobally = true; (function () { function n(e) { if (!window.frames[e]) { if (document.body && document.body.firstChild) { var t = document.body; var r = document.createElement("iframe"); r.style.display = "none"; r.name = e; r.title = e; t.insertBefore(r, t.firstChild) } else { setTimeout(function () { n(e) }, 5) } } } function e(r, a, o, c, d) { function e(e, t, r, n) { if (typeof r !== "function") { return } if (!window[a]) { window[a] = [] } var i = false; if (d) { i = d(e, n, r) } if (!i) { window[a].push({command: e, version: t, callback: r, parameter: n}) } } e.stub = true; e.stubVersion = 2; function t(n) { if (!window[r] || window[r].stub !== true) { return } if (!n.data) { return } var i = typeof n.data === "string"; var e; try { e = i ? JSON.parse(n.data) : n.data } catch (t) { return } if (e[o]) { var a = e[o]; window[r](a.command, a.version, function (e, t) { var r = {}; r[c] = {returnValue: e, success: t, callId: a.callId}; if (n.source) { n.source.postMessage(i ? JSON.stringify(r) : r, "*") } }, a.parameter) } } if (typeof window[r] !== "function") { window[r] = e; if (window.addEventListener) { window.addEventListener("message", t, false) } else { window.attachEvent("onmessage", t) } } } e("__tcfapi", "__tcfapiBuffer", "__tcfapiCall", "__tcfapiReturn"); n("__tcfapiLocator"); (function (e, t) { var r = document.createElement("link"); r.rel = "preconnect"; r.as = "script"; var n = document.createElement("link"); n.rel = "dns-prefetch"; n.as = "script"; var i = document.createElement("link"); i.rel = "preload"; i.as = "script"; var a = document.createElement("script"); a.id = "spcloader"; a.type = "text/javascript"; a["async"] = true; a.charset = "utf-8"; var o = "https://sdk.privacy-center.org/" + e + "/loader.js?target_type=notice&target=" + t; if (window.didomiConfig && window.didomiConfig.user) { var c = window.didomiConfig.user; var d = c.country; var s = c.region; if (d) { o = o + "&country=" + d; if (s) { o = o + "®ion=" + s } } } r.href = "https://sdk.privacy-center.org/"; n.href = "https://sdk.privacy-center.org/"; i.href = o; a.src = o; var f = document.getElementsByTagName("script")[0]; f.parentNode.insertBefore(r, f); f.parentNode.insertBefore(n, f); f.parentNode.insertBefore(i, f); f.parentNode.insertBefore(a, f) })("6bace3e2-3123-43af-a7d6-6b13f0bcfb8b", "qgficUEc") })(); } else { window.gdprAppliesGlobally=true;(function(){function n(e){if(!window.frames[e]){if(document.body&&document.body.firstChild){var t=document.body;var r=document.createElement("iframe");r.style.display="none";r.name=e;r.title=e;t.insertBefore(r,t.firstChild)}else{setTimeout(function(){n(e)},5)}}}function e(r,a,o,c,s){function e(e,t,r,n){if(typeof r!=="function"){return}if(!window[a]){window[a]=[]}var i=false;if(s){i=s(e,n,r)}if(!i){window[a].push({command:e,version:t,callback:r,parameter:n})}}e.stub=true;e.stubVersion=2;function t(n){if(!window[r]||window[r].stub!==true){return}if(!n.data){return}var i=typeof n.data==="string";var e;try{e=i?JSON.parse(n.data):n.data}catch(t){return}if(e[o]){var a=e[o];window[r](a.command,a.version,function(e,t){var r={};r[c]={returnValue:e,success:t,callId:a.callId};n.source.postMessage(i?JSON.stringify(r):r,"*")},a.parameter)}}if(typeof window[r]!=="function"){window[r]=e;if(window.addEventListener){window.addEventListener("message",t,false)}else{window.attachEvent("onmessage",t)}}}e("__tcfapi","__tcfapiBuffer","__tcfapiCall","__tcfapiReturn");n("__tcfapiLocator");(function(e,t){var r=document.createElement("link");r.rel="preconnect";r.as="script";var n=document.createElement("link");n.rel="dns-prefetch";n.as="script";var i=document.createElement("link");i.rel="preload";i.as="script";var a=document.createElement("script");a.id="spcloader";a.type="text/javascript";a["async"]=true;a.charset="utf-8";var o="https://sdk.privacy-center.org/"+e+"/loader.js?target_type=notice&target="+t;if(window.didomiConfig&&window.didomiConfig.user){var c=window.didomiConfig.user;var s=c.country;var d=c.region;if(s){o=o+"&country="+s;if(d){o=o+"®ion="+d}}}r.href="https://sdk.privacy-center.org/";n.href="https://sdk.privacy-center.org/";i.href=o;a.src=o;var f=document.getElementsByTagName("script")[0];f.parentNode.insertBefore(r,f);f.parentNode.insertBefore(n,f);f.parentNode.insertBefore(i,f);f.parentNode.insertBefore(a,f)})("6bace3e2-3123-43af-a7d6-6b13f0bcfb8b","Gr6FNbwV")})(); } window.didomiOnReady = window.didomiOnReady || []; window.didomiOnReady.push(didomiMainFlagHandler); window.didomiOnReady.push(consentEmbeddedHandler); window.didomiEventListeners = window.didomiEventListeners || []; window.didomiEventListeners.push({ event: 'consent.changed', listener: function (context) { didomi_specific_choices = true; didomiMainFlagHandler(window.Didomi); } }); var xhr = new XMLHttpRequest(); xhr.open('GET', URL_OAUTH+'gdpr/consents/', true); xhr.withCredentials = true; if(document.querySelector('*[data-e]')){ let e = document.querySelector('*[data-e]').getAttribute("data-e"); xhr.setRequestHeader('e', e); } xhr.send(null); xhr.onload = function(){ if(xhr.readyState === 4){ const response = JSON.parse(xhr.responseText); const consent = response.consents; const cookies = parseStr(getCookie(MAIN_COOKIE)); let cookiePubName = isManabuDomain() ? COOKIE_PUB_MANABU : COOKIE_PUB let hasPub = consent&&consent.indexOf(cookiePubName+'=')>-1||cookies[isManabuDomain() ? COOKIE_PUB_MANABU : COOKIE_PUB]; // si données distantes existent if((!response.error && xhr.status === 200 && consent.length)&&hasPub){ var date = response.date; var date_saved = new Date(date.replace(/-/g,'/')).getTime(); if (cookies.date_consent){ var date_local = cookies.date_consent; // si date locale + recente on enregistrement cookies locaux a distance if(date_local > date_saved){ setPreferences(cookies,"by_update"); } else { setCookieLocal(MAIN_COOKIE, consent,SIX_MONTHS); } } else { //on enregistre ce qu'il y'a à distance en locale; setCookieLocal(MAIN_COOKIE, consent,SIX_MONTHS); window.location.href = window.location.href + ""; } /* Pas de données à distance */ } else { if ((!hasPub && !response.error) || (document.cookie.indexOf(MAIN_COOKIE) === -1 && window.location.pathname.indexOf(URL_COOKIE) === -1)) { setCookieLocal(MAIN_COOKIE, consent,SIX_MONTHS); loadModal(true); } else if(xhr.status === 200 && !consent.length && window.location.pathname.indexOf(URL_COOKIE) === -1) { setPreferences(cookies,"by_update"); } } } }; xhr.onerror = function (ev) { if (document.cookie.indexOf(MAIN_COOKIE) === -1 && window.location.pathname.indexOf(URL_COOKIE) === -1) { loadModal(true); } } } window.addEventListener('DOMContentLoaded', function () { const modal_cookie = document.querySelector('#modal_cookie'); if(modal_cookie){ modal_cookie.addEventListener("click", function (e) { e.preventDefault(); loadModal(false); }); } refreshModals(document); window.addEventListener("unAuthorizedEmbedded", function(e){refreshModals(e.detail);}); }); function refreshModals(element){ const modals_cookie = element.querySelectorAll('.multiple_modal_cookie'); modals_cookie.forEach(function (modal){ modal.addEventListener("click", function (e) { e.preventDefault(); loadModal(false); }); }) } function loadModal(pIsMain) { let consent_css = 'consent.css'; const url = getOAuthConsentUrl(); consent_css = url+consent_css; const consent_html = URL_OAUTH + 'gdpr/modal/'; const link = ""; document.head.insertAdjacentHTML('beforeEnd', link); const xhr = new XMLHttpRequest(); const urlSuffix = isManabuDomain() ? '&domain='+MANABU : ''; xhr.open('POST', `${consent_html}?render=true${urlSuffix}`, true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset:UTF-8'); xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); if(document.querySelector('*[data-e]')){ let e = document.querySelector('*[data-e]').getAttribute("data-e"); xhr.setRequestHeader('e', e); } xhr.send(); xhr.onload = function() { if (xhr.readyState === 4) { var response = JSON.parse(xhr.responseText); var vidal_consent = document.createElement('div'); vidal_consent.id = "vidal_consent"; document.body.appendChild(vidal_consent); vidal_consent.innerHTML = response.html; initConsent(pIsMain); } }; } function getOAuthConsentUrl() { if(document.querySelector('script[src$="consent.js"]')) return document.querySelector('script[src$="consent.js"]').getAttribute('src').replace('consent.js', ''); else if(document.querySelector('script[src$="statique/dependencies/?need=Consent"]')) return document.querySelector('script[src$="statique/dependencies/?need=Consent"]').getAttribute('src').replace('statique/dependencies/?need=Consent', 'includes/components/consent-cookie/'); return ''; } function setPreferences(pPreferences, pTypeConsent, pDuration) { pDuration = pDuration || SIX_MONTHS; const d = new Date(); const now = d.getTime(); d.setMonth(d.getMonth()+pDuration); if(pTypeConsent === "by_update"){ var validity = parseStr(getCookie(MAIN_COOKIE))[COOKIE_VALIDITY_DATE]; } if(!validity){ validity = d.getTime(); validity = Math.floor(validity/1000); } const myHeaders = new Headers(); if(document.querySelector('*[data-e]')){ let e = document.querySelector('*[data-e]').getAttribute("data-e"); myHeaders.append('e', e); } const myInit = { method: 'GET', mode: 'cors', cache: 'default', headers: myHeaders, credentials: 'include' }; let params = []; pPreferences.date_consent = now; pPreferences.source_consent = document.location.host; pPreferences.type_consent_info = pTypeConsent; pPreferences.date_validity = validity; for(let i in pPreferences){ if(!pPreferences.hasOwnProperty(i)){ continue; } params.push(i+"="+pPreferences[i]); } let url = URL_OAUTH + "gdpr/consents/set/?"; if (isManabuDomain()) { url += "domain="+MANABU+"&"; } url += params.join("&"); fetch(url, myInit); } function parseStr(str) { var entries = str.split("&"); var returnData = {}; entries.forEach(function(entry){ entry = entry.split("="); var key = entry[0]; returnData[key] = entry[1]; }); return returnData; } function setCookie(pKey, pData, pDuration) { pDuration = pDuration || SIX_MONTHS; var d = new Date(); d.setMonth(d.getMonth()+pDuration); var validity = d.getTime(); var expires = "expires="+ d.toUTCString(); var domain = "domain=" + (!isManabuDomain()?VIDAL_FR:'m3manabu.com'); var cookie_value = ""; if((typeof pData) == 'object'){ let vals = []; pData[COOKIE_VALIDITY_DATE] = validity; for (let i in pData) { if(!pData.hasOwnProperty(i)){ continue; } vals.push(i+'='+pData[i]); } cookie_value = vals.join("&"); }else{ cookie_value = pData; } document.cookie = pKey+'='+cookie_value+';'+expires+';'+domain+';path=/'; } function getCookie(cname) { const name = cname + "="; const decodedCookie = document.cookie; const ca = decodedCookie.split(';'); for(let i = 0; i