PageSourceSearch

https://www.dubaione.ae/etc/designs/dmi-corporate/coockie-policy/cookie-warn.js

js dubaione.ae collected 2026-10-02 14:38:41 UTC 9,177 bytes, 293 lines download raw bytes

1(function (fn) {
2
3    "use strict";
4
5    // element id for styles
6    var elementId = fn + 'Box';
7    var cookieName = 'cookieWarn.accepted';
8
9    // get cookieWarn element
10    var el = document.getElementById(fn);
11
12    if (!el) {
13        console.warn(fn + ' element not found by id');
14        return;
15    }
16
17    // get cookie warn attributes
18    var getAttributes = function () {
19
20        var lang = document.documentElement.lang ? document.documentElement.lang : 'en';
21        var langData = el.getAttribute('data-lang-' + lang);
22        var data;
23
24        if (!langData) {
25            data = {
26                'text': document.getElementById('cktext').value,
27                'accept_text': document.getElementById('ckoktext').value,
28                'more_text': '',
29                'more_link': '',
30                'reject_text': '',
31                'reject_info': '',
32                'reject_link': ''
33            };
34        } else {
35            data = JSON.parse(langData.replace(/'/g, '"'));
36        }
37
38        var attributes = {
39            delay: parseInt(el.getAttribute('data-delay')),
40            expire: parseInt(el.getAttribute('data-expire')),
41            domain: el.getAttribute('data-domain'),
42            path: el.getAttribute('data-path'),
43            secure: el.getAttribute('data-secure'),
44            debug: el.getAttribute('data-debug'),
45            style: el.getAttribute('data-style'),
46            class: el.getAttribute('data-class'),
47            callback: el.getAttribute('data-callback'),
48            data: data
49        };
50
51        attributes.path = attributes.path ? attributes.path : '/';
52        attributes.delay = attributes.delay ? attributes.delay : 500;
53        attributes.expire = attributes.expire ? attributes.expire : 365;
54        attributes.secure = attributes.secure == "true" ? true : false;
55        attributes.debug = attributes.debug == "true" ? true : false;
56
57        if (attributes.debug) {
58            console.log(attributes);
59        }
60
61        return attributes;
62
63    };
64
65
66    // get cookieWarn html attributes
67    var attributes = getAttributes();
68
69
70    // set or get cookie
71    var cookie = function (name, value, days, path, domain, secure) {
72
73        if (value === undefined) {
74
75            var i, x, y, cookies = document.cookie.split(";");
76
77            for (i = 0; i < cookies.length; i++) {
78
79                x = cookies[i].substr(0, cookies[i].indexOf("="));
80                y = cookies[i].substr(cookies[i].indexOf("=") + 1);
81                x = x.replace(/^\s+|\s+$/g, "");
82
83                if (x == name) {
84                    return y;
85                }
86
87            }
88
89        } else {
90
91            var values = [];
92            var expire = new Date();
93
94            days = days ? days : 365;
95            expire.setDate(expire.getDate() + days);
96
97            if (days !== undefined && days !== null) {
98                values.push("expires=" + expire.toGMTString());
99            }
100
101            if (path !== undefined && path !== null) {
102                values.push("path=" + path);
103            }
104
105            if (domain !== undefined && domain !== null) {
106                values.push("domain=" + domain);
107            }
108
109            if (secure !== undefined && secure !== null && secure) {
110                values.push("secure");
111            }
112
113            if (values.length > 0) {
114                value = value + "; " + values.join("; ");
115            }
116
117            if (attributes.debug) {
118                console.log(name, value);
119            }
120
121            document.cookie = escape(name) + "=" + value;
122
123        }
124
125    };
126
127    // warning box close function
128    window[fn] = {
129
130        accept: function () {
131
132            // set the cookie
133            cookie(cookieName, true, attributes.expire, attributes.path, attributes.domain, attributes.secure);
134
135            // remove warning box
136            var wbox = document.getElementById(elementId);
137            wbox.className = wbox.className + ' closed';
138
139            cookieWarnValue = true;
140            check(cookieWarnValue);
141
142			//Accesibility cookie popup keyboard trap
143            const govtLogo = document.querySelector("#govtlogo");
144            event.preventDefault();
145            govtLogo.focus();
146
147
148        },
149
150        reject: function () {
151
152            // set the cookie
153            cookie(cookieName, false, attributes.expire, attributes.path, attributes.domain, attributes.secure);
154
155            // show reject information
156            var wbox = document.getElementById(elementId);
157            wbox.className = wbox.className + ' reject';
158
159            cookieWarnValue = false;
160            check(cookieWarnValue);
161
162        },
163
164    };
165
166    var cookieWarnValue = cookie(cookieName);
167
168    // check
169    var check = function (cookieWarnValue) {
170
171        var accepted = cookieWarnValue == 'true' || cookieWarnValue === true ? true : false;
172
173        if (attributes.debug) {
174            console.log('status: ' + (accepted ? 'accepted' : 'rejected'));
175        }
176
177        if (attributes.callback && window[attributes.callback]) {
178            if (attributes.debug) {
179                console.log('call: ' + attributes.callback);
180            }
181            window[attributes.callback](accepted);
182        }
183
184    };
185
186    var warn = function () {
187
188        if (!attributes.data) {
189            console.error('Empty or invalid data-lang parameters');
190            return;
191        }
192
193        var bootstrap = (window.jQuery && typeof $().modal == 'function');
194
195        var css = {
196
197            style: [
198                '#' + elementId + ' {transition:all 0.4s ease-in-out;position:fixed;z-index:999999;bottom:-20px;left:0;right:0;opacity:0;text-align:center;padding:10px;background-color:#212121}',
199                '#' + elementId + ' .btn {white-space:nowrap}',
200                '#' + elementId + ' .reject_more {padding:0px 10px;display:none;}',
201                '#' + elementId + '.reject .reject_more {display:block;}',
202                '#' + elementId + '.loaded {opacity:0.9;bottom:0px}',
203                '#' + elementId + '.closed {display:none;}'
204            ],
205            style2: [
206                '#' + elementId + ' {font-family: Verdana;line-height:24px;color:#f1f1f1;font-size:14px;}',
207                '#' + elementId + ' .btn {text-transform:uppercase;cursor:pointer;background-color:#f1f1f1;color:#659fda;padding:3px 14px;margin-left:10px;}',
208                '#' + elementId + ' .btn:hover {background-color:#ffffff;color:#4d78a5;}',
209                '#' + elementId + ' a {text-decoration:none;color:#659fda}',
210            ],
211            type: 'text/css',
212            element: document.createElement('style'),
213            append: function () {
214
215                if (!bootstrap) {
216                    this.style = this.style.concat(this.style2);
217                }
218
219                if (attributes.style) {
220                    this.style = this.style.concat(attributes.style);
221                }
222
223                this.element.type = this.type;
224                this.element.appendChild(document.createTextNode(this.style.join(' ')));
225                document.head.insertBefore(this.element, document.head.childNodes[0]);
226
227            }
228        };
229
230        css.append();
231
232        // create warning box
233        var wbox = document.createElement('div');
234        wbox.setAttribute("id", elementId);
235
236        if (attributes.class) {
237            wbox.setAttribute("class", attributes.class);
238        }
239
240        var info = (attributes.data.more_link && attributes.data.more_text) ? ' <a target="_blank" href="' + attributes.data.more_link + '">' + attributes.data.more_text + '</a> ' : '';
241        var accept_button = '<button class="btn btn-success" id="' + fn + 'Accept" onclick="' + fn + '.accept();">' + attributes.data.accept_text + '</button>';
242        var reject_button, reject_content;
243
244        if (attributes.data.reject_text) {
245            reject_button = '<button class="btn btn-warning" onclick="' + fn + '.reject();">' + attributes.data.reject_text + '</button>';
246            reject_content = '<button class="reject_more">' + attributes.data.reject_info + ' <a target="_blank" href="' + attributes.data.reject_link + '">' + attributes.data.reject_link + '</a></button>';
247        } else {
248            reject_button = '';
249            reject_content = '';
250        }
251
252        wbox.innerHTML = '<div class="text">' + attributes.data.text + info + accept_button + reject_button + reject_content + '</div>';
253
254        // append to body
255        var body = document.getElementsByTagName("body")[0];
256        body.appendChild(wbox);
257
258        setTimeout(function () {
259            wbox.className = wbox.className + ' loaded';
260        }, attributes.delay);
261
262    };
263
264
265    var isDOMready = function () {
266
267        var readyState = document.readyState;
268
269        if (attributes.debug) {
270            console.log('readyState: ' + readyState);
271        }
272
273        if (readyState == 'complete') {
274
275            if (!cookieWarnValue) {
276                warn();
277            } else {
278                check(cookieWarnValue);
279            }
280
281        } else {
282            setTimeout(function () {
283                isDOMready();
284            }, 200);
285        }
286
287    };
288
289    isDOMready();
290
291})('cookieWarn');
292
293

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.