PageSourceSearch

https://easydna.es/wp-content/plugins/wordpress-gdpr/public/js/wordpress-gdpr-public.js?ver=1.3.1

js easydna.es collected 2026-10-07 23:06:14 UTC 16,105 bytes, 404 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
28            this.elements = {};
29            this.elements.popup = $('.wordpress-gdpr-popup-container');
30            this.elements.popUpPrivacySettings = $('.wordpress-gdpr-popup-privacy-settings-modal');
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            if(this.settings.geoIP == "1") {
37                this.getUsersCountry(function(country) {
38                    
39                    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', '
39SE', 'GB'];
40                    var isEU = that.isInArray(country, euCountries);
41                    if(isEU) {
42                        that.popUp();
43                    } else {
44                        that.elements.popupAgreeLink.trigger('click');
45                    }
46                });
47                
48            } else {
49                this.popUp();
50            }
51            this.popUpAgree();
52            this.popUpClose();
53            this.popUpDecline();
54            this.popUpPrivacySettings();
55        },
56        popUp : function() {
57
58            var that = this;
59            var cookiesAllowed = false;
60
61            $.ajax({
62                type : 'post',
63                url : that.settings.ajaxURL,
64                dataType : 'json',
65                data : {
66                    action : 'check_privacy_setting',
67                    setting : 'wordpress_gdpr_cookies_allowed',
68                },
69                success : function( response ) {                    
70                    if((!response.allowed && !response.declined) || that.getParameterByName('gdpr') === "debug") {
71                        if(that.elements.popupBackdrop.length > 0) {
72                            that.elements.popupBackdrop.show();
73                        }
74                        that.elements.popup.show();
75                    } else {
76                        if(response.firstTime) {
77                            if(that.elements.popupBackdrop.length > 0) {
78                                that.elements.popupBackdrop.show();
79                            }
80                            that.elements.popup.show();
81                        } else {
82                            if(that.elements.popupBackdrop.length > 0) {
83                                that.elements.popupBackdrop.hide();
84                            }
85                            that.elements.popup.hide();
86                        }
87                    }
88                    that.checkPrivacySettings();
89                },
90                error: function (xhr, ajaxOptions, thrownError) {
91                    console.log(xhr);
92                    console.log(ajaxOptions);
93                    console.log(thrownError);
94                }
95             });
96        },
97        popUpClose : function() {
98
99            var that = this;
100            
101            $(that.elements.popupCloseLink).on('click', function(e) {
102                if(that.elements.popupBackdrop.length > 0) {
103                    that.elements.popupBackdrop.fadeOut();
104                }
105                that.elements.popup.fadeOut();
106            });
107        },
108        popUpDecline : function() {
109
110            var that = this;
111            
112            that.elements.popupDeclineLink.on('click', function(e) {
113                e.preventDefault();
114                $.ajax({
115                    type : 'post',
116                    url : that.settings.ajaxURL,
117                    dataType : 'json',
118                    data : {
119                        action : 'wordpress_gdpr_decline_cookies'
120                    },
121                    success : function( response ) {  
122                        if(that.elements.popupBackdrop.length > 0) {
123                            that.elements.popupBackdrop.fadeOut();
124                        }
125                        that.elements.popup.fadeOut();
126                        $.each(that.settings.checks, function(i, index) {
127                            var checkbox_exists = $('input[name="' + index + '"]') ;
128                            if(checkbox_exists.length > 0) {
129                                checkbox_exists.prop('checked', false);
130                            }
131                        });
132                    },
133                    error: function (xhr, ajaxOptions, thrownError) {
134                        console.log(xhr);
135                        console.log(ajaxOptions);
136                        console.log(thrownError);
137                    }
138                 });
139            });
140        },
141        popUpAgree : function() {
142
143            var that = this;
144
145            that.elements.popupAgreeLink.on('click', function(e) {
146                e.preventDefault();
147                $.ajax({
148                    type : 'post',
149                    url : that.settings.ajaxURL,
150                    dataType : 'json',
151                    data : {
152                        action : 'wordpress_gdpr_allow_cookies'
153                    },
154                    success : function( response ) {
155                        if(that.elements.popupBackdrop.length > 0) {
156                            that.elements.popupBackdrop.fadeOut();
157                        }
158                        that.elements.popup.fadeOut();
159                        $.each(that.settings.checks, function(i, index) {
160                            var checkbox_exists = $('input[name="' + index + '"]') ;
161                            if(checkbox_exists.length > 0) {
162                                checkbox_exists.prop('checked', true);
163                            }
164                        });
165                        that.checkPrivacySettings();
166                    },
167                    error: function (xhr, ajaxOptions, thrownError) {
168                        console.log(xhr);
169                        console.log(ajaxOptions);
170                        console.log(thrownError);
171                    }
172                 });
173            });
174        },
175        popUpPrivacySettings : function () {
176
177            var that = this;
178
179            if(that.elements.popUpPrivacySettings.length < 1) {
180                return;
181            }
182            $('.wordpress-gdpr-popup-privacy-settings-title').on('click', function(e) {
183                e.preventDefault();
184
185                var $this = $(this);
186                var privacySettingsModal = $(that.elements.popUpPrivacySettings);
187                var privacySettingsTable = $('.wordpress-gdpr-popup-privacy-settings');
188
189                if(privacySettingsModal.hasClass('wordpress-gdpr-popup-privacy-settings-modal-open')) {
190                
191                    if(privacySettingsModal.hasClass('wordpress-gdpr-popup-privacy-settings-modal-bottom')) {
192                        privacySettingsModal.removeClass('wordpress-gdpr-popup-privacy-settings-modal-open');
193                    } else {
194                        var targetHeight = 40 * -1;
195                        privacySettingsModal.animate({top: targetHeight}, 800, function() {
196                            privacySettingsModal.removeClass('wordpress-gdpr-popup-privacy-settings-modal-open')
197                        });
198                    }
199                } else {
200
201                    if(privacySettingsModal.hasClass('wordpress-gdpr-popup-privacy-settings-modal-bottom')) {
202                        privacySettingsModal.addClass('wordpress-gdpr-popup-privacy-settings-modal-open')
203                    } else {
204                        privacySettingsModal.addClass('wordpress-gdpr-popup-privacy-settings-modal-open')
205                        var targetHeight = (privacySettingsTable.outerHeight() + 40) * -1;
206                        privacySettingsModal.animate({top: targetHeight}, 800);
207                    }
208                }
209
210                
211            });
212        },
213        checkPrivacySettings : function() {
214
215            var that = this;
216            var settings = {};
217            
218            $.ajax({
219                type : 'post',
220                url : that.settings.ajaxURL,
221                dataType : 'json',
222                data : {
223                    action : 'check_privacy_settings',
224                    settings : that.settings.checks
225                },
226                success : function( response ) {
227
228                    $.each(response, function(i, index) {
229
230                        var checkbox_exists = $('input[name="' + i + '"]') ;
231
232                        if(checkbox_exists.length > 0) {
233                            if(index.allowed) {
234                                checkbox_exists.prop('checked', true);
235                            } else {
236                                checkbox_exists.prop('checked', false);
237                            }
238                        }
239
240                        if(index.head !== "" && index.allowed) {
241                            $("head").append(index.head);
242                        }
243                        if(index.body !== "" && index.allowed) {
244                            $(index.body).prependTo($('body'));
245                        }
246
247                        if(i == "wordpress_gdpr_adsense_allowed" && !index.allowed) {
248                            var adsExists = $(".adsbygoogle");
249
250                            if(adsExists.length > 0 && that.getCookie('wordpress_gdpr_adsense_allowed') !== "true") {
251                                adsExists.remove();
252                            }
253                        }
254
255                        if(checkbox_exists.length > 0) {
256                            checkbox_exists.on('change', function(e) {
257                                var checked = $(this).prop('checked');
258                                var name = $(this).prop('name');
259                                $.ajax({
260                                    type : 'post',
261                                    url : that.settings.ajaxURL,
262                                    dataType : 'json',
263                                    data : {
264                                        action : 'update_privacy_setting',
265                                        setting : name,
266                                        checked : checked,
267                                    },
268                                    success : function( response ) {
269                                        if(name == "wordpress_gdpr_cookies_allowed" && !checked) {
270                                            $.each(that.settings.checks, function(i, index) {
271                                                var checkbox_exists = $('input[name="' + index + '"]') ;
272                                                if(checkbox_exists.length > 0) {
273                                                    checkbox_exists.prop('checked', checked);
274                                                }
275                                            });
276                                        } else {
277                                            var checkbox_exists = $('input[name="' + name + '"]') ;
278                                            if(checkbox_exists.length > 0) {
279                                                checkbox_exists.prop('checked', checked);
280                                            }
281                                        }
282
283                                    }
284                                });
285                            });
286                        }
287                    });
288                },
289                error: function (xhr, ajaxOptions, thrownError) {
290                    console.log(xhr);
291                    console.log(ajaxOptions);
292                    console.log(thrownError);
293                }
294             });
295        },
296        getUsersCountry : function(callback) {
297            var that = this;
298
299            $.ajax({
300                url: "https://geoip.nekudo.com/api/",
301                type: 'get',
302                dataType: 'json',
303                success : function( response ) {
304                    callback(response.country.code);
305                },
306                error: function(jqXHR, textStatus, errorThrown) {
307                    console.log(jqXHR);
308                    console.log(textStatus);
309                    console.log(errorThrown);
310                }
311            });
312        },
313        //////////////////////
314        ///Helper Functions///
315        //////////////////////
316        deleteAllCookies : function() {
317            var cookies = document.cookie.split(";");
318            console.log(cookies);
319            for (var i = 0; i < cookies.length; i++) {
320                var cookie = cookies[i];
321                var eqPos = cookie.indexOf("=");
322                var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
323                document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
324            }
325
326        },
327        isEmpty: function(obj) {
328
329            if (obj == null)        return true;
330            if (obj.length > 0)     return false;
331            if (obj.length === 0)   return true;
332
333            for (var key in obj) {
334                if (hasOwnProperty.call(obj, key)) return false;
335            }
336
337            return true;
338        },
339        sprintf: function parse(str) {
340            var args = [].slice.call(arguments, 1),
341                i = 0;
342
343            return str.replace(/%s/g, function() {
344                return args[i++];
345
346            });
347        },
348        getCookie: function(cname) {
349            var name = cname + "=";
350            var ca = document.cookie.split(';');
351            for(var i=0; i<ca.length; i++) {
352                var c = ca[i];
353                while (c.charAt(0)==' ') c = c.substring(1);
354                if (c.indexOf(name) === 0) return c.substring(name.length, c.length);
355            }
356            return "";
357        },
358        createCookie: function(name, value, days) {
359            var expires = "";
360
361            if (days) {
362                var date = new Date();
363                date.setTime(date.getTime() + (days*24*60*60*1000));
364                var expires = "; expires="+date.toGMTString();
365            }
366
367            document.cookie = name + "=" + value+expires + "; path=/";
368        },
369        deleteCookie: function(name) {
370            this.createCookie(name, '', -10);
371        },
372        getParameterByName: function(name, url) {
373            if (!url) url = window.location.href;
374            name = name.replace(/[\[\]]/g, "\\$&");
375            var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)", "i"),
376                results = regex.exec(url);
377            if (!results) return null;
378            if (!results[2]) return '';
379            return decodeURIComponent(results[2].replace(/\+/g, " "));
380        },
381        isInArray : function (value, array) {
382            return array.indexOf(value) > -1;
383        }
384    } );
385
386    // Constructor wrapper
387    $.fn[ pluginName ] = function( options ) {
388        return this.each( function() {
389            if ( !$.data( this, "plugin_" + pluginName ) ) {
390                $.data( this, "plugin_" +
391                    pluginName, new Plugin( this, options ) );
392            }
393        } );
394    };
395
396    $(document).ready(function() {
397
398        $( "body" ).gdpr( 
399            gdpr_options
400        );
401
402    } );
403
404})( 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.