PageSourceSearch

https://salapolivalenta.ro/wp-content/plugins/wordpress-gdpr/public/js/wordpress-gdpr-public.js?ver=1.8.10

js salapolivalenta.ro collected 2026-10-02 12:26:53 UTC 25,244 bytes, 620 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('<i class="fa fa-spinner fa-spin"></i>');
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                var $this = $(this);
202                var text = $this.text();
203                $this.html('<i class="fa fa-spinner fa-spin"></i>');
204
205                $.ajax({
206                    type : 'post',
207                    url : that.settings.ajaxURL,
208                    dataType : 'json',
209                    data : {
210                        action : 'wordpress_gdpr_allow_cookies'
211                    },
212                    success : function( response ) {
213                        if(that.elements.popUpBackdrop.length > 0) {
214                            that.elements.popUpBackdrop.fadeOut();
215                        }
216                        $('.wordpress-gdpr-privacy-settings-popup, .wordpress-gdpr-privacy-settings-popup-backdrop').fadeOut();
217                        that.elements.popUp.fadeOut();
218                        $.each($('.gdpr-service-switch:not(:disabled)'), function(i, index) {
219                            $(this).prop('checked', true);
220                        });
221                        
222                        that.checkPrivacySettings();
223                        $this.text(text);
224                    },
225                    error: function (xhr, ajaxOptions, thrownError) {
226                        console.log(xhr);
227                        console.log(ajaxOptions);
228                        console.log(thrownError);
229                    }
230                 });
231            });
232        },
233        popUpPrivacySettingsOpen : function () {
234
235            var that = this;
236
237            $('.wordpress-gdpr-open-privacy-settings-modal').on('click', function(e) {
238                e.preventDefault();
239
240                if(($('.wordpress-gdpr-privacy-settings-popup-services-container').length < 1)) {
241                    alert('No GDPR Service Categories / Services created yet. Remove the trigger or create services and attach them to service categories first.');
242                    return false;
243                }
244
245                if($('.wordpress-gdpr-popup').length > 0) {
246                    $('.wordpress-gdpr-popup').hide(0, function() {
247                        $('.wordpress-gdpr-privacy-settings-popup, .wordpress-gdpr-privacy-settings-popup-backdrop').fadeIn();
248                    });
249                } else {
250                    $('.wordpress-gdpr-privacy-settings-popup, .wordpress-gdpr-privacy-settings-popup-backdrop').fadeIn();
251                }
252            });
253        },
254        popUpPrivacySettingsClose : function () {
255            var that = this;
256            
257            $(that.elements.privacySettingsPopupCloseLink).on('click', function(e) {
258                e.preventDefault();
259                if(that.elements.privacySettingsPopupBackdrop.length > 0) {
260                    that.elements.privacySettingsPopupBackdrop.fadeOut();
261                }
262                that.elements.privacySettingsPopup.fadeOut();
263            });
264        },
265        popUpPrivacySettings : function() {
266
267            $('.wordpress-gdpr-popup-privacy-settings-open-service-category').on('click', function(e) {
268                e.preventDefault();
269
270                var id = $(this).data('id');
271                $('.wordpress-gdpr-popup-privacy-settings-services-content:not(#wordpress-gdpr-popup-privacy-settings-services-content-' + id + ')').hide(0, function() {
272                    $('#wordpress-gdpr-popup-privacy-settings-services-content-' + id).show();
273                });
274            });
275
276            $('.wordpress-gdpr-popup-privacy-settings-services-content-title').on('click', function(e) {
277                e.preventDefault();
278
279                var $this = $(this);
280                var id= $(this).data('id');
281                var fa = $this.find('.fa');
282
283                var description = $('#wordpress-gdpr-popup-privacy-settings-services-content-description-' + id);
284                if (description.css('display') == 'none') {
285                    description.slideDown();
286                    fa.removeClass('fa-caret-right').addClass('fa-caret-down');
287                } else {
288                    description.slideUp();
289                    fa.removeClass('fa-caret-down').addClass('fa-caret-right');
290                }
291            });
292        },
293        checkPrivacySettings : function() {
294
295            var that = this;
296            var settings = {};
297            var switches = $('.gdpr-service-switch');
298
299            $.each(switches, function() {
300                var serviceID = $(this).data('id');
301                settings[serviceID] = serviceID;
302            });
303
304            $.ajax({
305                type : 'post',
306                url : that.settings.ajaxURL,
307                dataType : 'json',
308                data : {
309                    action : 'check_privacy_settings',
310                    settings : settings
311                },
312                success : function( response ) {
313
314                    $.each(response, function(i, index) {
315
316                        if(index.head !== "" && index.allowed && !that.privacySettingsLoaded[i]) {
317                            $("head").append(index.head);
318                        }
319                        if(index.body !== "" && index.allowed && that.privacySettingsLoaded[i]) {
320                            $(index.body).prependTo($('body'));
321                        }
322
323                        if(index.adsense == "1" && !index.allowed && that.privacySettingsLoaded[i]) {
324                            var adsExists = $(".adsbygoogle");
325
326                            if(adsExists.length > 0 && that.getCookie('wordpress_gdpr_adsense_allowed') !== "true") {
327                                adsExists.remove();
328                            }
329                        }
330
331                        var checkbox_exists = $('input[name="' + i + '"]') ;
332                        if(checkbox_exists.length > 0) {
333                            if(index.allowed) {
334                                checkbox_exists.prop('checked', true);
335                                that.privacySettingsLoaded[i] = true;
336                            } else {
337                                checkbox_exists.prop('checked', false);
338                                that.privacySettingsLoaded[i] = false;
339                            }
340                        }
341                        
342                        if(checkbox_exists.length > 0 && !that.privacySettingsCheckPerformed) {
343
344                            checkbox_exists.on('change', function(e) {
345
346                                var checked = $(this).prop('checked');
347                                var name = $(this).prop('name');
348
349                                $('.wordpress-gdpr-privacy-settings-popup-message').fadeIn();
350
351                                $.ajax({
352                                    type : 'post',
353                                    url : that.settings.ajaxURL,
354                                    dataType : 'json',
355                                    data : {
356                                        action : 'update_privacy_setting',
357                                        setting : name,
358                                        checked : checked,
359                                    },
360                                    success : function( response ) {
361
362                                        setTimeout(function(){ $('.wordpress-gdpr-privacy-settings-popup-message').fadeOut(); }, 1500);                                        
363
364                                        var index = response[name];
365
366                                        if(index.head !== "" && index.allowed && that.privacySettingsLoaded[name]) {
367                                            $("head").append(index.head);
368                                        }
369                                        if(index.body !== "" && index.allowed && that.privacySettingsLoaded[name]) {
370                                            $(index.body).prependTo($('body'));
371                                        }
372
373                                        if(index.adsense == "1" && !index.allowed && that.privacySettingsLoaded[name]) {
374                                            var adsExists = $(".adsbygoogle");
375
376                                            if(adsExists.length >
376 0 && that.getCookie('wordpress_gdpr_adsense_allowed') !== "true") {
377                                                adsExists.remove();
378                                            }
379                                        }
380
381                                        
382                                        var checkbox_exists = $('input[name="' + name + '"]') ;
383                                        if(checkbox_exists.length > 0) {
384                                            if(index.allowed) {
385                                                checkbox_exists.prop('checked', true);
386                                                that.privacySettingsLoaded[name] = true;
387                                            } else {
388                                                checkbox_exists.prop('checked', false);
389                                            }
390                                        }
391                                    }
392                                });
393                            });
394                        }
395                    });
396                    that.privacySettingsCheckPerformed = true;
397                },
398                error: function (xhr, ajaxOptions, thrownError) {
399                    console.log(xhr);
400                    console.log(ajaxOptions);
401                    console.log(thrownError);
402                }
403             });
404        },
405        get_current_page_id : function() {
406            var page_body = $('body.page');
407
408            var id = 0;
409
410            if(page_body) {
411                var page_body_class = page_body.attr('class')
412
413                if(page_body_class || page_body_class != null) {
414                    if(page_body_class.length > 1) {
415                        var page_body_class_list = page_body_class.split(/\s+/);
416
417                        $.each(page_body_class_list, function(index, item) {
418                            if (item.indexOf('page-id') >= 0) {
419                                var item_arr = item.split('-');
420                                id =  item_arr[item_arr.length -1];
421                                return false;
422                            }
423                        });
424                    }
425                }
426            }
427            return id;
428        },
429        getUsersCountry : function(callback) {
430            var that = this;
431
432            $.ajax({
433                url: "https://extreme-ip-lookup.com/json/",
434                type: 'get',
435                dataType: 'json',
436                success : function( response ) {
437                    callback(response.countryCode);
438                },
439                error: function(jqXHR, textStatus, errorThrown) {
440                    console.log(jqXHR);
441                    console.log(textStatus);
442                    console.log(errorThrown);
443                }
444            });
445        },
446        commentFormprivacyPolicyTermsAcceptance : function() {
447            var that = this;
448
449            var submit = $('#commentform input[type="submit"]');
450            if(submit.length < 1) {
451                return false;
452            }
453
454            var checkbox = $('#commentform #privacy_policy');
455            if(checkbox.length < 1) {
456                return false;
457            }
458
459            submit.on('click', function(e) {
460                var checkboxChecked = checkbox.is(':checked');
461                if(!checkboxChecked) {
462                    e.preventDefault();
463                    alert(that.settings.acceptanceText);
464                    return false;
465                }
466
467                $.ajax({
468                    type : 'post',
469                    url : that.settings.ajaxURL,
470                    dataType : 'json',
471                    data : {
472                        action : 'wordpress_gdpr_update_privacy_policy_terms',
473                        setting : 'wordpress_gdpr_privacy_policy_accepted',
474                        checked : checkboxChecked,
475                    }
476                });
477                return true;                
478            });
479        },
480        privacyPolicyTermsAcceptance : function() {
481            var that = this;
482
483            if($('#accept-privacy-policy-checkbox').length < 1 && $('#accept-terms-conditions-checkbox').length < 1) {
484                return false;
485            }
486
487            $('#accept-privacy-policy-checkbox').on('click', function(e) {
488                var name = $(this).prop('name');
489                var checked = $(this).prop('checked');
490
491                if(!checked) {
492                    alert(that.settings.acceptanceText);
493                    return false;
494                }
495                
496                $.ajax({
497                    type : 'post',
498                    url : that.settings.ajaxURL,
499                    dataType : 'json',
500                    data : {
501                        action : 'wordpress_gdpr_update_privacy_policy_terms',
502                        setting : name,
503                        checked : checked,
504                    },
505                });
506            });
507
508            $('#accept-terms-conditions-checkbox').on('click', function(e) {
509                var name = $(this).prop('name');
510                var checked = $(this).prop('checked');
511
512                if(!checked) {
513                    alert(that.settings.termsAcceptanceText);
514                    return false;
515                }
516                
517                $.ajax({
518                    type : 'post',
519                    url : that.settings.ajaxURL,
520                    dataType : 'json',
521                    data : {
522                        action : 'wordpress_gdpr_update_privacy_policy_terms',
523                        setting : name,
524                        checked : checked,
525                    },
526                });
527            });
528        },
529        //////////////////////
530        ///Helper Functions///
531        //////////////////////
532        deleteAllCookies : function() {
533            var cookies = document.cookie.split(";");
534            console.log(cookies);
535            for (var i = 0; i < cookies.length; i++) {
536                var cookie = cookies[i];
537                var eqPos = cookie.indexOf("=");
538                var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
539                document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
540            }
541
542        },
543        isEmpty: function(obj) {
544
545            if (obj == null)        return true;
546            if (obj.length > 0)     return false;
547            if (obj.length === 0)   return true;
548
549            for (var key in obj) {
550                if (hasOwnProperty.call(obj, key)) return false;
551            }
552
553            return true;
554        },
555        sprintf: function parse(str) {
556            var args = [].slice.call(arguments, 1),
557                i = 0;
558
559            return str.replace(/%s/g, function() {
560                return args[i++];
561
562            });
563        },
564        getCookie: function(cname) {
565            var name = cname + "=";
566            var ca = document.cookie.split(';');
567            for(var i=0; i<ca.length; i++) {
568                var c = ca[i];
569                while (c.charAt(0)==' ') c = c.substring(1);
570                if (c.indexOf(name) === 0) return c.substring(name.length, c.length);
571            }
572            return "";
573        },
574        createCookie: function(name, value, days) {
575            var expires = "";
576
577            if (days) {
578                var date = new Date();
579                date.setTime(date.getTime() + (days*24*60*60*1000));
580                var expires = "; expires="+date.toGMTString();
581            }
582
583            document.cookie = name + "=" + value+expires + "; path=/";
584        },
585        deleteCookie: function(name) {
586            this.createCookie(name, '', -10);
587        },
588        getParameterByName: function(name, url) {
589            if (!url) url = window.location.href;
590            name = name.replace(/[\[\]]/g, "\\$&");
591            var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)", "i"),
592                results = regex.exec(url);
593            if (!results) return null;
594            if (!results[2]) return '';
595            return decodeURIComponent(results[2].replace(/\+/g, " "));
596        },
597        isInArray : function (value, array) {
598            return array.indexOf(value) > -1;
599        }
600    } );
601
602    // Constructor wrapper
603    $.fn[ pluginName ] = function( options ) {
604        return this.each( function() {
605            if ( !$.data( this, "plugin_" + pluginName ) ) {
606                $.data( this, "plugin_" +
607                    pluginName, new Plugin( this, options ) );
608            }
609        } );
610    };
611
612    $(document).ready(function() {
613
614        $( "body" ).gdpr( 
615            gdpr_options
616        );
617
618    } );
619
620})( 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.