Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
function ajouterStyle() {
var urlCss = "http://resources.tela-botanica.org/tb/reseau/bandeau_cnil.css";
// http://stackoverflow.com/questions/574944/how-to-load-up-css-files-using-javascript
link = document.createElement("link");
link.href = urlCss;
link.type = "text/css";
link.rel = "stylesheet";
link.media = "screen,print";
document.getElementsByTagName( "head" )[0].appendChild(link);
}
function ajouterBandeau() {
var divCookie =
'<div class="bandeau" id="bandeau_cookie_cnil">'+
'<div class="bandeau_cookie_cnil_titre"> Utilisation des cookies </div>'+
'<hr />'+
'<div class="avertissement_cookie"> '+
'Le site de Tela Botanica utilise des cookies. En poursuivant votre navigation sur le site, vous acceptez l\'utilisation de ces cookies qui permettent notamment de se souvenir de vos préférences. <br />'+
'<a class="en_savoir_plus" target="_blank" href="http://www.tela-botanica.org/page:licence"> En savoir plus</a>'+
'<a class="button" id="accepterCookie" onclick="javascript:accepterCookie()" href="#" > OK </a>'+
'</div>'+
'</div>';
document.body.innerHTML += divCookie;
}
function accepterCookie() {
var element = document.getElementById("bandeau_cookie_cnil");
element.parentNode.removeChild(element);
createCookie("cnil", 1, 365);
return false;
}
function initialiserBandeauCnil() {
ajouterStyle();
ajouterBandeau();
}
/**
* Fonctions tirées de stackoverflow
*/
// http://stackoverflow.com/questions/4825683/how-do-i-create-and-read-a-value-from-cookie
function createCookie(name, value, days) {
var expires;
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toGMTString();
}
else {
expires = "";
}
document.cookie = name + "=" + value + expires + "; path=/";
}
function getCookie(c_name) {
if (document.cookie.length > 0) {
c_start = document.cookie.indexOf(c_name + "=");
if (c_start != -1) {
c_start = c_start + c_name.length + 1;
c_end = document.cookie.indexOf(";", c_start);
if (c_end == -1) {
c_end = document.cookie.length;
}
return unescape(document.cookie.substring(c_start, c_end));
}
}
return "";
}
//http://stackoverflow.com/questions/799981/document-ready-equivalent-without-jquery#answer-18775368
document.onreadystatechange = function () {
// tant pis pour les vieux navigateurs qui ne supportent pas document.readyState
if (document.readyState == "complete") {
var cookieCnil = getCookie("cnil");
if(cookieCnil == null || cookieCnil != 1) {
initialiserBandeauCnil();
}
}
}