PageSourceSearch

https://www.dcaf.ch/modules/contrib/cookie_banner/js/cookie_banner.js?v=1.x

js dcaf.ch collected 2026-10-02 02:32:59 UTC 1,956 bytes, 63 lines download raw bytes

1// Cookie banner javascript file
2(function ($) {
3
4  Drupal.behaviors.cookie_banner = {
5    attach: function (context, settings) {
6      var cookie_name     = drupalSettings.cookie_banner.cookie_banner_name;
7      var cookie_message  = drupalSettings.cookie_banner.cookie_banner_message;
8      // PHP time is expressed in seconds, JS needs milliseconds.
9      var cookie_duration = drupalSettings.cookie_banner.cookie_banner_duration * 1000;
10
11      $('body').prepend(cookie_message);
12
13      Drupal.cookie_banner.closeBanner(cookie_name, cookie_duration);
14
15    }
16  };
17
18  Drupal.cookie_banner = {};
19
20  Drupal.cookie_banner.closeBanner = function (name, time) {
21    var $cookieBanner = $('#cookie-banner');
22    if (Drupal.cookie_banner.getCookie(name) == "") {
23      Drupal.cookie_banner.setCookie(name, '0', time);
24    } else if (Drupal.cookie_banner.getCookie(name) == "1") {
25      $cookieBanner.detach();
26    }
27
28    $cookieBanner.on('click', '.close', function () {
29      Drupal.cookie_banner.setCookie(name, '1', time);
30      $cookieBanner.detach();
31    });
32    $cookieBanner.on('click', '.agree-btn', function () {
33      Drupal.cookie_banner.setCookie(name, '1', time);
34      $cookieBanner.detach();
35    });
36  };
37
38  Drupal.cookie_banner.setCookie = function (name, value, time) {
39    var expires = "";
40    if (time) {
41      var date = new Date();
42      date.setTime(time);
43      expires = "; expires=" + date.toGMTString();
44    }
45    document.cookie = name + "=" + value + expires + "; path=/";
46  };
47
48  Drupal.cookie_banner.getCookie = function (cname) {
49    var name = cname + "=";
50    var ca = document.cookie.split(';');
51    for(var i = 0; i < ca.length; i++) {
52      var c = ca[i];
53      while (c.charAt(0) == ' ') {
54        c = c.substring(1);
55      }
56      if (c.indexOf(name) == 0) {
57        return c.substring(name.length, c.length);
58      }
59    }
60    return "";
61  };
62
63})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.