Subversion Repositories Sites.tela-botanica.org

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1125 aurelien 1
function ajouterStyle() {
2
  var urlCss = "http://resources.tela-botanica.org/tb/reseau/bandeau_cnil.css";
3
  // http://stackoverflow.com/questions/574944/how-to-load-up-css-files-using-javascript
4
  link = document.createElement("link");
5
  link.href = urlCss;
6
  link.type = "text/css";
7
  link.rel = "stylesheet";
8
  link.media = "screen,print";
9
  document.getElementsByTagName( "head" )[0].appendChild(link);
10
}
11
 
12
function ajouterBandeau() {
13
  var divCookie =
14
    '<div class="bandeau" id="bandeau_cookie_cnil">'+
15
    	'<div class="bandeau_cookie_cnil_titre"> Utilisation des cookies </div>'+
16
    	'<hr />'+
17
		'<div class="avertissement_cookie">  '+
18
		'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&eacute;f&eacute;rences. <br />'+
19
		'<a class="en_savoir_plus" target="_blank" href="http://www.tela-botanica.org/page:licence"> En savoir plus</a>'+
20
		'<a class="button" id="accepterCookie" onclick="javascript:accepterCookie()" href="#" > OK </a>'+
21
		'</div>'+
22
    '</div>';
23
  document.body.innerHTML += divCookie;
24
}
25
 
26
function accepterCookie() {
27
  var element = document.getElementById("bandeau_cookie_cnil");
28
  element.parentNode.removeChild(element);
29
  createCookie("cnil", 1, 365);
30
  return false;
31
}
32
 
33
function initialiserBandeauCnil() {
34
    ajouterStyle();
35
    ajouterBandeau();
36
}
37
 
38
/**
39
 * Fonctions tirées de stackoverflow
40
 */
41
// http://stackoverflow.com/questions/4825683/how-do-i-create-and-read-a-value-from-cookie
42
function createCookie(name, value, days) {
43
  var expires;
44
  if (days) {
45
      var date = new Date();
46
      date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
47
      expires = "; expires=" + date.toGMTString();
48
  }
49
  else {
50
      expires = "";
51
  }
52
  document.cookie = name + "=" + value + expires + "; path=/";
53
}
54
 
55
function getCookie(c_name) {
56
    if (document.cookie.length > 0) {
57
		c_start = document.cookie.indexOf(c_name + "=");
58
		if (c_start != -1) {
59
		    c_start = c_start + c_name.length + 1;
60
		    c_end = document.cookie.indexOf(";", c_start);
61
		    if (c_end == -1) {
62
		    	c_end = document.cookie.length;
63
		    }
64
		    return unescape(document.cookie.substring(c_start, c_end));
65
		}
66
    }
67
    return "";
68
}
69
 
70
//http://stackoverflow.com/questions/799981/document-ready-equivalent-without-jquery#answer-18775368
71
document.onreadystatechange = function () {
72
	// tant pis pour les vieux navigateurs qui ne supportent pas document.readyState
73
	if (document.readyState == "complete") {
74
		var cookieCnil = getCookie("cnil");
75
	    if(cookieCnil == null || cookieCnil != 1) {
76
	    	initialiserBandeauCnil();
77
	    }
78
	}
79
}