PageSourceSearch

https://www.fscdena.org/wp-content/plugins/easy-facebook-likebox/f…/frontend/assets/js/public.js?ver=6.7.2

js fscdena.org collected 2026-10-02 07:22:56 UTC 9,566 bytes, 295 lines download raw bytes

1jQuery(document).ready(function($) {
2
3  jQuery('.efbl-popup-carousel-container img').removeAttr('srcset');
4
5  /*
6  *	Check if the like box has loaded. If yes then remove loader and add animation class!
7  */
8
9  if ($('.efbl_feed_wraper .efbl_custom_likebox')[0] ||
10      $('.widget_easy_facebook_page_plugin .efbl-like-box')[0]) {
11
12    if (typeof FB === 'undefined' || FB === null) {
13
14      setTimeout(function() { $('.efbl-loader').remove(); }, 3000);
15
16    }
17    else {
18
19      FB.Event.subscribe('xfbml.render', function(response) {
20
21        var animclasses = $('.efbl-like-box .fb-page').data('animclass');
22
23        $('.efbl-loader').remove();
24
25        $('.efbl-like-box iframe').addClass('animated ' + animclasses);
26
27      });
28
29    }
30  }
31
32  // Sanitize content to prevent XSS attacks
33  function sanitizeContent(content) {
34    if (!content) return '';
35    
36    // Create a temporary div to safely parse and sanitize HTML
37    var tempDiv = document.createElement('div');
38    tempDiv.innerHTML = content;
39    
40    // Remove script tags and event handlers
41    var scripts = tempDiv.querySelectorAll('script');
42    for (var i = 0; i < scripts.length; i++) {
43      scripts[i].parentNode.removeChild(scripts[i]);
44    }
45    
46    // Remove event handlers from all elements
47    var allElements = tempDiv.querySelectorAll('*');
48    for (var i = 0; i < allElements.length; i++) {
49      var element = allElements[i];
50      var attributes = element.attributes;
51      for (var j = attributes.length - 1; j >= 0; j--) {
52        var attr = attributes[j];
53        if (attr.name.toLowerCase().startsWith('on') || 
54            attr.name.toLowerCase() === 'javascript:' ||
55            attr.value.toLowerCase().includes('javascript:')) {
56          element.removeAttribute(attr.name);
57        }
58      }
59    }
60    
61    return tempDiv.innerHTML;
62  }
63
64  // Magic function that will prepare and render markup.
65  function efbl_render_poup_markup(object) {
66
67    var $story_link = object.data('storylink'),
68        $story_link_text = object.data('linktext'),
69        $caption = object.data('caption'),
70        $image_url = object.data('imagelink'),
71        $iframe_vid_url = object.data('videolink'),
72        $video_url = object.data('video'),
73        $itemnumber = object.data('itemnumber'),
74        $windowWidth = window.innerWidth,
75        $windowHeight = window.innerHeight - 200;
76
77    // Detect GDPR mode and consent for this feed container.
78    var $feedContainer = object.closest('.efbl_feed_wraper');
79    var flagsAttr = $feedContainer.length ? ($feedContainer.attr('data-esf-flags') || '') : '';
80    var flags = flagsAttr ? flagsAttr.split(',') : [];
81    var hasGdpr = flags.indexOf('gdpr') > -1;
82    var mode = 'none';
83
84    if (flags.indexOf('gdpr_yes') > -1) {
85      mode = 'yes';
86    } else if (flags.indexOf('gdpr_auto') > -1) {
87      mode = 'auto';
88    }
89
90    var consentGiven = false;
91    if (window.ESFGDPR && typeof window.ESFGDPR.checkConsent === 'function' && $feedContainer.length) {
92      consentGiven = window.ESFGDPR.checkConsent($feedContainer);
93    }
94
95    // Media is allowed only when:
96    // - GDPR is not enabled, OR
97    // - mode is "auto" and consent has been given.
98    var mediaAllowed = true;
99    if (hasGdpr) {
100      if (mode === 'yes') {
101        mediaAllowed = false;
102      } else if (mode === 'auto' && !consentGiven) {
103        mediaAllowed = false;
104      }
105    }
106
107    $('.white-popup .efbl_popup_left_container').css({
108      'width': 'auto',
109      'height': 'auto',
110    });
111
112    $('.efbl_popup_image').css('height', 'auto');
113
114    // Helper to get a placeholder image URL from the clicked element, if available.
115    function getPlaceholderFromElement(el) {
116      var bg = el.css('background-image') || '';
117      if (!bg || bg === 'none') {
118        return '';
119      }
120      // Expect format: url("...") or url('...') or url(...)
121      bg = bg.replace(/^url\((['"]?)/, '').replace(/(['"]?)\)$/, '');
122      return bg;
123    }
124
125    // IMAGES
126    if ($image_url) {
127      if (mediaAllowed) {
128        $('#efblcf_holder .efbl_popup_image').attr('src', $image_url);
129        $('#efblcf_holder .efbl_popup_image').css('display', 'block');
130      } else {
131        var placeholderImg = getPlaceholderFromElement(object);
132        if (placeholderImg) {
133          $('#efblcf_holder .efbl_popup_image').attr('src', placeholderImg);
134          $('#efblcf_holder .efbl_popup_image').css('display', 'block');
135        } else {
136          // No safe placeholder, hide image completely.
137          $('#efblcf_holder .efbl_popup_image').attr('src', '');
138          $('#efblcf_holder .efbl_popup_image').css('display', 'none');
139        }
140      }
141    }
142
143    // IFRAME VIDEO
144    if ($iframe_vid_url) {
145      if (mediaAllowed) {
146        $('#efblcf_holder .efbl_popup_if_video').attr('src', $iframe_vid_url);
147        $('#efblcf_holder .efbl_popup_if_video').css({
148          'display': 'block',
149          'width': '720px',
150          'height': '400px',
151        });
152      } else {
153        $('#efblcf_holder .efbl_popup_if_video').attr('src', '');
154        $('#efblcf_holder .efbl_popup_if_video').css('display', 'none');
155      }
156
157    }
158
159    // HTML5 VIDEO
160    if ($video_url) {
161      if (mediaAllowed) {
162        $('#efblcf_holder .efbl_popup_video').attr('src', $video_url);
163        $('#efblcf_holder .efbl_popup_video').css('display', 'block');
164        setTimeout(function() {
165          $('#efblcf_holder .efbl_popup_video')[0].play();
166        }, 500);
167      } else {
168        $('#efblcf_holder .efbl_popup_video').attr('src', '');
169        $('#efblcf_holder .efbl_popup_video').css('display', 'none');
170      }
171
172    }
173
174    //$('.efbl-popup-next').attr('data-itemnumber', $itemnumber+1);
175    //$('.efbl-popup-prev').attr('data-itemnumber', $itemnumber-1);
176
177    $('.efbl_feed_wraper #item_number').val($itemnumber);
178
179    if ($caption) {
180      // Sanitize caption and link text to prevent XSS
181      var sanitizedCaption = sanitizeContent($caption);
182      var sanitizedLinkText = sanitizeContent($story_link_text);
183      
184      $('#efblcf_holder .efbl_popupp_footer').
185          html(
186              '<p>' + sanitizedCaption + ' <br> <a class="efbl_popup_readmore" href="' +
187              $story_link + '" target="_blank">
187' + sanitizedLinkText +
188              '</a></p>');
189      $('#efblcf_holder .efbl_popupp_footer').css('display', 'block');
190    }
191
192  }
193
194  function reset_popup_holder() {
195    //Clear the container for new instance
196    $('#efblcf_holder .efbl_popup_image').attr('src', '');
197    $('#efblcf_holder .efbl_popup_image').css('display', 'none');
198
199    $('#efblcf_holder .efbl_popup_if_video').attr('src', '');
200    $('#efblcf_holder .efbl_popup_if_video').css('display', 'none');
201
202    $('#efblcf_holder .efbl_popup_video').attr('src', '');
203    $('#efblcf_holder .efbl_popup_video').css('display', 'none');
204
205    $('#efblcf_holder .efbl_popupp_footer').html('');
206    $('#efblcf_holder .efbl_popupp_footer').css('display', 'none');
207  }
208
209  $('.efbl_feed_popup').esfFreePopup({
210    type: 'ajax',
211    tLoading: 'Loading...',
212    preloader: false,
213    mainClass: 'esfp-fade',
214
215    callbacks: {
216
217      ajaxContentAdded: function() {
218        // Ajax content is loaded and appended to DOM
219
220        efbl_render_poup_markup(this.st.el);
221
222        // GDPR: if consent is already given and popup content contains
223        // placeholder images (esf-no-consent), swap them to real URLs.
224        if (window.ESFGDPR && typeof window.ESFGDPR.checkConsent === 'function') {
225          try {
226            // Use the first feed wrapper on the page to evaluate consent state.
227            var $feedContainer = jQuery('.efbl_feed_wraper').first();
228            if ($feedContainer.length && window.ESFGDPR.checkConsent($feedContainer)) {
229              // Target the most recently added popup.
230              var $popup = jQuery('.efbl-popup').last();
231              if ($popup.length) {
232                $popup.find('.esf-no-consent').each(function() {
233                  var $element = jQuery(this);
234                  var realImageUrl = $element.attr('data-image-url');
235
236                  if (realImageUrl) {
237                    // Update <img> tag if present.
238                    var $img = $element.is('img') ? $element : $element.find('img');
239                    if ($img.length) {
240                      $img.attr('src', realImageUrl);
241                    }
242
243                    // Also update background-image if used.
244                    $element.css('background-image', 'url(' + realImageUrl + ')');
245
246                    $element.removeClass('esf-no-consent');
247                    $element.removeAttr('data-image-url');
248                  }
249                });
250              }
251            }
252          } catch (e) {
253            // Fail silently; do not break popup if something goes wrong.
254          }
255        }
256      },
257
258      beforeOpen: function() {
259        // console.log(this.st.el);
260
261        // efbl_render_poup_markup(this.st.el);
262
263      },
264
265      beforeClose: function() {
266
267        reset_popup_holder();
268
269      },
270    },
271
272  });
273
274  $('.efbl_share_links').click(function() {
275    $(this).next('.efbl_links_container').slideToggle('slow');
276  });
277
278  $('.efbl_info').click(function() {
279    $(this).siblings('.efbl_comments_wraper').slideToggle('slow');
280  });
281
282  jQuery(document).
283      on('click', 'div[data-class=\'efbl_redirect_home\']', function(event) {
284
285        window.open(
286            'https://easysocialfeed.com/?utm_campaign=powered-by&utm_medium=link&utm_source=plugin',
287            '_blank');
288      });
289
290  $('.esf-share').click(function(e) {
291    e.preventDefault();
292    $(this).next().slideToggle();
293  });
294
295});

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.