Alex-D / Cookies-EU-banner

1kb vanilla JS script which manages cookies consent banner display like asked by GDPR
http://alex-d.github.io/Cookies-EU-banner/
MIT License
439 stars 57 forks source link

Does not seem to be invoked / initialiazed #28

Closed chrissound closed 6 years ago

chrissound commented 6 years ago

I've tried two browsers.

How I've installed this: I've downloaded the zip, and copied over the Cookies-EU-banner-master/src/cookies-eu-banner.js file. I've added a script tag to source this file to my page, as well as add the relevant banner.

However the banner does not get shown, if I remove the display:none css property it gets shown but clicking any of the buttons doesn't do anything.

How can I verify the code is being correctly invoked?

chrissound commented 6 years ago
}(window, function () {
  'use strict';
    console.log("14");
  var CookiesEuBanner,
    document = window.document;

  CookiesEuBanner = function (launchFunction, waitAccept, undefined) {
    if (!(this instanceof CookiesEuBanner)) {
      return new CookiesEuBanner(launchFunction);
    }

    this.cookieTimeout = 33696000000; // 13 months in milliseconds
    this.bots = /bot|googlebot|crawler|spider|robot|crawling/i;
    this.cookieName = 'hasConsent';
    this.trackingCookiesNames = [ '__utma', '__utmb', '__utmc', '__utmt', '__utmv', '__utmz', '_ga', '_gat' ];
    this.launchFunction = launchFunction;
    this.waitAccept = waitAccept || false;
    console.log("29");
    this.init();
    console.log("31");
  };

Only get "14" in the console output, so this function does not seem to be run?

chrissound commented 6 years ago

It seem it's missing a CookiesEuBanner().init() somewher?

chrissound commented 6 years ago

It seems to me necessary to actually call new CookiesEuBanner(); on the page. It would be useful to mention this in the readme, as it's not obvious that it's strictly required.

Alex-D commented 6 years ago

Read the README maybe?

https://github.com/Alex-D/Cookies-EU-banner/blob/master/README.md#in-your-pages

Thanks...