PageSourceSearch

https://substantivoplural.com.br/wp-content/plugins/foxiz-core/assets/core.js?ver=2.1.5

js substantivoplural.com.br collected 2026-10-02 02:59:12 UTC 13,282 bytes, 386 lines download raw bytes

1/** FOXIZ_CORE_SCRIPT */
2var FOXIZ_CORE_SCRIPT = (function (Module, $) {
3    "use strict";
4
5    Module.init = function () {
6        this._body = $('body');
7        this.darkModeID = foxizCoreParams.darkModeID || 'RubyDarkMode';
8        this.mSiteID = foxizCoreParams.mSiteID || null;
9        this.isCMode = document.body.classList.contains("is-cmode");
10        this.personailizeUID = this.getUserUUID();
11        this.initDarkModeCookie();
12        this.switchDarkMode();
13        this.noteToggle();
14        this.emailToDownload();
15        this.accordion();
16        this.ajaxURL = foxizCoreParams.ajaxurl
17    }
18
19    /**
20     * generate UUID
21     * @returns {string}
22     */
23    Module.generateUUID = function () {
24        const alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789';
25        let id = '';
26        for (let i = 0; i < 7; i++) {
27            const randomIndex = Math.floor(Math.random() * alphabet.length);
28            id += alphabet[randomIndex];
29        }
30        return id;
31    }
32
33    /**
34     * set cookies
35     * @param name
36     * @param value
37     * @param days
38     */
39    Module.setCookie = function (name, value, days = 60) {
40
41        var date = new Date();
42        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
43        var expires = '; expires=' + date.toUTCString();
44        var cookieDomain = foxizCoreParams.cookieDomain || '';
45        var cookiePath = foxizCoreParams.cookiePath || '/';
46
47        document.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=' + cookiePath + '; domain=' + cookieDomain;
48    }
49
50    /**
51     * get cookie
52     * @param name
53     * @returns {string|null}
54     */
55    Module.getCookie = function (name) {
56        var nameEQ = name + '=';
57        var cookies = document.cookie.split(';');
58        for (var i = 0; i < cookies.length; i++) {
59            var cookie = cookies[i];
60            while (cookie.charAt(0) == ' ') cookie = cookie.substring(1, cookie.length);
61            if (cookie.indexOf(nameEQ) == 0) return decodeURIComponent(cookie.substring(nameEQ.length, cookie.length));
62        }
63        return null;
64    }
65
66    /**
67     * delete cookies
68     * @param name
69     */
70    Module.deleteCookie = function (name) {
71        var cookieDomain = foxizCoreParams.cookieDomain || '';
72        var cookiePath = foxizCoreParams.cookiePath || '/';
73        document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=' + cookiePath + '; domain=' + cookieDomain;
74    }
75
76    /**
77     * set localStorage
78     * @param key
79     * @param data
80     */
81    Module.setStorage = function (key, data) {
82        localStorage.setItem(key, JSON.stringify(data));
83    }
84
85    /**
86     * get localStorage
87     * @param key
88     * @param defaultValue
89     * @returns {any}
90     */
91    Module.getStorage = function (key, defaultValue) {
92        const data = localStorage.getItem(key);
93        if (data === null) {
94            return defaultValue;
95        }
96        return JSON.parse(data);
97    }
98
99    /**
100     * delelte localStorage
101     * @param key
102     */
103    Module.deleteStorage = function (key) {
104        localStorage.removeItem(key);
105    }
106
107    /**
108     * create UUID
109     * @returns {string|*}
110     */
111    Module.getUserUUID = function () {
112        let uuid;
113
114        if (!navigator.cookieEnabled) {
115            return 'uuid';
116        }
117
118        if (this.getCookie('RBUUID')) {
119            uuid = this.getCookie('RBUUID');
120        } else {
121            uuid = this.getStorage('RBUUID', null);
122            if (null === uuid) {
123                uuid = this.generateUUID();
124                this.setStorage('RBUUID', uuid);
125                this.setCookie('personalize_sync', 'yes', 1);
126            }
127
128            this.setCookie('RBUUID', uuid);
129        }
130
131        if (this.mSiteID) {
132            uuid = this.mSiteID + uuid;
133        }
134
135        return uuid;
136    }
137
138    Module.initDarkModeCookie = function () {
139        if (this.isCMode && !this.getCookie(this.darkModeID)) {
140            this.setCookie(this.darkModeID, document.body.getAttribute('data-theme'));
141        }
142    }
143
144    Module.setDarkModeCookie = function (name, value) {
145        if (this.isCMode) {
146            this.setCookie(name, value);
147        }
148    }
149
150    Module.switchDarkMode = function () {
151        var self = this;
152
153        $('.dark-mode-toggle').off('click').on('click', function (e) {
154            e.preventDefault();
155            e.stopPropagation();
156
157            if (!$(this).hasClass('triggered')) {
158                $(this).addClass('triggered')
159            }
160
161            const iconDefault = $('.mode-icon-default');
162            const iconDark = $('.mode-icon-dark');
163            const currentMode = (
164                (self.isCMode || !navigator.cookieEnabled) ?
165                    document.body.getAttribute('data-theme') :
166                    localStorage.getItem(self.darkModeID)
167            );
168
169            self._body.addClass('switch-smooth');
170
171            if ('dark' === currentMode) {
172                if (navigator.cookieEnabled) {
173                    localStorage.setItem(self.darkModeID, 'default');
174                    self.setDarkModeCookie(self.darkModeID, 'default');
175                }
176                self._body.attr('data-theme', 'default');
177                iconDefault.addClass('activated');
178                iconDark.removeClass('activated');
179            } else {
180                if (navigator.cookieEnabled) {
181                    localStorage.setItem(self.darkModeID, 'dark');
182                    self.setDarkModeCookie(self.darkModeID, 'dark');
183                }
184                self._body.attr('data-theme', 'dark');
185                iconDefault.removeClass('activated');
186                iconDark.addClass('activated');
187            }
188        })
189    }
190
191    /** share action */
192    Module.shareTrigger = function () {
193        $('a.share-trigger').off('click').on('click', function (e) {
194            e.preventDefault();
195            e.stopPropagation();
196            window.open($(this).attr('href'), '_blank', 'width=600, height=350');
197            return false;
198        });
199        $('a.copy-trigger').off('click').on('click', function (e) {
200            e.preventDefault();
201            e.stopPropagation();
202            var target = $(this);
203            var link = target.data('link');
204            var copied = target.data('copied');
205            if (link) {
206                navigator.clipboard.writeText(link).then(
207                    function () {
208                        $('body').find('.tipsy-inner').html((copied));
209                    }).catch(function () {
210                    console.log('Copying is not supported by your browser.');
211                });
212            }
213        });
214
215        $('a.native-share-trigger').on('click', function (e) {
216            e.preventDefault();
217            e.stopPropagation();
218            const target = $(this);
219
220            if (navigator.share) {
221                const link = target.data('link');
222                const title = target.data('ptitle');
223                navigator.share({
224                    title: title,
225                    url: link
226                })
227            } else {
228                console.log('Native share API not supported.');
229            }
230        });
231    };
232
233    /** single infinite load */
234    Module.loadGoogleAds = function (response) {
235        var googleAds = $(response).find('.adsbygoogle');
236        if (typeof window.adsbygoogle !== 'undefined' && googleAds.length) {
237            var adsbygoogle;
238            googleAds.each(function () {
239                (adsbygoogle = window.adsbygoogle || []).push({});
240            });
241        }
242    }
243
244    Module.loadInstagram = function (response) {
245        var instEmbed = $(response).find('.instagram-media');
246        if ('undefined' !== typeof window.instgrm) {
247            window.instgrm.Embeds.process();
248        } else if (instEmbed.length && 'undefined' === typeof window.instgrm) {
249            var embedJS = document.createElement('script');
250            embedJS.src = '//platform.instagram.com/en_US/embeds.js';
251            embedJS.onload = function () {
252                window.instgrm.Embeds.process();
253            };
254            this._body.append(embedJS);
255        }
256    }
257
258    Module.updateGA = function (article) {
259        var gaURL = article.postURL.replace(/https?:\/\/[^\/]+/i, '');
260        if (typeof _gaq !== 'undefined' && _gaq !== null) {
261            _gaq.push(['_trackPageview', gaURL]);
262        }
263        if (typeof ga !== 'undefined' && ga !== null) {
264            ga('send', 'pageview', gaURL);
265        }
266        if (typeof __gaTracker !== 'undefined' && __gaTracker !== null) {
267            __gaTracker('send', 'pageview', gaURL);
268        }
269
270        if (window.googletag && googletag.pubadsReady) {
271            googletag.pubads().refresh();
272        }
273    }
274
275    Module.noteToggle = function () {
276        $('.yes-toggle > .note-header').on('click', function () {
277            let wrapper = $(this).parent();
278            let timing = wrapper.hasClass('is-inline') ? 0 : 300;
279
280            wrapper.toggleClass('explain');
281            wrapper.find('.note-content').slideToggle(timing);
282        });
283    }
284
285    Module.isValidEmail = function (email) {
286        var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
287        return emailRegex.test(email);
288    }
289
290    Module.emailToDownload = function () {
291        var self = this;
292
293        $('.download-form').each(function () {
294            var form = $(this);
295            var acceptTermsCheckbox = form.find('input[name="acceptTerms"]');
296            var submitButton = form.find('input[type="submit"]');
297            var noticeText = form.find('.notice-text');
298
299            if (acceptTermsCheckbox.length > 0) {
300                acceptTermsCheckbox.change(function () {
301                    submitButton.prop('disabled', !this.checked);
302                });
303            }
304
305            form.submit(function (event) {
306                event.preventDefault();
307
308                var emailInput = form.find('input[name="EMAIL"]');
309                var email = emailInput.val();
310                var label = form.find('input[type="submit"]').val();
311                noticeText.empty();
312
313                if (!self.isValidEmail(email)) {
314                    var errorNotice = 'Please enter a valid email address.';
315                    noticeText.text(errorNotice);
316                    return;
317                }
318
319                var wrapper = form.parents('.gb-download');
320                wrapper.addClass('submitting');
321
322                $.ajax({
323                    url: self.ajaxURL,
324                    method: 'POST',
325                    data: form.serialize(),
326                    success: function (response) {
327                        var fileURL = response.file;
328                        if (fileURL) {
329                            var link = document.createElement('a');
330                            link.href = fileURL;
331                            link.setAttribute('download', '');
332                            link.click();
333                            var newContent = `<div class="fallback-info">${response.message}</div><a href="${response.file}" download="" class="is-btn gb-download-btn fallback-download-btn">${label}</a>`;
334                            form.replaceWith(newContent);
335                        } else {
336                            noticeText.text(response.message);
337                        }
338                        wrapper.removeClass('submitting');
339                    }
340                });
341            });
342        });
343    };
344
345    Module.accordion = function () {
346        $('.gb-accordion').each(function () {
347            const accordion = $(this);
348            const accordionItems = accordion.find('.gb-accordion-item');
349
350            if (accordion.hasClass('yes-open')) {
351                accordionItems.first().addClass('active');
352            }
353
354            accordionItems.on('click', function () {
355                const item = $(this);
356                const isActive = item.hasClass('active');
357
358                if (!isActive) {
359                    const activeItem = accordionItems.filter('.active');
360                    activeItem.removeClass('active').find('.accordion-item-content').slideUp(250, function () {
361                        $(this).css('display', 'none');
362                    });
363
364                    item.addClass('active').find('.accordion-item-content').slideDown(250, function () {
365                        $(this).css('display', 'block');
366                    });
367                } else {
368                    item.removeClass('active').find('.accordion-item-content').slideUp(250, function () {
369                        $(this).css('display', 'none');
370                    });
371                }
372            });
373        });
374    };
375
376    return Module;
377
378}(FOXIZ_CORE_SCRIPT || {}, jQuery));
379
380jQuery(document).ready(function () {
381    FOXIZ_CORE_SCRIPT.init();
382});
383
384jQuery(window).on('load', function () {
385    FOXIZ_CORE_SCRIPT.shareTrigger();
386});

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.