PageSourceSearch

https://enterprise.gov.ie/includes/js/cookies.js

js enterprise.gov.ie collected 2026-10-02 02:16:33 UTC 11,992 bytes, 290 lines download raw bytes

1var userInputs = {};
2var siteName = "Site";
3var colour1 = "#020066";
4var colour2 = "#800000";
5var colour3 = "#fff";
6var url = "/cookie-management/";
7var container = "#main";
8var bodyTag = "none";
9
10function cookie(name, value, options) {
11    if (typeof value != 'undefined') {
12        options = options || {};
13        if (value === null) {
14            value = '';
15            options.expires = -1;
16        }
17        var expires = '';
18        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
19            var date;
20            if (typeof options.expires == 'number') {
21                date = new Date();
22                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
23            } else {
24                date = options.expires;
25            }
26            expires = '; expires=' + date.toUTCString();
27        }
28        var path = options.path ? '; path=' + (options.path) : '';
29        var domain = options.domain ? '; domain=' + (options.domain) : '';
30        var secure = options.secure ? '; secure' : '';
31        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
32    } else {
33        var cookieValue = null;
34        if (document.cookie && document.cookie != '') {
35            var cookies = document.cookie.split(';');
36            for (var i = 0; i < cookies.length; i++) {
37                var cookie = cookies[i].trim();
38                if (cookie.substring(0, name.length + 1) == (name + '=')) {
39                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
40                    break;
41                }
42            }
43        }
44        return cookieValue;
45    }
46};
47if (!Element.prototype.matches) {
48    Element.prototype.matches = Element.prototype.msMatchesSelector ||
49        Element.prototype.webkitMatchesSelector;
50}
51
52if (!Element.prototype.closest) {
53    Element.prototype.closest = function (s) {
54        var el = this;
55
56        do {
57            if (Element.prototype.matches.call(el, s)) return el;
58            el = el.parentElement || el.parentNode;
59        } while (el !== null && el.nodeType === 1);
60        return null;
61    };
62}
63"use strict";
64
65function CookieCheck(userInputs) {
66    if (userInputs.siteName != null) {
67        siteName = userInputs.siteName;
68    }
69    try {
70        if (userInputs.colours[0] != null) {
71            colour1 = userInputs.colours[0];
72        }
73        if (userInputs.colours[1] != null) {
74            colour2 = userInputs.colours[1];
75        }
76        if (userInputs.colours[2] != null) {
77            colour3 = userInputs.colours[2];
78        }
79    } catch (e) {
80        console.log(e);
81    }
82    if (userInputs.url != null) {
83        url = userInputs.url;
84    }
85    if (userInputs.container != null) {
86        container = userInputs.container;
87    }
88    if (userInputs.header != null) {
89        bodyTag = userInputs.header[0];
90    }
91    var observer = new MutationObserver(function (mutations) {
92
93        mutations.forEach(function (_ref) {
94            var addedNodes = _ref.addedNodes;
95            [].forEach.call(addedNodes, function (node) {
96                if (node.nodeType === 1 && node.tagName === 'SCRIPT') {
97                    [].forEach.call(addedNodes, function (node) {
98                        if ((node.closest(container) != null && node.getAttribute('src') != null) || (node.closest("#ThirdParty"))) {
99                            node.setAttribute("type", "javascript/blocked");
100                            node.outerHTML = '<div class="video-block"><a href="' + url + '">Please accept all cookies to View this content</a></div>';
101                        }
102                        const beforeScriptExecuteListener = function (event) {
103                            // Prevent only marked scripts from executing
104                            if (node.getAttribute('type') === 'javascript/blocked')
105                                event.preventDefault()
106                            node.removeEventListener('beforescriptexecute', beforeScriptExecuteListener)
107                        }
108                        node.addEventListener('beforescriptexecute', beforeScriptExecuteListener)
109                    });
110                }
111
112                if (node.tagName === 'IFRAME') {
113                    [].forEach.call(addedNodes, function (node) {
114                        if (node.closest(container) != null) {
115                            var src = node.getAttribute('src');
116                            var html = '<div class="video-block cookie-blk"><p>Please accept cookies to view this content.</p><p>Read our <a href="/en/privacy-statement/">cookies policy</a> to find out more about cookies and how we use them.</p><a class="btn btn-default" onclick="acceptCookie();">I accept cookies</a></div>';
117                            try {
118                                if ((src.indexOf("www.youtube.com") === -1) && (src.indexOf("www.youtube-nocookie.com") === -1)) {
119                                    node.outerHTML = html;
120                                }
121                            } catch (ex) {
122                                node.outerHTML = '<div class="video-block"><a href="' + url + '">
122Please accept all cookies to View this content</a></div>';
123                            }
124                        }
125                    });
126                }
127                if (node.tagName === 'OBJECT') {
128                    [].forEach.call(addedNodes, function (node) {
129                        if (node.closest(container) != null) {
130                            node.outerHTML = '<div class="video-block"><a href="' + url + '">Please accept all cookies to View this content</a></div>';
131                        }
132                    });
133                }
134            });
135        });
136    });
137
138    var youtubeObserver = new MutationObserver(function (mutations) {
139        mutations.forEach(function (_ref) {
140            var addedNodes = _ref.addedNodes;
141            [].forEach.call(addedNodes, function (node) {
142
143                if (node.tagName === 'IFRAME') {
144                    [].forEach.call(addedNodes, function (node) {
145
146                        if (node.closest(container) != null) {
147                            var src = node.getAttribute('src');
148
149                            var youtubehtml = '<div class="video-block cookie-blk"><p>Please accept YouTube cookies to view this content.</p><p>Read our <a href="/en/privacy-statement/">cookies policy</a> to find out more about cookies and how we use them.</p><a class="btn btn-default" onclick="acceptYoutubeCookies();">I accept YouTube cookies</a></div>';
150
151                            if ((src.indexOf("www.youtube.com") > 0) || (src.indexOf("www.youtube-nocookie.com") > 0)) {
152                                node.outerHTML = youtubehtml;
153
154                            }
155                        }
156                    });
157                }
158
159            });
160        });
161    });
162
163    if (cookie("CookieYouTube") == "youTubeAgree") {
164    }
165    else {
166        youtubeObserver.observe(document.documentElement, {
167            childList: true,
168            subtree: true
169        })
170
171    }
172
173    if (cookie("CookieFunctional") == "funcAgree" && cookie("CookieAdvertising") == "advertAgree") { }
174    else {
175        observer.observe(document.documentElement, {
176            childList: true,
177            subtree: true
178        })
179    }
180
181    window.addEventListener('load', function () {
182        observer.disconnect();
183        if (document.cookie.indexOf(siteName + "_cookies") < 0 && bodyTag != "none") {
184            AddHeader();
185        }
186        else if (document.cookie.indexOf(siteName + "_cookies") < 0 && bodyTag == "none") {
187            document.getElementById("globalCookieBar").style.display = "block";
188        }
189    });
190}
191
192function acceptCookie() {
193    var path = "; path=/;";
194    var date = new Date();
195    date.setTime(date.getTime() + (178 * 24 * 60 * 60 * 1000));
196    var expires = "; expires=" + date.toGMTString();
197    document.cookie = siteName + "_cookies=true" + expires + path + "SameSite=Lax;";
198    document.cookie = "CookieFunctional=funcAgree" + expires + path + "SameSite=Lax;";
199    document.cookie = "CookieAnalytical=analyticsAgree" + expires + path + "SameSite=Lax;";
200    document.cookie = "CookieYouTube=youTubeAgree" + expires + path + "SameSite=Lax;";
201    //document.cookie = "CookiePerformance=perfAgree" + expires + path + "SameSite=Lax;";
202    document.cookie = "CookieAdvertising=advertAgree" + expires + path + "SameSite=Lax;";
203
204    document.location.reload(true);
205}
206
207
208function acceptYoutubeCookies() {
209    var path = "; path=/;";
210
211    var date = new Date();
212    date.setTime(date.getTime() + (178 * 24 * 60 * 60 * 1000));
213    var expires = "; expires=" + date.toGMTString();
214    document.cookie = "CookieYouTube=youTubeAgree" + expires + path + "SameSite=Lax;";
215    document.location.reload(true);
216}
217
218function acceptNecessaryCookie() {
219    deleteAllCookies();
220    var path = "; path=/;";
221
222    var date = new Date();
223    date.setTime(date.getTime() + (178 * 24 * 60 * 60 * 1000));
224    var expires = "; expires=" + date.toGMTString();
225    document.cookie = siteName + "_cookies=true" + expires + path + "SameSite=Lax;";
226    document.cookie = "CookieFunctional=funcDisagree" + expires + path + "SameSite=Lax;";
227    document.cookie = "CookieAnalytical=analyticsDisagree" + expires + path + "SameSite=Lax;";
228    document.cookie = "CookieYouTube=youTubeDisagree" + expires + path + "SameSite=Lax;";
229    document.cookie = "CookieAdvertising=advertDisgree" + expires + path + "SameSite=Lax;";
230    document.location.reload(true);
231}
232
233
234
235function acceptIndividualCookie(Functional, Analytical, Youtube, Advertising) {
236    deleteAllCookies();
237    var path = "; path=/;";
238
239    document.cookie.split(';').forEach(function (c) {
240        document.cookie = c.trim().split('=')[0] + '=;' + 'expires=Thu, 01 Jan 1970 00:00:00 UTC;';
241    });
242    var date = new Date();
243    date.setTime(date.getTime() + (178 * 24 * 60 * 60 * 1000));
244    var expires = "; expires=" + date.toGMTString();
245
246    document.cookie = siteName + "_cookies=true" + expires + path + "SameSite=Lax;";
247
248    if (Functional === 'true') {
249        document.cookie = "CookieFunctional=funcAgree" + expires + path + "SameSite=Lax;";
250    }
251    else {
252        document.cookie = "CookieFunctional=funcDisagree" + expires + path + "SameSite=Lax;";
253    }
254    if (Analytical === 'true') {
255        document.cookie = "CookieAnalytical=analyticsAgree" + expires + path + "SameSite=Lax;";
256    }
257    else {
258        document.cookie = "CookieAnalytical=analyticsDisagree" + expires + path + "SameSite=Lax;";
259    }
260    if (Youtube === 'true') {
261        document.cookie = "CookieYouTube=youTubeAgree" + expires + path + "SameSite=Lax;";
262    }
263    else {
264        document.cookie = "CookieYouTube=youTubeDisagree" + expires + path + "SameSite=Lax;";
265    }
266    //if (Performance === 'true') {
267    //    document.cookie = "CookiePerformance=perfAgree" + expires + path + "SameSite=Lax;";
268    //}
269    //else {
270    //    document.cookie = "CookiePerformance=perfDisagree" + expires + path + "SameSite=Lax;";
271    //}
272    if (Advertising === 'true') {
273        document.cookie = "CookieAdvertising=advertAgree" + expires + path + "SameSite=Lax;";
274    }
275    else {
276        document.cookie = "CookieAdvertising=advertDisagree" + expires + path + "SameSite=Lax;";
277    }
278
279}
280
281function deleteAllCookies() {
282    var cookies = document.cookie.split(";");
283
284    for (var i = 0; i < cookies.length; i++) {
285        var cookie = cookies[i];
286        var eqPos = cookie.indexOf("=");
287        var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
288        document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
289    }
290}

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.