PageSourceSearch

https://ael.edu.pt/wp-content/plugins/embedpress/assets/js/front.js?ver=3.9.1

js ael.edu.pt collected 2026-10-02 00:13:20 UTC 20,731 bytes, 503 lines download raw bytes

1/**
2 * @package     EmbedPress
3 * @author      EmbedPress <[email protected]>
4 * @copyright   Copyright (C) 2023 EmbedPress. All rights reserved.
5 * @license     GPLv2 or later
6 * @since       1.7.0
7 */
8
9
10
11let epGlobals = {};
12
13(function ($) {
14    'use strict';
15    // function equivalent to jquery ready()
16    function ready(fn) {
17        if (document.readyState !== 'loading') {
18            fn();
19        } else {
20            document.addEventListener('DOMContentLoaded', fn);
21        }
22    }
23
24    ready(function () {
25        let option = {
26            forceObject: true,
27        };
28        let selector = document.querySelectorAll('.embedpress-embed-document-pdf');
29        if (selector.length) {
30            selector.forEach((function (value, index, thisArg) {
31                let id = value.dataset['emid'];
32                let src = value.dataset['emsrc'];
33                PDFObject.embed(src, "." + id, option);
34            }));
35        }
36        if (typeof epGlobals.youtubeChannelGallery === 'function') {
37            epGlobals.youtubeChannelGallery();
38        }
39    });
40
41    /**
42     *
43     * Make embeds responsive so they don't overflow their container.
44     */
45
46    /**
47     * Add max-width & max-height to <iframe> elements, depending on their width & height props.
48     *
49     *
50     * @return {void}
51     */
52    function embedPressResponsiveEmbeds() {
53        var proportion, parentWidth;
54
55        // Loop iframe elements.
56        document.querySelectorAll('iframe').forEach(function (iframe) {
57            // Only continue if the iframe has a width & height defined.
58            if (iframe.width && iframe.height) {
59                // Calculate the proportion/ratio based on the width & height.
60                proportion = parseFloat(iframe.width) / parseFloat(iframe.height);
61                // Get the parent element's width.
62                parentWidth = parseFloat(window.getComputedStyle(iframe.parentElement, null).width.replace('px', ''));
63                // Set the max-width & height.
64                iframe.style.maxWidth = '100%';
65                iframe.style.maxHeight = Math.round(parentWidth / proportion).toString() + 'px';
66            }
67        });
68    }
69
70    // Run on initial load.
71    embedPressResponsiveEmbeds();
72
73    // Run on resize.
74    window.onresize = embedPressResponsiveEmbeds;
75
76
77    function hasClass(ele, cls) {
78        return !!ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"));
79    }
80
81    function addClass(ele, cls) {
82        if (!hasClass(ele, cls)) ele.className += " " + cls;
83    }
84
85    function removeClass(ele, cls) {
86        if (hasClass(ele, cls)) {
87            var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
88            ele.className = ele.className.replace(reg, " ");
89        }
90    }
91    if (!Element.prototype.matches) {
92        Element.prototype.matches =
93            Element.prototype.matchesSelector ||
94            Element.prototype.webkitMatchesSelector ||
95            Element.prototype.mozMatchesSelector ||
96            Element.prototype.msMatchesSelector ||
97            Element.prototype.oMatchesSelector ||
98            function (s) {
99                var matches = (this.document || this.ownerDocument).querySelectorAll(s),
100                    i = matches.length;
101                while (--i >= 0 && matches.item(i) !== this) { }
102                return i > -1;
103            };
104    }
105    var delegate = function (el, evt, sel, handler) {
106        el.addEventListener(evt, function (event) {
107            var t = event.target;
108            while (t && t !== this) {
109                if (t.matches(sel)) {
110                    handler.call(t, event);
111                }
112                t = t.parentNode;
113            }
114        });
115    };
116
117    function sendRequest(url, postData, callback) {
118        var req = createXMLHTTPObject();
119        if (!req) return;
120        var method = postData ? "POST" : "GET";
121        req.open(method, url, true);
122        if (postData) {
123            req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
124        }
125        req.onreadystatechange = function () {
126            if (req.readyState != 4) return;
127            if (req.status != 200 && req.status != 304) {
128                return;
129            }
130            callback(req);
131        };
132        if (req.readyState == 4) return;
133        req.send(postData);
134    }
135
136    var XMLHttpFactories = [
137        function () {
138            return new XMLHttpRequest();
139        },
140        function () {
141            return new ActiveXObject("Msxml3.XMLHTTP");
142        },
143        function () {
144            return new ActiveXObject("Msxml2.XMLHTTP.6.0");
145        },
146        function () {
147            return new ActiveXObject("Msxml2.XMLHTTP.3.0");
148        },
149        function () {
150            return new ActiveXObject("Msxml2.XMLHTTP");
151        },
152        function () {
153            return new ActiveXObject("Microsoft.XMLHTTP");
154        },
155    ];
156
157    function createXMLHTTPObject() {
158        var xmlhttp = false;
159        for (var i = 0; i < XMLHttpFactories.length; i++) {
160            try {
161                xmlhttp = XMLHttpFactories[i]();
162            } catch (e) {
163                continue;
164            }
165            break;
166        }
167        return xmlhttp;
168    }
169
170    epGlobals.youtubeChannelGallery = function () {
171        var playerWraps = document.getElementsByClassName("ep-player-wrap");
172        if (playerWraps && playerWraps.length) {
173            for (var i = 0, im = playerWraps.length; im > i; i++) {
174                youtubeChannelEvents(playerWraps[i])
175            }
176        }
177    }
178
179    function youtubeChannelEvents(playerWrap) {
180
181        delegate(playerWrap, "click", ".item", function (event) {
182            var embed = "https://www.youtube.com/embed/";
183            var vid = this.getAttribute("data-vid");
184            var iframe = playerWrap.getElementsByTagName("iframe");
185            if (vid) {
186                if (iframe) {
187                    var vidSrc = iframe[0].src.replace(/(.*\/embed\/)([^\?&"'>]+)(.+)?/, `\$1${vid}\$3`);
188                    if (vidSrc.indexOf('autoplay') > 0) {
189                        vidSrc = vidSrc.replace('autoplay=0', 'autoplay=1');
190                    }
191                    else {
192                        vidSrc += '&autoplay=1';
193                    }
194                    iframe[0].src = vidSrc;
195                    playerWrap.scrollIntoView();
196                }
197            }
198        });
199
200        var currentPage = 1;
201
202        let nearestEpContentId = playerWrap.querySelector('.ep-youtube__content__block').getAttribute('data-unique-id');
203
204        delegate(playerWrap, "click", ".ep-next, .ep-prev", function (event) {
205            const totalPages = event.target.closest('.ose-youtube').getAttribute('data-total-pages');
206            const closestClass = event.target.closest('.ose-youtube').classList;
207
208            const activePage = document.querySelector(`.${closestClass[1]} .embedpress-page-active`);
209            if (activePage) {
210                document.querySelector(`.${closestClass[1]} .embedpress-page-active`).classList.remove('embedpress-page-active');
211            }
212
213
214
215            var isNext = this.classList.contains("ep-next");
216
217            if (isNext) {
218                currentPage++;
219            } else {
220                currentPage--;
221            }
222
223            var data = {
224                action: "youtube_rest_api",
225                playlistid: this.getAttribute("data-playlistid"),
226                pagetoken: this.getAttribute("data-pagetoken"),
227                pagesize: this.getAttribute("data-pagesize"),
228                currentpage: currentPage
229            };
230
231            var formBody = [];
232            for (var property in data) {
233                var encodedKey = encodeURIComponent(property);
234                var encodedValue = encodeURIComponent(data[property]);
235                formBody.push(encodedKey + "=" + encodedValue);
236            }
237            formBody = formBody.join("&");
238
239            var galleryWrapper = playerWrap.getElementsByClassName(
240                "ep-youtube__content__block"
241            );
242
243            playerWrap.setAttribute('data-current-page', currentPage);
244
245
246            let x = 1;
247
248            sendRequest("/wp-admin/admin-ajax.php", formBody, function (request) {
249                if (galleryWrapper && galleryWrapper[0] && request.responseText) {
250                    var response = JSON.parse(request.responseText);
251                    galleryWrapper[0].outerHTML = response.html;
252
253                    var currentPageNode =
254                        galleryWrapper[0].getElementsByClassName("current-page");
255                    if (currentPageNode && currentPageNode[0]) {
256                        currentPageNode[0].textContent = currentPage;
257
258                    }
259                }
260            });
261
262            const intervalID = setInterval(() => {
263                x++
264
265                if (playerWrap.querySelector('.ep-youtube__content__block')) {
266                    const newNearestEpContentId = playerWrap
267                        .querySelector('.ep-youtube__content__block')
268                        .getAttribute('data-unique-id');
269
270                    if (newNearestEpContentId !== nearestEpContentId && playerWrap.querySelector(`[data-
270page="${currentPage}"]`)) {
271                        playerWrap.querySelector(`[data-page="${currentPage}"]`).classList.add('embedpress-page-active');
272                        nearestEpContentId = newNearestEpContentId;
273                        clearInterval(intervalID);
274                    }
275                }
276
277                if (x > 100) {
278                    clearInterval(intervalID);
279                }
280            }, 100);
281
282        });
283    }
284
285    //Load more for OpenaSea collection
286    const epLoadMore = () => {
287
288        $('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').each(function () {
289            let selctorEl = `[data-nftid='${$(this).data('nftid')}']`;
290
291            let loadmorelabel = $(selctorEl).data('loadmorelabel');
292            let iconcolor = $(selctorEl + " .nft-loadmore").data('iconcolor');
293
294            let spinicon = `<svg width="18" height="18" fill="${iconcolor || '#fff'}" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><style>.spinner_GuJz{transform-origin:center;animation:spinner_STY6 1.5s linear infinite}@keyframes spinner_STY6{100%{transform:rotate(360deg)}}</style><g class="spinner_GuJz"><circle cx="3" cy="12" r="2"/><circle cx="21" cy="12" r="2"/><circle cx="12" cy="21" r="2"/><circle cx="12" cy="3" r="2"/><circle cx="5.64" cy="5.64" r="2"/><circle cx="18.36" cy="18.36" r="2"/><circle cx="5.64" cy="18.36" r="2"/><circle cx="18.36" cy="5.64" r="2"/></g></svg>`;
295
296            $(selctorEl + ` .ep_nft_item`).slice(0, $(selctorEl).data('itemparpage')).show();
297            $('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper .ep-loadmore-wrapper button').css('display', 'flex');
298
299            $(selctorEl + " .nft-loadmore").click(function (e) {
300                //change the text of the button
301                $(this).html(loadmorelabel + spinicon);
302                //disable the button
303                $(this).prop("disabled", true);
304                //wait for 1 seconds
305                setTimeout(function () {
306                    //change the text back
307                    $(selctorEl + " .nft-loadmore").text(loadmorelabel);
308                    //enable the button
309                    $(selctorEl + " .nft-loadmore").prop("disabled", false);
310                    $(selctorEl + " .ep_nft_item:hidden").slice(0, $(selctorEl).data('itemparpage')).fadeIn("slow");
311                    if ($(selctorEl + " .ep_nft_item:hidden").length == 0) {
312                        $(selctorEl + " .nft-loadmore").fadeOut("slow");
313                    }
314                }, 500);
315            });
316        });
317    };
318
319    if ($('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').length > 0) {
320        epLoadMore();
321    }
322
323    // Content protection system function 
324    const unlockSubmitHander = (perentSel, that) => {
325        var ep_client_id = jQuery(that).closest('form').find('input[name="ep_client_id"]').val();
326        var password = jQuery(`input[name="pass_${ep_client_id}"]`).val();
327        var post_id = jQuery(`input[name="post_id"]`).val();
328        const buttonText = jQuery(that).closest('.password-form-container').find('input[type="submit"]').val();
329        const unlokingText = jQuery(that).data('unlocking-text');
330
331
332        var data = {
333            'action': 'lock_content_form_handler',
334            'client_id': ep_client_id,
335            'password': password,
336            'post_id': post_id,
337        };
338
339        jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(unlokingText);
340
341        jQuery.post(eplocalize.ajaxurl, data, function (response) {
342            if (response.success) {
343                if (!response.embedHtml) {
344
345                    jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(buttonText);
346                    jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="password"]').val('');
347                    jQuery(that).closest('.password-form-container').find('.error-message').removeClass('hidden');
348                }
349                else {
350                    jQuery('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').html(response.embedHtml);
351
352                    if (jQuery('#' + perentSel + '-' + ep_client_id + ' .ose-youtube').length > 0) {
353                        epGlobals.youtubeChannelGallery();
354                    }
355
356                    if ($('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').length > 0) {
357                        epLoadMore();
358                    }
359                    
360                    // Custom player initialization when content protection enabled
361                    document.querySelector('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').classList.remove('plyr-initialized');
362
363                    initPlayer(document.querySelector('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper'));
364
365                }
366            } else {
367                jQuery('#password-error_' + ep_client_id).html(response.form);
368                jQuery('#password-error_' + ep_client_id).show();
369            }
370        }, 'json');
371    }
372
373    // unlockSubmitHander called for gutentberg
374    jQuery('.ep-gutenberg-content .password-form').submit(function (e) {
375        e.preventDefault(); // Prevent the default form submission
376        unlockSubmitHander('ep-gutenberg-content', this);
377    });
378
379    window.addEventListener('load', function (e) {
380        const urlParams = new URLSearchParams(window.location.search);
381        const hash = urlParams.get('hash');
382
383        // find the element with the matching id
384        const element = document.getElementById(hash);
385
386        if (element) {
387            element.scrollIntoView({ behavior: 'smooth' });
388        }
389
390    });
391
392
393})(jQuery);
394
395
396jQuery(window).on("elementor/frontend/init", function () {
397
398    var filterableGalleryHandler = function ($scope, $) {
399
400        // Get the Elementor unique selector for this widget
401        let classes = $scope[0].className;
402        let selectorEl = '.' + classes.split(' ').join('.');
403
404        const epElLoadMore = () => {
405
406            const spinicon = '<svg width="18" height="18" fill="#fff" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><style>.spinner_GuJz{transform-origin:center;animation:spinner_STY6 1.5s linear infinite}@keyframes spinner_STY6{100%{transform:rotate(360deg)}}</style><g class="spinner_GuJz"><circle cx="3" cy="12" r="2"/><circle cx="21" cy="12" r="2"/><circle cx="12" cy="21" r="2"/><circle cx="12" cy="3" r="2"/><circle cx="5.64" cy="5.64" r="2"/><circle cx="18.36" cy="18.36" r="2"/><circle cx="5.64" cy="18.36" r="2"/><circle cx="18.36" cy="5.64" r="2"/></g></svg>';
407
408            $('.elementor-widget-container .ep-nft-gallery-wrapper').each(function () {
409                let selctorEl = `.elementor-widget-container [data-nftid='${$(this).data('nftid')}']`;
410                let loadmorelabel = $(selctorEl).data('loadmorelabel');
411                $(selctorEl + ` .ep_nft_item`).slice(0, $(selctorEl).data('itemparpage')).show();
412                $('.elementor-widget-container .ep-nft-gallery-wrapper .ep-loadmore-wrapper button').css('display', 'flex');
413
414                $(selctorEl + " .nft-loadmore").click(function (e) {
415                    //change the text of the button
416                    $(this).html(loadmorelabel + spinicon);
417
418                    //disable the button
419                    $(this).prop("disabled", true);
420                    //wait for 1 seconds
421                    setTimeout(function () {
422                        //change the text back
423                        $(selctorEl + " .nft-loadmore").text(loadmorelabel);
424                        //enable the button
425                        $(selctorEl + " .nft-loadmore").prop("disabled", false);
426                        $(selctorEl + " .ep_nft_item:hidden").slice(0, $(selctorEl).data('itemparpage')).fadeIn("slow");
427                        if ($(selctorEl + " .ep_nft_item:hidden").length == 0) {
428                            $(selctorEl + " .nft-loadmore").fadeOut("slow");
429                        }
430                    }, 500);
431                });
432            });
433        };
434
435        if ($('.elementor-widget-container .ep-nft-gallery-wrapper').length > 0) {
436            epElLoadMore();
437        }
438
439        // Content protection system function 
440        const unlockElSubmitHander = (perentSel, that) => {
441            var ep_client_id = jQuery(that).closest('form').find('input[name="ep_client_id"]').val();
442            var password = jQuery(`input[name="pass_${ep_client_id}"]`).val();
443            var post_id = jQuery(`input[name="post_id"]`).val();
444            const buttonText = jQuery(that).closest('.password-form-container').find('input[type="submit"]').val();
445            const unlokingText = jQuery(that).data('unlocking-text');
446
447            var data = {
448                'action': 'lock_content_form_handler',
449                'client_id': ep_client_id,
450                'password': password,
451                'post_id': post_id,
452            };
453
454            jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(unlokingText);
455
456            jQuery.post(eplocalize.ajaxurl, data, function (response) {
457                if (response.success) {
458                    if (!response.embedHtml) {
459                        jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(buttonText);
460                        jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="password"]').val('');
461                        jQuery(that).closest('.password-form-container').find('.error-message').removeClass('hidden');
462                    }
463                    else {
464                        if ($('.ep-content-locked').has('#' + perentSel + '-' + ep_client_id).length) {
465                            $('.ep-content-locked').removeClass('ep-content-locked');
466                        }
467
468                        jQuery('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').html(response.embedHtml);
469
470                        $('#' + perentSel + '-' + ep_client_id).removeClass('ep-content-protection-enabled');
471
472                        if (jQuery('#' + perentSel + '-' + ep_client_id + ' .ose-youtube').length > 0) {
473                            epGlobals.youtubeChannelGallery();
474                        }
475
476                        if ($('.elementor-widget-container .ep-nft-gallery-wrapper').length > 0) {
477                            epElLoadMore();
478                        }
479                    }
480                } else {
481                    jQuery('#password-error_' + ep_client_id).html(response.form);
482                    jQuery('#password-error_' + ep_client_id).show();
483                }
484            }, 'json');
485        }
486
487        // unlockElSubmitHander called for Elementor
488        jQuery('.ep-elementor-content .password-form').submit(function (e) {
489            e.preventDefault(); // Prevent the default form submission
490            unlockElSubmitHander('ep-elementor-content', this);
491        });
492    };
493    elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", filterableGalleryHandler);
494    elementorFrontend.hooks.addAction("frontend/element_ready/embedpress_pdf.default", filterableGalleryHandler);
495    elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_document.default", filterableGalleryHandler);
496});
497
498
499// document.addEventListener('DOMContentLoaded', function () {
500//     testHellowWorld();
501// });
502
503// testHellowWorld();

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.