Bonjour,

Je suis novice en javascript, j'ai un script que je n'ai pas fait moi-même pour générer un bandeau pour informer l'utilisateur de l'utilisation de cookies et j'aimerai comprendre comment il fonctionne. Et principalement j'aimerai savoir combien de temps après validation le bandeau va réapparaitre.

Est-ce que quelqu'un voudrait bien prendre de son temps pour m'expliquer ?


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*Cookie Box | Version 4*/ !(function () {
  var e = function (e, t, o) {
    (this.text = e),
      (this.acceptText = t),
      (this.element = null),
      this.init();
  };
  (e.prototype = {
    init: function () {
      this.create(), this.load(), this.actions();
    },
    load: function () {
      null === localStorage.getItem("cookie-box-accepted") && this._show();
    },
    actions: function () {
      var e = document.querySelector("#cookie-box-accept"),
        o = this;
      e.addEventListener(
        "click",
        function (e) {
          e.preventDefault(),
            localStorage.setItem("cookie-box-accepted", "yes"),
            o._hide();
        },
        !1
      )
 
    },
    create: function () {
      var e = document.createElement("div");
      this.element = e;
      var t =
        "<div id='cookie-box-wrap'><div id='cookie-box-text'>" +
        this.text +
        "</div>";
      (e.id = "cookie-box"),
        (t +=
          "<div id='cookie-box-btns'><button type='button' id='cookie-box-accept'>" +
          this.acceptText +
          "</button>"),
 
        (e.innerHTML = t),
        document.body.appendChild(e);
    },
    _show: function () {
      var e = this;
      (e.element.style.display = "block"),
        setTimeout(function () {
          e.element.className = "visible";
        }, 500);
    },
    _hide: function () {
      var e = this;
      (e.element.className = ""),
        setTimeout(function () {
          e.element.style.display = "none";
        }, 500);
    },
  }),
    document.addEventListener("DOMContentLoaded", function () {
      new e(
        "<h3>Vous aimez les <br>cookies?<br>🍪<br></h3>Nous utilisons des cookies pour vous garantir la meilleure expérience sur notre site Web.<a href='#cookies' rel='noopener' target='_blank'><br>En savoir plus</a><a href='#gestion'rel='noopener' target='_blank'><br>Gérer les Cookies</a><span id='open'><svg height='78' width='35'><text x='0' y='0' fill='#ffffff' transform='rotate(90 1,10)'>Cookies</text></svg></span>",
        "J'accepte"
 
      );
    });
})();
var sheet = (function () {
  var e = document.createElement("style");
  return (
    e.appendChild(
      document.createTextNode(
        "#cookie-box{position:fixed;bottom:0px;left:0px;width:100%;max-width:290px;min-height:3em;background:#f1f1f1;color:#555;z-index:10000000000;display:none;transition:all .5s ease-in;transform: translate(-350px, 0px);}#cookie-box.visible{transform:translate(0px, 0px)}#cookie-box{background-color:rgba(23, 23, 23, 0.8);margin-left:-293px}#cookie-box:hover{margin-left:0px}#cookie-box-wrap{margin:0 auto;max-width:285px;text-align:center}#cookie-box-text{color:#ffffff;padding:17px 3px 7px;font-size:15px;line-height:25px;}#cookie-box-text a{color:#ffa600;text-decoration:underline;}#cookie-box-btns{margin:15px auto}#open{float:right;margin-top:-25px;margin-right:-40px;background-color:rgba(23, 23, 23, 0.6);font-size:19px;border-left:none;border-top-right-radius:4px;border-bottom-right-radius:4px}.mytooltip{position:relative}.mytooltip .mytooltext{visibility:hidden;transition:all .5s ease-in;max-width:280px;background-color:grey;font-size:15px;line-height:19px;color:#fff;text-align:center;text-transform:none;border-radius:1px;padding:25px 0;position:fixed;z-index:1;bottom:57px;left:5px}.mytooltip:hover .mytooltext{visibility:visible}"
      )
    ),
    document.head.appendChild(e),
    e.sheet
  );
})();
function eraseCookieFromAllPaths(e) {
  var o = location.pathname.split("/"),
    t = " path=";
  document.cookie = e + "=; expires=Thu, 01-Jan-1970 00:00:01 GMT;";
  for (var a = 0; a < o.length; a++)
    (t += ("/" != t.substr(-1) ? "/" : "") + o[a]),
      (document.cookie =
        e +
        "=; expires=Thu, 01-Jan-1970 00:00:01 GMT;" +
        t +
        ";") /*,alert("The following cookies will be deleted: "+document.cookie)*/,
      location.reload(true);
}