Selaa lähdekoodia

Merge pull request #185 from ygriguer-bhs/changeable-cookie-name

Give the possibility to change cookie's name
Amauri CHAMPEAUX 6 vuotta sitten
vanhempi
commit
cb0e23b72e
2 muutettua tiedostoa jossa 4 lisäystä ja 2 poistoa
  1. 1 0
      README.md
  2. 3 2
      tarteaucitron.js

+ 1 - 0
README.md

@@ -118,6 +118,7 @@ In PHP for example, you can bypass all the script by setting this var `tarteauci
 <script type="text/javascript">
 tarteaucitron.init({
     "hashtag": "#tarteaucitron", /* Ouverture automatique du panel avec le hashtag */
+    "cookieName": "tartaucitron", /* Nom du cookie */
     "highPrivacy": false, /* désactiver le consentement implicite (en naviguant) ? */
     "orientation": "top", /* le bandeau doit être en haut (top) ou en bas (bottom) ? */
     "adblocker": false, /* Afficher un message si un adblocker est détecté */

+ 3 - 2
tarteaucitron.js

@@ -184,6 +184,7 @@ var tarteaucitron = {
             defaults = {
                 "adblocker": false,
                 "hashtag": '#tarteaucitron',
+                "cookieName": 'tarteaucitron',
                 "highPrivacy": false,
                 "orientation": "top",
                 "removeCredit": false,
@@ -893,7 +894,7 @@ var tarteaucitron = {
                 expireTime = time + timeExipre, // 365 days
                 regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
                 cookie = tarteaucitron.cookie.read().replace(regex, ""),
-                value = 'tarteaucitron=' + cookie + '!' + key + '=' + status,
+                value = tarteaucitron.parameters.cookieName + '=' + cookie + '!' + key + '=' + status,
                 domain = (tarteaucitron.parameters.cookieDomain !== undefined && tarteaucitron.parameters.cookieDomain !== '') ? 'domain=' + tarteaucitron.parameters.cookieDomain + ';' : '';
 
           if (tarteaucitron.cookie.read().indexOf(key + '=' + status) === -1) {
@@ -905,7 +906,7 @@ var tarteaucitron = {
         },
         "read": function () {
             "use strict";
-            var nameEQ = "tarteaucitron=",
+            var nameEQ = tarteaucitron.parameters.cookieName + "=",
                 ca = document.cookie.split(';'),
                 i,
                 c;