PageSourceSearch

https://www.onb.ac.at/typo3conf/ext/f_cookies/Resources/Public/Js/fcc-cookie-consent.js?1789643165

js onb.ac.at collected 2026-09-24 08:37:00 UTC 12,835 bytes, 331 lines download raw bytes

1const fcc_accordion_items = document.querySelectorAll('.fcc-accordion-item_cookie-category');
2
3/**
4 * remove cookie banner animation
5 */
6
7if (typeof $ !== 'undefined' && typeof Cookies !== 'undefined' && document.querySelector('.fcc-cookie-modal') && Cookies.get('fcc_cookie_consent') === '1') {
8    document.querySelector('.fcc-cookie-modal').style.setProperty('transition','none');
9}
10
11/**
12 * Toggle Checkbox all on/off on page load
13 */
14
15window.onload = function() {
16    fcc_cookies.forEach(function (fcc_single_cookies) {
17        Object.keys(fcc_single_cookies).forEach(function (item, index) {
18            let cookieName = fcc_single_cookies[item]['title'];
19            if(Cookies.get(fcc_single_cookies[item]['title']) == '1')  {
20                document.querySelector('.fcc-accordion-item_cookie-single-cookie .fcc-cookie-accordion-item_title input[id="' + cookieName + '"]').checked = true;
21            } else {
22                document.querySelector('.fcc-accordion-item_cookie-single-cookie .fcc-cookie-accordion-item_title input[id="' + cookieName + '"]').checked = false;
23                document.querySelector('.fcc-accordion-item_cookie-single-cookie .fcc-cookie-accordion-item_title .fcc-input-necessary').checked = true;
24            }
25        });
26    });
27
28    fcc_accordion_items.forEach(function(fcc_single_accordion_item){
29        let fcc_category_title = fcc_single_accordion_item.querySelector(".fcc-cookie-accordion-item_title");
30        let fcc_category_input = fcc_category_title.querySelectorAll(":scope > .fcc-cookie-accordion-item_input > input");
31
32        fcc_category_input.forEach(function(fcc_single_input){
33            let fcc_child_inputs = document.querySelectorAll('[data-fcc-cookie-category="' + fcc_single_input.getAttribute('id') + '"]');
34
35            fcc_child_inputs.forEach(function(fcc_cookie_inputs) {
36                let fcc_child_inputsChecked = document.querySelectorAll('[data-fcc-cookie-category="' + fcc_single_input.getAttribute('id') + '"]:checked');
37
38                if ( fcc_child_inputs.length === fcc_child_inputsChecked.length ) {
39                    fcc_single_input.checked = true;
40                }
41                else {
42                    fcc_single_input.checked = false;
43                }
44            });
45        });
46    });
47}
48
49/**
50 * Toggle Accordion Item only one open at the same time
51 */
52fcc_accordion_items.forEach(function(fcc_single_accordion_item){
53    fcc_single_accordion_item.addEventListener('toggle', fcc_cookie_accordion_open_one_only);
54});
55
56function fcc_cookie_accordion_open_one_only(e) {
57    if (this.open) {
58        fcc_accordion_items.forEach(fcc_single_accordion_item=>{
59            if (fcc_single_accordion_item!=this && fcc_single_accordion_item.open) fcc_single_accordion_item.open = false
60        });
61    }
62}
63
64/**
65 * Toggle Checkbox all on/off
66 */
67fcc_accordion_items.forEach(function(fcc_single_accordion_item){
68    let fcc_category_title = fcc_single_accordion_item.querySelector(".fcc-cookie-accordion-item_title");
69    let fcc_category_input = fcc_category_title.querySelectorAll(":scope > .fcc-cookie-accordion-item_input > input");
70
71    fcc_category_input.forEach(function(fcc_single_input){
72        let fcc_child_inputs = document.querySelectorAll('[data-fcc-cookie-category="' + fcc_single_input.getAttribute('id') + '"]');
73
74        fcc_single_input.addEventListener('change', function (event) {
75            if ( fcc_single_input.checked === true ) {
76                fcc_child_inputs.forEach(function(fcc_cookie_inputs) {
77                    fcc_cookie_inputs.checked = true;
78                });
79            }
80            else {
81                fcc_child_inputs.forEach(function(fcc_cookie_inputs) {
82                    fcc_cookie_inputs.checked = false;
83                });
84            }
85        });
86
87        fcc_child_inputs.forEach(function(fcc_cookie_inputs) {
88            fcc_cookie_inputs.addEventListener('change', function (event) {
89                let fcc_child_inputsChecked = document.querySelectorAll('[data-fcc-cookie-category="' + fcc_single_input.getAttribute('id') + '"]:checked');
90
91                if ( fcc_child_inputs.length === fcc_child_inputsChecked.length ) {
92                    fcc_single_input.checked = true;
93                }
94                else {
95                    fcc_single_input.checked = false;
96                }
97            }, false);
98        });
99    });
100});
101
102/**
103 * Enable tab navigation for checkboxes
104 */
105document.querySelectorAll('.fcc-cookie-accordion-item_title label').forEach(function(fcc_cookie_inputs) {
106    fcc_cookie_inputs.addEventListener('keypress', function (event) {
107        if (event.key === 'Enter') {
108            this.click();
109        }
110    }, false);
111});
112
113
114/**
115 * Save cookies
116 */
117let fcc_cookies = fcc_cookie_array;
118let fcc_btn_settings =  document.querySelector('.fcc-cookie-button_settings');
119let fcc_btn_save_settings = document.querySelector('.fcc-cookie-button_accept-settings');
120let fcc_btn_disable_all = document.querySelector('.fcc-cookie-button_disable-all');
121let fcc_btn_accept_all = document.querySelector('.fcc-cookie-button_accept-all');
122let fcc_allcookie_inputs = document.querySelectorAll('.fcc-cookie-accordion-item .fcc-cookie-accordion-item_title .fcc-cookie-accordion-item_input_class');
123
124if (typeof (fcc_btn_settings) !== undefined) {
125    if (fcc_btn_settings !== null) {
126        if(document.querySelector('#fccCookieModal').classList.contains('minified')) {
127            fcc_btn_save_settings.parentElement.classList.add('hidden');
128        } else {
129            fcc_btn_settings.parentElement.classList.add('hidden');
130        }
131
132        if(Cookies.get('fcc_cookie_consent_minified') == '1') {
133            fcc_btn_settings.parentElement.classList.add('hidden');
134            fcc_btn_save_settings.parentElement.classList.remove('hidden');
135        }
136
137        fcc_btn_settings.addEventListener('click', function (event) {
138            fcc_btn_settings.parentElement.classList.add('hidden');
139            fcc_btn_save_settings.parentElement.classList.remove('hidden');
140
141            if(document.querySelector('#fccCookieModal').classList.contains('minified')) {
142                document.querySelector('#fccCookieModal').classList.remove('minified')
143            }
144        });
145    }
146}
147
148if (typeof(fcc_btn_accept_all) !== undefined && fcc_btn_accept_all !== null) {
149    fcc_btn_accept_all.addEventListener('click', function (event) {
150        fcc_allcookie_inputs.forEach(function(fcc_allcookie_input_item) {
151            fcc_allcookie_input_item.checked = true;
152        });
153        fcc_btn_save_settings.click();
154    }, false);
155}
156
157if (typeof(fcc_btn_disable_all) !== undefined && fcc_btn_disable_all !== null) {
158    fcc_btn_disable_all.addEventListener('click', function (event) {
159        fcc_allcookie_inputs.forEach(function (fcc_allcookie_input_item) {
160            if (fcc_allcookie_input_item.disabled === true) {
161                fcc_allcookie_input_item.checked = true;
162            } else {
163                fcc_allcookie_input_item.checked = false;
164            }
165        });
166        fcc_btn_save_settings.click();
167    }, false);
168}
169
170if (typeof (fcc_btn_save_settings) !== undefined) {
171    if (fcc_btn_save_settings !== null) {
172        fcc_btn_save_settings.addEventListener('click', function (event) {
173            fcc_cookies.forEach(function (fcc_single_cookies) {
174                Object.keys(fcc_single_cookies).forEach(function (item, index) {
175                    // console.log("item: " + item); // key
176                    // console.log(fcc_single_cookies[item]); // value
177                    // console.log(fcc_single_cookies[item]['title']); // title string
178                    // console.log(fcc_single_cookies[item]['lifetime']); // lifetime int
179                    // console.log(fcc_single_cookies[item]['accepted']); // accepted bool
180                    let cookieName = fcc_single_cookies[item]['title'];
181                    var cookieLifetime = fcc_single_cookies[item]['lifetime'];
182
183                    if (document.querySelector('.fcc-accordion-item_cookie-single-cookie .fcc-cookie-accordion-item_title input[id="' + cookieName + '"]').checked === true) {
184                        if(cookieLifetime === 0) {
185                            Cookies.set(cookieName, '1');
186                        } else {
187                            Cookies.set(cookieName, '1', { expires: cookieLifetime });
188                        }
189                    } else {
190                        Cookies.remove('fcc_cookie_consent');
191                        Cookies.remove(cookieName);
192                    }
193                });
194            });
195            Cookies.set('fcc_cookie_consent', '1', {expires: 365, secure: true});
196            /* add Cookies to URL */
197            setCookies();
198
199            fcc_close_modal();
200            location.reload();
201        }, false);
202    }
203}
204
205
206/**
207 * remove minified class
208 */
209
210if(Cookies.get('fcc_cookie_consent_minified') == '1') {
211    document.querySelector('#fccCookieModal').classList.remove('minified')
212}
213
214/**
215 *
216 * @type {Element}
217 */
218const fcc_cookie_modal_window = document.querySelector('.fcc-cookie-modal');
219const fcc_privacy_link_for_focus = document.querySelector('.fcc-cookie-modal-content_privacy-link a');
220const fcc_cookie_tab_for_focus = document.querySelector('.fcc-accordion-item_cookie-category:first-child .fcc-cookie-accordion-item_title');
221let url = new URL(window.location.href);
222if(Cookies.get('fcc_cookie_consent') !== '1' && !url.searchParams.get('noconsent')) {
223    if (typeof(fcc_cookie_modal_window) !== undefined && fcc_cookie_modal_window !== null) {
224        fcc_cookie_modal_window.classList.add('fcc-show-modal');
225
226        if ( typeof(fcc_privacy_link_for_focus) !== undefined && fcc_privacy_link_for_focus !== null ) {
227            fcc_privacy_link_for_focus.focus();
228        }
229        else {
230            if ( typeof(fcc_cookie_tab_for_focus) !== undefined && fcc_cookie_tab_for_focus !== null ) {
231                fcc_cookie_tab_for_focus.focus();
232            }
233        }
234    }
235}
236else {
237    fcc_close_modal();
238}
239
240function fcc_close_modal() {
241    if (typeof(fcc_cookie_modal_window) !== undefined && fcc_cookie_modal_window !== null) {
242        fcc_cookie_modal_window.classList.remove('fcc-show-modal');
243    }
244}
245
246function setCookies() {
247    let currentCookies = 'CookieNotice';
248
249    if(Cookies.get('fcc_cookie_consent') == '1') {
250        currentCookies+= '=1;';
251    } else {
252        currentCookies+= '=0;';
253    }
254
255    fcc_cookies.forEach(function (fcc_single_cookies) {
256        Object.keys(fcc_single_cookies).forEach(function (item, index) {
257            var cookieName = fcc_single_cookies[item]['title'];
258
259            if(Cookies.get(fcc_single_cookies[item]['title']) == '1')  {
260                currentCookies+= ''+ cookieName + '=1;';
261            } else {
262                currentCookies+= ''+ cookieName + '=0;';
263            }
264        });
265    });
266
267    let redirectUrl = new URL (window.location);
268    let consentUrl = document.querySelector('#fccCookieModal').dataset.consentUrl;
269
270    if(consentUrl.length > 0) {
271        redirectUrl = new URL(consentUrl);
272    }
273
274    redirectUrl.searchParams.set('cookies', currentCookies);
275    window.history.pushState({}, '', redirectUrl);
276    location.reload();
277}
278
279/**
280 * Reset Link to show Cookie Modal again
281 * @type {Element}
282 */
283
284const $resetLinks = $('a[href="#fcc-reset-cookie"], a[href$="#fcc-reset-cookie"]').not('.show-content');
285
286if ($resetLinks.length) {
287    $resetLinks.on('click', function(event) {
288        event.preventDefault();
289
290        Cookies.remove('fcc_cookie_consent');
291
292        var base = location.href.split('#')[0];
293        var hash = location.hash || '';
294        var sep = base.indexOf('?') >= 0 ? '&' : '?';
295
296        location.href = base + sep + 'cookiereload=1' + hash;
297        location.reload();
298    });
299}
300
301/**
302 * Enable ESC for Modal window
303 */
304document.addEventListener('keydown', function (event) {
305    if(event.key === "Escape"){
306        if( Cookies.get('fcc_cookie_consent') !== '1' ) {
307            fcc_btn_save_settings.click();
308        }
309    }
310}, false);
311
312/**
313 * show personal-id
314 */
315
316let showIDLink = document.querySelector('.show-id');
317
318if (typeof (showIDLink) !== undefined) {
319    if (showIDLink !== null) {
320        showIDLink.addEventListener('click', function (event) {
321            event.preventDefault();
322            let personalID = document.querySelector('.personal-id');
323            personalID.classList.remove('hidden');
324            event.target.classList.add('hidden');
325        }, false);
326    }
327}
328
329
330
331

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.