PageSourceSearch

https://www.lup-ag.de/wp-content/plugins/wordpress-gdpr/public/js/wordpress-gdpr-public.js?ver=1.8.11

js lup-ag.de collected 2026-10-05 19:17:34 UTC 24,950 bytes, 621 lines download raw bytes

1(function( $ ) {
2    'use strict';
3
4    // Create the defaults once
5    var pluginName = "gdpr",
6        defaults = {
7            bla: "",
8        };
9
10    // The actual plugin constructor
11    function Plugin ( element, options ) {
12        this.element = element;
13        this.settings = $.extend( {}, defaults, options );
14        this._defaults = defaults;
15
16        this._name = pluginName;
17        this.init();
18    }
19
20    // Avoid Plugin.prototype conflicts
21    $.extend( Plugin.prototype, {
22        init: function() {
23            var that = this;
24            this.window = $(window);
25            this.documentHeight = $( document ).height();
26            this.windowHeight = this.window.height();
27            this.privacySettingsCheckPerformed = false;
28
29            this.elements = {};
30            this.elements.popUp = $('.wordpress-gdpr-popup-container');
31            this.elements.popUpAgreeLink = $('.wordpress-gdpr-popup-agree');
32            this.elements.popUpDeclineLink = $('.wordpress-gdpr-popup-decline');
33            this.elements.popUpCloseLink = $('.wordpress-gdpr-popup-close');
34            this.elements.popUpBackdrop = $('.wordpress-gdpr-popup-overlay-backdrop');
35
36            this.privacySettingsLoaded = {};
37            this.elements.privacySettingsPopupTrigger = $('.wordpress-gdpr-privacy-settings-trigger-container');
38            this.elements.privacySettingsPopup = $('.wordpress-gdpr-privacy-settings-popup');
39            this.elements.privacySettingsPopupPrivacySettings = $('.wordpress-gdpr-privacy-settings-popup-privacy-settings-modal');
40            this.elements.privacySettingsPopupAgreeLink = $('.wordpress-gdpr-privacy-settings-popup-agree');
41            this.elements.privacySettingsPopupDeclineLink = $('.wordpress-gdpr-privacy-settings-popup-decline');
42            this.elements.privacySettingsPopupCloseLink = $('.wordpress-gdpr-privacy-settings-popup-close');
43            this.elements.privacySettingsPopupBackdrop = $('.wordpress-gdpr-privacy-settings-popup-backdrop');
44
45            if(this.settings.geoIP == "1") {
46                this.getUsersCountry(function(country) {
47
48                    var euCountries = ['AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', '
48SE', 'GB'];
49                    var isEU = that.isInArray(country, euCountries);
50                    if(isEU) {
51                        that.popUp();
52                    } else {
53                        $('.wordpress-gdpr-popup-actions-buttons .wordpress-gdpr-popup-agree').trigger('click');
54                        that.elements.privacySettingsPopupTrigger.remove();
55                    }
56                });
57
58            } else {
59                this.popUp();
60            }
61            this.popUpAgree();
62            this.popUpClose();
63            this.popUpDecline();
64
65            this.popUpPrivacySettings();
66            this.popUpPrivacySettingsOpen();
67            this.popUpPrivacySettingsClose();
68
69            this.privacyPolicyTermsAcceptance();
70            this.commentFormprivacyPolicyTermsAcceptance();
71        },
72        popUp : function() {
73
74            var botPattern = "/bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex/";
75            var re = new RegExp(botPattern, 'i');
76            if (re.test(navigator.userAgent)) {
77                return false;
78            }
79
80            var that = this;
81            var cookiesAllowed = false;
82
83            $.ajax({
84                type : 'post',
85                url : that.settings.ajaxURL,
86                dataType : 'json',
87                data : {
88                    action : 'check_privacy_setting',
89                    setting : 'wordpress_gdpr_cookies_allowed',
90                    current_page_id : that.get_current_page_id()
91                },
92                success : function( response ) {
93
94                    var popupExcludePages = that.settings.popupExcludePages;
95                    var exclude = false;
96                    if(!that.isEmpty(popupExcludePages)) {
97                        var currentPage, matches = document.body.className.match(/(^|\s)post-id-(\d+)(\s|$)/);
98                        if (matches) {
99                            currentPage = matches[2];
100                        } else {
101                            matches = document.body.className.match(/(^|\s)page-id-(\d+)(\s|$)/);
102                            if (matches) {
103                                currentPage = matches[2];
104                            }
105                        }
106                        if(currentPage !== "" && that.isInArray(currentPage, popupExcludePages)) {
107                            exclude = true;
108                        }
109                    }
110
111                    if(!exclude) {
112                        if(response.firstTime) {
113                            if(that.elements.popUpBackdrop.length > 0) {
114                                that.elements.popUpBackdrop.show();
115                            }
116                            $.each($('.gdpr-service-switch:not(:disabled)'), function(i, index) {
117                                $(this).prop('checked', true);
118                            });
119                            that.elements.popUp.show();
120                        }
121                        else if((!response.allowed && !response.declined) || that.getParameterByName('gdpr') === "debug") {
122                            if(that.elements.popUpBackdrop.length > 0) {
123                                that.elements.popUpBackdrop.show();
124                            }
125                            that.elements.popUp.show();
126                        } else {
127                            if(that.elements.popUpBackdrop.length > 0) {
128                                that.elements.popUpBackdrop.hide();
129                            }
130                            that.elements.popUp.hide();
131                        }
132                    }
133
134                    that.checkPrivacySettings();
135                },
136                error: function (xhr, ajaxOptions, thrownError) {
137                    console.log(xhr);
138                    console.log(ajaxOptions);
139                    console.log(thrownError);
140                }
141             });
142        },
143        popUpClose : function() {
144
145            var that = this;
146
147            $(that.elements.popUpCloseLink).on('click', function(e) {
148                e.preventDefault();
149                if(that.elements.popUpBackdrop.length > 0) {
150                    that.elements.popUpBackdrop.fadeOut();
151                }
152                that.elements.popUp.fadeOut();
153            });
154        },
155        popUpDecline : function() {
156
157            var that = this;
158
159            that.elements.popUpDeclineLink.on('click', function(e) {
160
161                e.preventDefault();
162
163                var $this = $(this);
164                var text = $this.text();
165                $this.html('Cookies abgelehnt');
166
167                $.ajax({
168                    type : 'post',
169                    url : that.settings.ajaxURL,
170                    dataType : 'json',
171                    data : {
172                        action : 'wordpress_gdpr_decline_cookies'
173                    },
174                    success : function( response ) {
175                        if(that.elements.popUpBackdrop.length > 0) {
176                            that.elements.popUpBackdrop.fadeOut();
177                        }
178                        $('.wordpress-gdpr-privacy-settings-popup, .wordpress-gdpr-privacy-settings-popup-backdrop').fadeOut();
179                        that.elements.popUp.fadeOut();
180                        $.each($('.gdpr-service-switch:not(:disabled)'), function(i, index) {
181                            $(this).prop('checked', false);
182                        });
183                        $this.text(text);
184
185                    },
186                    error: function (xhr, ajaxOptions, thrownError) {
187                        console.log(xhr);
188                        console.log(ajaxOptions);
189                        console.log(thrownError);
190                    }
191                 });
192            });
193        },
194        popUpAgree : function() {
195
196            var that = this;
197
198            that.elements.popUpAgreeLink.on('click', function(e) {
199                e.preventDefault();
200
201
202                var $this = $(this);
203                var text = $this.text();
204                $this.html('Cookies akzeptiert');
205
206                $.ajax({
207                    type : 'post',
208                    url : that.settings.ajaxURL,
209                    dataType : 'json',
210                    data : {
211                        action : 'wordpress_gdpr_allow_cookies'
212                    },
213                    success : function( response ) {
214                        if(that.elements.popUpBackdrop.length > 0) {
215                            that.elements.popUpBackdrop.fadeOut();
216                        }
217                        $('.wordpress-gdpr-privacy-settings-popup, .wordpress-gdpr-privacy-settings-popup-backdrop').fadeOut();
218                        that.elements.popUp.fadeOut();
219                        $.each($('.gdpr-service-switch:not(:disabled)'), function(i, index) {
220                            $(this).prop('checked', true);
221                        });
222
223                        that.checkPrivacySettings();
224                        $this.text(text);
225                    },
226                    error: function (xhr, ajaxOptions, thrownError) {
227                        console.log(xhr);
228                        console.log(ajaxOptions);
229                        console.log(thrownError);
230                    }
231                 });
232            });
233        },
234        popUpPrivacySettingsOpen : function () {
235
236            var that = this;
237
238            $('.wordpress-gdpr-open-privacy-settings-modal').on('click', function(e) {
239                e.preventDefault();
240
241                if(($('.wordpress-gdpr-privacy-settings-popup-services-container').length < 1)) {
242                    alert('No GDPR Service Categories / Services created yet. Remove the trigger or create services and attach them to service categories first.');
243                    return false;
244                }
245
246                if($('.wordpress-gdpr-popup').length > 0) {
247                    $('.wordpress-gdpr-popup').hide(0, function() {
248                        $('.wordpress-gdpr-privacy-settings-popup, .wordpress-gdpr-privacy-settings-popup-backdrop').fadeIn();
249                    });
250                } else {
251                    $('.wordpress-gdpr-privacy-settings-popup, .wordpress-gdpr-privacy-settings-popup-backdrop').fadeIn();
252                }
253            });
254        },
255        popUpPrivacySettingsClose : function () {
256            var that = this;
257
258            $(that.elements.privacySettingsPopupCloseLink).on('click', function(e) {
259                e.preventDefault();
260                if(that.elements.privacySettingsPopupBackdrop.length > 0) {
261                    that.elements.privacySettingsPopupBackdrop.fadeOut();
262                }
263                that.elements.privacySettingsPopup.fadeOut();
264            });
265        },
266        popUpPrivacySettings : function() {
267
268            $('.wordpress-gdpr-popup-privacy-settings-open-service-category').on('click', function(e) {
269                e.preventDefault();
270
271                var id = $(this).data('id');
272                $('.wordpress-gdpr-popup-privacy-settings-services-content:not(#wordpress-gdpr-popup-privacy-settings-services-content-' + id + ')').hide(0, function() {
273                    $('#wordpress-gdpr-popup-privacy-settings-services-content-' + id).show();
274                });
275            });
276
277            $('.wordpress-gdpr-popup-privacy-settings-services-content-title').on('click', function(e) {
278                e.preventDefault();
279
280                var $this = $(this);
281                var id= $(this).data('id');
282                var fa = $this.find('.fa');
283
284                var description = $('#wordpress-gdpr-popup-privacy-settings-services-content-description-' + id);
285                if (description.css('display') == 'none') {
286                    description.slideDown();
287                    fa.removeClass('fa-caret-right').addClass('fa-caret-down');
288                } else {
289                    description.slideUp();
290                    fa.removeClass('fa-caret-down').addClass('fa-caret-right');
291                }
292            });
293        },
294        checkPrivacySettings : function() {
295
296            var that = this;
297            var settings = {};
298            var switches = $('.gdpr-service-switch');
299
300            $.each(switches, function() {
301                var serviceID = $(this).data('id');
302                settings[serviceID] = serviceID;
303            });
304
305            $.ajax({
306                type : 'post',
307                url : that.settings.ajaxURL,
308                dataType : 'json',
309                data : {
310                    action : 'check_privacy_settings',
311                    settings : settings
312                },
313                success : function( response ) {
314
315                    $.each(response, function(i, index) {
316
317                        if(index.head !== "" && index.allowed && !that.privacySettingsLoaded[i]) {
318                            $("head").append(index.head);
319                        }
320                        if(index.body !== "" && index.allowed && that.privacySettingsLoaded[i]) {
321                            $(index.body).prependTo($('body'));
322                        }
323
324                        if(index.adsense == "1" && !index.allowed && that.privacySettingsLoaded[i]) {
325                            var adsExists = $(".adsbygoogle");
326
327                            if(adsExists.length > 0 && that.getCookie('wordpress_gdpr_adsense_allowed') !== "true") {
328                                adsExists.remove();
329                            }
330                        }
331
332                        var checkbox_exists = $('input[name="' + i + '"]') ;
333                        if(checkbox_exists.length > 0) {
334                            if(index.allowed) {
335                                checkbox_exists.prop('checked', true);
336                                that.privacySettingsLoaded[i] = true;
337                            } else {
338                                checkbox_exists.prop('checked', false);
339                                that.privacySettingsLoaded[i] = false;
340                            }
341                        }
342
343                        if(checkbox_exists.length > 0 && !that.privacySettingsCheckPerformed) {
344
345                            checkbox_exists.on('change', function(e) {
346
347                                var checked = $(this).prop('checked');
348                                var name = $(this).prop('name');
349
350                                $('.wordpress-gdpr-privacy-settings-popup-message').fadeIn();
351
352                                $.ajax({
353                                    type : 'post',
354                                    url : that.settings.ajaxURL,
355                                    dataType : 'json',
356                                    data : {
357                                        action : 'update_privacy_setting',
358                                        setting : name,
359                                        checked : checked,
360                                    },
361                                    success : function( response ) {
362
363                                        setTimeout(function(){ $('.wordpress-gdpr-privacy-settings-popup-message').fadeOut(); }, 1500);
364
365                                        var index = response[name];
366
367                                        if(index.head !== "" && index.allowed && that.privacySettingsLoaded[name]) {
368                                            $("head").append(index.head);
369                                        }
370                                        if(index.body !== "" && index.allowed && that.privacySettingsLoaded[name]) {
371                                            $(index.body).prependTo($('body'));
372                                        }
373
374                                        if(index.adsense == "1" && !index.allowed && that.privacySettingsLoaded[name]) {
375                                            var adsExists = $(".adsbygoogle");
376
377                                            if(adsExists.length >
377 0 && that.getCookie('wordpress_gdpr_adsense_allowed') !== "true") {
378                                                adsExists.remove();
379                                            }
380                                        }
381
382
383                                        var checkbox_exists = $('input[name="' + name + '"]') ;
384                                        if(checkbox_exists.length > 0) {
385                                            if(index.allowed) {
386                                                checkbox_exists.prop('checked', true);
387                                                that.privacySettingsLoaded[name] = true;
388                                            } else {
389                                                checkbox_exists.prop('checked', false);
390                                            }
391                                        }
392                                    }
393                                });
394                            });
395                        }
396                    });
397                    that.privacySettingsCheckPerformed = true;
398                },
399                error: function (xhr, ajaxOptions, thrownError) {
400                    console.log(xhr);
401                    console.log(ajaxOptions);
402                    console.log(thrownError);
403                }
404             });
405        },
406        get_current_page_id : function() {
407            var page_body = $('body.page');
408
409            var id = 0;
410
411            if(page_body) {
412                var page_body_class = page_body.attr('class')
413
414                if(page_body_class || page_body_class != null) {
415                    if(page_body_class.length > 1) {
416                        var page_body_class_list = page_body_class.split(/\s+/);
417
418                        $.each(page_body_class_list, function(index, item) {
419                            if (item.indexOf('page-id') >= 0) {
420                                var item_arr = item.split('-');
421                                id =  item_arr[item_arr.length -1];
422                                return false;
423                            }
424                        });
425                    }
426                }
427            }
428            return id;
429        },
430        getUsersCountry : function(callback) {
431            var that = this;
432
433            $.ajax({
434                url: "https://extreme-ip-lookup.com/json/",
435                type: 'get',
436                dataType: 'json',
437                success : function( response ) {
438                    callback(response.countryCode);
439                },
440                error: function(jqXHR, textStatus, errorThrown) {
441                    console.log(jqXHR);
442                    console.log(textStatus);
443                    console.log(errorThrown);
444                }
445            });
446        },
447        commentFormprivacyPolicyTermsAcceptance : function() {
448            var that = this;
449
450            var submit = $('#commentform input[type="submit"]');
451            if(submit.length < 1) {
452                return false;
453            }
454
455            var checkbox = $('#commentform #privacy_policy');
456            if(checkbox.length < 1) {
457                return false;
458            }
459
460            submit.on('click', function(e) {
461                var checkboxChecked = checkbox.is(':checked');
462                if(!checkboxChecked) {
463                    e.preventDefault();
464                    alert(that.settings.acceptanceText);
465                    return false;
466                }
467
468                $.ajax({
469                    type : 'post',
470                    url : that.settings.ajaxURL,
471                    dataType : 'json',
472                    data : {
473                        action : 'wordpress_gdpr_update_privacy_policy_terms',
474                        setting : 'wordpress_gdpr_privacy_policy_accepted',
475                        checked : checkboxChecked,
476                    }
477                });
478                return true;
479            });
480        },
481        privacyPolicyTermsAcceptance : function() {
482            var that = this;
483
484            if($('#accept-privacy-policy-checkbox').length < 1 && $('#accept-terms-conditions-checkbox').length < 1) {
485                return false;
486            }
487
488            $('#accept-privacy-policy-checkbox').on('click', function(e) {
489                var name = $(this).prop('name');
490                var checked = $(this).prop('checked');
491
492                if(!checked) {
493                    alert(that.settings.acceptanceText);
494                    return false;
495                }
496
497                $.ajax({
498                    type : 'post',
499                    url : that.settings.ajaxURL,
500                    dataType : 'json',
501                    data : {
502                        action : 'wordpress_gdpr_update_privacy_policy_terms',
503                        setting : name,
504                        checked : checked,
505                    },
506                });
507            });
508
509            $('#accept-terms-conditions-checkbox').on('click', function(e) {
510                var name = $(this).prop('name');
511                var checked = $(this).prop('checked');
512
513                if(!checked) {
514                    alert(that.settings.termsAcceptanceText);
515                    return false;
516                }
517
518                $.ajax({
519                    type : 'post',
520                    url : that.settings.ajaxURL,
521                    dataType : 'json',
522                    data : {
523                        action : 'wordpress_gdpr_update_privacy_policy_terms',
524                        setting : name,
525                        checked : checked,
526                    },
527                });
528            });
529        },
530        //////////////////////
531        ///Helper Functions///
532        //////////////////////
533        deleteAllCookies : function() {
534            var cookies = document.cookie.split(";");
535            console.log(cookies);
536            for (var i = 0; i < cookies.length; i++) {
537                var cookie = cookies[i];
538                var eqPos = cookie.indexOf("=");
539                var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
540                document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
541            }
542
543        },
544        isEmpty: function(obj) {
545
546            if (obj == null)        return true;
547            if (obj.length > 0)     return false;
548            if (obj.length === 0)   return true;
549
550            for (var key in obj) {
551                if (hasOwnProperty.call(obj, key)) return false;
552            }
553
554            return true;
555        },
556        sprintf: function parse(str) {
557            var args = [].slice.call(arguments, 1),
558                i = 0;
559
560            return str.replace(/%s/g, function() {
561                return args[i++];
562
563            });
564        },
565        getCookie: function(cname) {
566            var name = cname + "=";
567            var ca = document.cookie.split(';');
568            for(var i=0; i<ca.length; i++) {
569                var c = ca[i];
570                while (c.charAt(0)==' ') c = c.substring(1);
571                if (c.indexOf(name) === 0) return c.substring(name.length, c.length);
572            }
573            return "";
574        },
575        createCookie: function(name, value, days) {
576            var expires = "";
577
578            if (days) {
579                var date = new Date();
580                date.setTime(date.getTime() + (days*24*60*60*1000));
581                var expires = "; expires="+date.toGMTString();
582            }
583
584            document.cookie = name + "=" + value+expires + "; path=/";
585        },
586        deleteCookie: function(name) {
587            this.createCookie(name, '', -10);
588        },
589        getParameterByName: function(name, url) {
590            if (!url) url = window.location.href;
591            name = name.replace(/[\[\]]/g, "\\$&");
592            var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)", "i"),
593                results = regex.exec(url);
594            if (!results) return null;
595            if (!results[2]) return '';
596            return decodeURIComponent(results[2].replace(/\+/g, " "));
597        },
598        isInArray : function (value, array) {
599            return array.indexOf(value) > -1;
600        }
601    } );
602
603    // Constructor wrapper
604    $.fn[ pluginName ] = function( options ) {
605        return this.each( function() {
606            if ( !$.data( this, "plugin_" + pluginName ) ) {
607                $.data( this, "plugin_" +
608                    pluginName, new Plugin( this, options ) );
609            }
610        } );
611    };
612
613    $(document).ready(function() {
614
615        $( "body" ).gdpr(
616            gdpr_options
617        );
618
619    } );
620
621})( 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.