function addCSS() {
if (document.createStyleSheet) {
document.createStyleSheet('https://www.ts-line.fr/rgpd/rgpd.css');
} else {
var styles = "@import url('https://www.ts-line.fr/rgpd/rgpd.css');";
var newSS = document.createElement('link');
newSS.rel = 'stylesheet';
newSS.href = 'data:text/css,' + escape(styles);
document.getElementsByTagName("head")[0].appendChild(newSS);
}
};
function addRGPDForm() {
var gdpr = document.createElement('div'),
gdprP = document.createElement('p'),
gdprBt = document.createElement('button');
gdpr.id = 'gdpr';
gdprBt.className = 'gdpr-agreement';
gdpr.appendChild(gdprP);
gdpr.appendChild(gdprBt);
gdprP.innerHTML = "En poursuivant votre navigation sur ce site, vous acceptez l’utilisation de cookies pour vous proposer des services et offres adaptés à vos centres d’intérêts et réaliser des statistiques de visite.
Consultez notre politique de confidentialité.";
gdprBt.innerHTML = "J’accepte";
document.getElementsByTagName('body')[0].appendChild(gdpr);
gdprBt.addEventListener('click', function() {
setCookie('rgpd', 'accept', 365);
document.querySelector('#gdpr').classList.add('accept')
}, false);
};
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
};
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
};
function addRGPDOnload() {
if (document.getElementsByName('contactform') != null) {
var contactGDPR = "";
var arr = document.forms;
for (var i = 0; i < arr.length; i++) {
if ((arr[i].getAttribute('role') == 'search') || (arr[i].getAttribute('role') == 'form') || (arr[i].getAttribute('role') == 'customization') || (arr[i].getAttribute('id')=='searchbox') || (arr[i].getAttribute('id')=='add-to-cart-or-refresh') || (arr[i].getAttribute('id')=='recherche') || (arr[i].getAttribute('id')=='create-account_form') || (arr[i].getAttribute('id')=='login_form') || (arr[i].getAttribute('id')=='layered_form') || (arr[i].getAttribute('id')=='buy_block') || (arr[i].getAttribute('id')=='voucher') || (arr[i].getAttribute('method')=='link') || (arr[i].getAttribute('role')=='livechat') || (arr[i].getAttribute('name')=='ag_grid')) {} else {
btSubmit = arr[i].querySelector('input[type="submit"],a[type="submit"],button');
parentDiv = btSubmit.parentNode;
gdprForm = document.createElement('div');
gdprForm.className = 'rgpd-widget-form';
parentDiv.insertBefore(gdprForm, btSubmit);
gdprForm.innerHTML = contactGDPR;
}
}
}
};
/*
var aTags=document.querySelectorAll("a");
var searchText="mentions légales";
var found;
for (var i = 0; i < aTags.length; i++) {
if (aTags[i].textContent.toLowerCase() == searchText) {
found = aTags[i];
parentLegal=found.parentNode;
gdprBTlegal=document.createElement('a');
gdprBTlegal.className='rgpd-form-policy';
gdprBTlegal.setAttribute('href', 'https://www.ts-line.fr/content/7-politique-de-confidentialite?content_only=1');
gdprBTlegal.setAttribute('class', 'various');
gdprBTlegal.setAttribute('data-fancybox-type','iframe');
gdprBTlegal.textContent=" Politique de confidentialité";
parentLegal.insertBefore(gdprBTlegal,found.nextSibling);
break;
}
}
*/
addCSS();
if (window.addEventListener) window.addEventListener('load', addRGPDOnload, false);
else if (window.attachEvent) window.attachEvent('onload', addRGPDOnload);
else window.onload = addRGPDOnload;
if (getCookie('rgpd') != 'accept') {
addRGPDForm();
}