PageSourceSearch

https://www.gualba.cat/base/resources/javascript/pct-cookies/js/pct-cookies.js

js gualba.cat collected 2026-10-02 13:43:14 UTC 4,525 bytes, 123 lines download raw bytes

1let pctCookies = {
2    init: function () {
3        this.initConfig();
4        this.initServices();
5    },
6    initConfig: function() {
7        var me = this;
8        let pctCookiesConfigScript = document.querySelector("#pctCookiesConfig");
9
10        if (pctCookiesConfigScript !== null) {
11            Object.keys(pctCookiesConfigScript.dataset).forEach(function (attribute) {
12                let value = pctCookiesConfigScript.dataset[attribute];
13                pctCookiesConfig[attribute] = me.setValueWithType(value);
14            });
15        }
16    },
17    initServices: function() {
18        var me = this;
19        let pctCookiesServices = document.querySelectorAll('link[type="text/plain"], script[type="text/plain"]');
20
21        if (pctCookiesServices.length > 0) {
22            pctCookiesConfig.services = [];
23
24            pctCookiesServices.forEach(function (element) {
25                let service = {};
26                Object.keys(element.dataset).forEach(function (attribute) {
27                    let value = element.dataset[attribute];
28                    service[attribute] = me.setValueWithType(value);
29                });
30                if (typeof pctCookiesCallback !== 'undefined' && typeof pctCookiesCallback[service.name] === 'function') {
31                    service.callback = pctCookiesCallback[service.name];
32                }
33                pctCookiesConfig.services.push(service);
34            });
35        }
36    },
37    setValueWithType: function(value) {
38        if (!isNaN(value)) {
39            return parseInt(value);
40        }
41        else if (value === 'true' || value === 'false') {
42            return (value === 'true');
43        }
44        else if (value !== '' && value[0] === '[') {
45            return value.substr(1, value.length - 2).split(',');
46        }
47        else {
48            return value;
49        }
50    }
51};
52
53pctCookiesConfig = {
54    // You can customize the ID of the DIV element that Klaro will create
55    // when starting up. If undefined, Klaro will use 'klaro'.
56    elementID: 'pctCookies',
57
58    // Setting this to true will render the descriptions of the consent
59    // modal and consent notice are HTML. Use with care.
60    htmlTexts: true,
61
62    // Setting 'embedded' to true will render the Klaro modal and notice without
63    // the modal background, allowing you to e.g. embed them into a specific element
64    // of your website, such as your privacy notice.
65    embedded: false,
66
67    // You can group services by their purpose in the modal. This is advisable
68    // if you have a large number of services. Users can then enable or disable
69    // entire groups of services instead of having to enable or disable every service.
70    groupByPurpose: true,
71
72    // How Klaro should store the user's preferences. It can be either 'cookie'
73    // (the default) or 'localStorage'.
74    storageMethod: 'cookie',
75
76    // You can customize the name of the cookie that Klaro uses for storing
77    // user consent decisions. If undefined, Klaro will use 'klaro'.
78    cookieName: 'pct_cookies',
79
80    // You can also set a custom expiration time for the Klaro cookie.
81    // By default, it will expire after 120 days.
82    cookieExpiresAfterDays: 365,
83
84    // Defines the default state for services (true=enabled by default).
85    default: false,
86
87    // If "mustConsent" is set to true, Klaro will directly display the consent
88    // manager modal and not allow the user to close it before having actively
89    // consented or declines the use of third-party services.
90    mustConsent: false,
91
92    // Show "accept all" to accept all services instead of "ok" that only accepts
93    // required and "default: true" services
94    acceptAll: true,
95
96    // replace "decline" with cookie manager modal
97    hideDeclineAll: true,
98
99    // hide "learnMore" link
100    hideLearnMore: false,
101
102    // show cookie notice as modal
103    noticeAsModal: false,
104
105    disablePoweredBy: true,
106
107    // you can specify an additional class (or classes) that will be added to the Klaro `div`
108    additionalClass: 'pct-cookies',
109
110    // You can define the UI language directly here. If undefined, Klaro will
111    // use the value given in the global "lang" variable. If that does
112    // not exist, it will use the value given in the "lang" attribute of your
113    // HTML tag. If that also doesn't exist, it will use 'en'.
114    //lang: 'en',
115};
116
117// Example config that shows how to overwrite translations:
118// https://github.com/KIProtect/klaro/blob/master/src/configs/i18n.js
119pctCookiesConfig.translations = {
120
121};
122
123pctCookies.init();

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.