GIF89a=( õ' 7IAXKgNgYvYx\%wh…hŽth%ˆs%—x¨}9®Œ©€&©‰%¶†(¹–.¹5·œD¹&Çš)ÇŸ5ǘ;Í£*È¡&Õ²)ׯ7×µ<Ñ»4ï°3ø‘HÖ§KͯT÷¨Yÿšqÿ»qÿÔFØ !ù ' !ÿ NETSCAPE2.0 , =( þÀ“pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§gª«ªE¯°¨¬ª±²Œ¹º¹E¾­”´ÂB¶¯ §Åȸ»ÑD¾¿Á•ÄÅ®° ÝH¾ÒLÀÆDÙ«D¶BÝïðÀ¾DÑÑÔTÌÍíH òGö¨A RÎڐ |¥ ٭&ºìE8œ¹kGÔAÞpx­a¶­ã R2XB®åE8I€Õ6Xî:vT)äžþÀq¦è³¥ì仕F~%xñ  4#ZÔ‰O|-4Bs‘X:= QÉ œš lºÒyXJŠGȦ|s hÏíK–3l7·B|¥$'7Jީܪ‰‡àá”Dæn=Pƒ ¤Òëí‰`䌨ljóá¯Éüv>á–Á¼5 ½.69ûϸd«­ºÀûnlv©‹ªîf{¬ÜãPbŸ  l5‘ޝpß ´ ˜3aÅùäI«O’ý·‘áÞ‡˜¾Æ‚ÙÏiÇÿ‹Àƒ #öó)pâš Þ½ ‘Ý{ó)vmÞü%D~ 6f s}ŃƒDØW Eþ`‡þ À…L8xá†ç˜{)x`X/> Ì}mø‚–RØ‘*|`D=‚Ø_ ^ð5 !_…'aä“OÚ—7âcð`D”Cx`ÝÂ¥ä‹éY¹—F¼¤¥Š?¡Õ™ n@`} lď’ÄÉ@4>ñd œ à‘vÒxNÃ×™@žd=ˆgsžG±æ ´²æud &p8Qñ)ˆ«lXD©øÜéAžHìySun jª×k*D¤LH] †¦§C™Jä–´Xb~ʪwStŽ6K,°£qÁœ:9ت:¨þªl¨@¡`‚ûÚ ».Û¬¯t‹ÆSÉ[:°=Š‹„‘Nåû”Ìî{¿ÂA ‡Rà›ÀÙ6úë°Ÿð0Ä_ ½;ÃϱîÉì^ÇÛÇ#Ëë¼ôº!±Ä˜íUîÅÇ;0L1óÁµö«p% AÀºU̬ݵ¼á%霼€‡¯Á~`ÏG¯»À× ­²± =4ªnpð3¾¤³¯­ü¾¦îuÙuµÙ®|%2ÊIÿür¦#0·ÔJ``8È@S@5ê¢ ö×Þ^`8EÜ]ý.뜃Âç 7 ú ȉÞj œ½Dç zý¸iþœÑÙûÄë!ˆÞÀl§Ïw‹*DçI€nEX¯¬¼ &A¬Go¼QföõFç°¯;é¦÷îŽêJ°îúôF5¡ÌQ|îúöXªæ»TÁÏyñêï]ê² o óÎC=öõ›ÒÓPB@ D×½œä(>èCÂxŽ`±«Ÿ–JЀ»Û á¤±p+eE0`ëŽ`A Ú/NE€Ø†À9‚@¤à H½7”à‡%B‰`Àl*ƒó‘–‡8 2ñ%¸ —€:Ù1Á‰E¸àux%nP1ð!‘ðC)¾P81lÑɸF#ˆ€{´âé°ÈB„0>±û °b¡Š´±O‚3È–Ù()yRpbµ¨E.Z‘D8ÊH@% òŒx+%Ù˜Æcü »¸˜fõ¬b·d`Fê™8èXH"ÉÈ-±|1Ô6iI, 2““¬$+](A*jÐ QTÂo‰.ÛU슬Œã„Ž`¯SN¡–¶Äåyše¯ª’­¬‚´b¦Éož œ)åyâ@Ì®3 ÎtT̉°&Ø+žLÀf"Ø-|žçÔ>‡Ðv¦Ðžì\‚ Q1)Ž@Žh#aP72”ˆ™¨$‚ !ù " , =( …7IAXG]KgNgYvYxR"k\%w]'}hŽth%ˆg+ˆs%—r.—m3šx3˜x¨}9®€&©€+¨‡7§‰%¶†(¹–.¹œD¹&ǘ;Í•&ײ)×»4ïÌ6ò§KÍ þ@‘pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g «¬ E ±± ¨­¶°ººE Á´”·®C¬²§Ç¶Œ»ÓDÃÕƷ¯Ê±H½ºM×ÁGÚ¬D¶BËÁ½î½DÓôTÏÛßîG»ôõC×CÌ l&âž:'òtU³6ɹ#·Ø)€'Ü.6±&ëÍÈ» K(8p0N?!æ2"ÛˆNIJX>R¼ÐO‚M '¡¨2¸*Ÿþ>#n↠å@‚<[:¡Iïf’ ¤TÚ˘CdbÜÙ“[«ŽEú5MBo¤×@€`@„€Êt W-3 ¶Ÿ¡BíêäjIÝ…Eò9[T…$íêﯧ„…•s»Óȳ¹€ÅÚdc®UUρ#±Ùïldj?´í¼²`\ŽÁðÞu|3'ÖŒ]ë6 ¶S#²‡˜FKLÈ *N E´‘áäŠ$˜›eÄYD„ºq«.è촁ƒs \-ÔjA 9²õ÷å- üúM[Âx(ís÷ì®x€|í¡Ù’p¦‚ ŽkÛTÇDpE@WÜ ²Ç]kŠ1¨ þ€·Yb ÓÁ‰l°*n0 ç™—žzBdОu¾7ĉBl€â‰-ºx~|UåU‰  h*Hœ|e"#"?vpÄiŠe6^ˆ„+qâŠm8 #VÇá ‘å–ÄV„œ|Аè•m"сœn|@›U¶ÆÎž—Špb¥G¨ED”€±Úê2FÌIç? >Éxå Œ± ¡¤„%‘žjŸ‘ꄯ<Ìaà9ijÐ2˜D¦È&›†Z`‚å]wþ¼Â:ç6àB¤7eFJ|õÒ§Õ,¨äàFÇ®cS·Ê¶+B°,‘Þ˜ºNûãØ>PADÌHD¹æž«ÄÀnÌ¥}­#Ë’ë QÀÉSÌÂÇ2ÌXÀ{æk²lQÁ2«ÊðÀ¯w|2Í h‹ÄÂG€,m¾¶ë3ÐÙ6-´ÅE¬L°ÆIij*K½ÀÇqï`DwVÍQXœÚÔpeœ±¬Ñ q˜§Tœ½µƒ°Œìu Â<¶aØ*At¯lmEØ ü ôÛN[P1ÔÛ¦­±$ÜÆ@`ùåDpy¶yXvCAyåB`ŽD¶ 0QwG#¯ æš[^Äþ $ÀÓÝǦ{„L™[±úKÄgÌ;ï£S~¹ìGX.ôgoT.»åˆ°ùŸûù¡?1zö¦Ÿž:ÅgÁ|ìL¹ „®£œŠ‚à0œ]PÁ^p F<"•ç?!,ñ‡N4—…PÄ Á„ö¨Û:Tè@hÀ‹%táÿ:ø-žI<`þ‹p I….)^ 40D#p@ƒj4–؀:²‰1Øâr˜¼F2oW¼#Z†;$Q q” ‘ ÂK¦ñNl#29 !’F@¥Bh·ᏀL!—XFóLH‘Kh¤.«hE&JòG¨¥<™WN!€ÑÙÚˆY„@†>Œž19J" 2,/ &.GXB%ÌRÈ9B6¹W]’î×ÔW¥’IÎ$ ñ‹ÓŒE8YÆ ¼³™ñA5“à®Q.aŸB€&Ø©³ JÁ—! ¦t)K%tœ-¦JF bòNMxLôþ)ÐR¸Ð™‘ èÝ6‘O!THÌ„HÛ ‰ !ù ) , =( …AXKgNgYvYxR"k\%wh…hŽh%ˆg+ˆs%—r.—x3˜x¨}9®€&©€+¨Œ,©‡7§‰%¶†(¹–.¹5·&Çš)ǘ;Í•&×£*Ȳ)ׯ7×»4ï°3øÌ6ò‘HÖ§KÍ»Hó¯T÷¨Yÿ»qÿÇhÿ þÀ”pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g ª« E$±²¨ª­ · °²½$E$ÂÕ««D· Í ¿¦Ç¶¸ÌŒ¾³CÃÅÆ E ééH½MÛÂGâªD­ çBêêϾD²ÒaÀà€Š1r­ðÓ¤ ÔožzU!L˜C'¾yW½UGtäÇïÙllê0×àÂuGþ)AÀs[þ·xì ÁxO%ƒûX2ó—  P£n›R/¡ÑšHše+êDm?# —‘Ç£6¡8íJ¡ŸâDiäªM¥Ö„ôj“¬¹£5oQ7°- <‡ *´lãÓŒ2r/a!l)dÈ A™ÈE¢ôÔ͆…ð ;Ö˜c ¡%ß‚’Ùˆâ¸b½—pe~C"BíëÚHïeF2§æŠ8qb t_`urŠeü wÅu3êæPv§h•"ß`íÍxçLĹÜÖ3á  ~Öº“®›¸ÏMDfJÙ °„ÛµáWõ%§œ‚à©–‚X ÓØ)@®Ñ›Eþ´wëuÅSxb8y\mÖzœ¥§ZbºE—ÂLªÌw!y(>¡™wú=Ç|ÅÝs¢d €CÁW)HÜcC$€L Ä7„r.á\{)@ð` @ äXÈ$PD” `šaG:§æˆOˆ72EÐamn]ù"ŒcÊxÑŒ° &dR8`g«iÙŸLR!¦P …d’ä¡“¦ðÎTƒ¦ià|À _ ¥ Qi#¦Šg›Æ ›noMµ ›V ã£)p ç£ÎW…š=Âeªk§†j„ ´®1ß²sÉxéW«jšl|0¯B0Û, \jÛ´›6±¬¶C ÛíWþï|ëÙ‹¸ñzĸV {ì;Ýñn¼òVˆm³I¼³.Ðã¤PN¥ ²µ¼„µCã+¹ÍByî£Ñ¾HŸ›ëê 7ìYÆFTk¨SaoaY$Dµœìï¿Ã29RÈkt Çïfñ ÇÒ:ÀÐSp¹3ÇI¨â¥DZÄ ü9Ïýögñ½­uÔ*3)O‘˜Ö[_hv ,àî×Et Ÿé¶BH€ Õ[ü±64M@ÔSÌM7dÐl5-ÄÙU܍´©zߌ3Ô€3ž„ „ ¶ÛPô½5×g› êÚ˜kN„Ý…0Îj4€Ìë°“#{þÕ3S2çKÜ'ợlø¼Ú2K{° {Û¶?žm𸧠ËI¼nEò='êüóºè^üæÃ_Û=°óž‚ì#Oý¿Í'¡½áo..ÏYìnüñCœO±Áa¿¢Kô½o,üÄËbö²çºíï{ËC Ú— "”Ï{ËK ÍÒw„õ±Oz dÕ¨à:$ ƒô—«v»] A#ð «€¿šéz)Rx׿ˆ¥‚d``èw-îyÏf×K!ð€þ­Ð|ìPľ„=Ì`ý(f” 'Pa ¥ÐBJa%Ðâf§„%Š¡}FàáÝ×6>ÉäŠG"éŽè=ø!oа^FP¼Ø©Q„ÀCÙÁ`(Ž\ÄÝ® ©Â$<n@dÄ E#ììUÒI! ‚#lù‹`k¦ÐÇ'Rró’ZýNBÈMF Í[¤+‹ðɈ-áwj¨¥þ8¾rá ,VÂh„"|½œ=×G_¦Ñ™EØ 0i*%̲˜Æda0mV‚k¾)›;„&6 p>ÓjK “¦Ç# âDÂ:ûc?:R Ó¬fÞéI-Ì“•Ã<ä=™Ï7˜3œ¨˜c2ŒW ,ˆ”8(T™P‰F¡Jhç"‚ ; 403WebShell
403Webshell
Server IP : 172.67.177.218  /  Your IP : 216.73.216.165
Web Server : LiteSpeed
System : Linux premium229.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User : akhalid ( 749)
PHP Version : 8.3.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/akhalid/dangroup.sa/wp-content/plugins/wp-statistics/assets/dev/javascript/pages/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/akhalid/dangroup.sa/wp-content/plugins/wp-statistics/assets/dev/javascript/pages/overview.js
if (wps_js.global.page.file === "index.php" || wps_js.is_active('overview_page') || wps_js.global.page.file === "post-new.php" || (wps_js.global.page.file === "post.php" && wps_js.isset(wps_js.global, 'page', 'ID'))) {

    // Split meta boxes into left and right
    const meta_list_side = wps_js.global.meta_boxes.side;
    const meta_list_normal = wps_js.global.meta_boxes.normal;
    const meta_list_column3 = wps_js.global.meta_boxes?.column3;
    const meta_list_column4 = wps_js.global.meta_boxes?.column4;
    const isInsideDashboard = document.getElementById('dashboard-widgets') !== null;

    class DateManager {
        static getDateRange(filter) {
            const today = moment().format('YYYY-MM-DD');
            const currentWeekEnd = moment().endOf('week').format('YYYY-MM-DD');

            const ranges = {
                'today': {start: today, end: today},
                'yesterday': {
                    start: moment().subtract(1, 'days').format('YYYY-MM-DD'),
                    end: moment().subtract(1, 'days').format('YYYY-MM-DD')
                },
                'this_week': {
                    start: moment().startOf('week').format('YYYY-MM-DD'),
                    end: currentWeekEnd
                },
                'last_week': {
                    start: moment().subtract(1, 'week').startOf('week').format('YYYY-MM-DD'),
                    end: moment().subtract(1, 'week').endOf('week').format('YYYY-MM-DD')
                },
                'this_month': {
                    start: moment().startOf('month').format('YYYY-MM-DD'),
                    end: moment().endOf('month').format('YYYY-MM-DD')
                },
                'last_month': {
                    start: moment().subtract(1, 'month').startOf('month').format('YYYY-MM-DD'),
                    end: moment().subtract(1, 'month').endOf('month').format('YYYY-MM-DD')
                },
                '7days': {
                    start: moment().subtract(6, 'days').format('YYYY-MM-DD'),
                    end: today
                },
                '28days': {
                    start: moment().subtract(27, 'days').format('YYYY-MM-DD'),
                    end: today
                },
                '30days': {
                    start: moment().subtract(29, 'days').format('YYYY-MM-DD'),
                    end: today
                },
                '90days': {
                    start: moment().subtract(89, 'days').format('YYYY-MM-DD'),
                    end: today
                },
                '6months': {
                    start: moment().subtract(6, 'months').format('YYYY-MM-DD'),
                    end: today
                },
                'this_year': {
                    start: moment().startOf('year').format('YYYY-MM-DD'),
                    end: moment().endOf('year').format('YYYY-MM-DD')
                },
                'last_year': {
                    start: moment().subtract(1, 'year').startOf('year').format('YYYY-MM-DD'),
                    end: moment().subtract(1, 'year').endOf('year').format('YYYY-MM-DD')
                }
            };

            return ranges[filter] || {start: null, end: null};
        }

        static formatDateRange(startDate, endDate) {
            if (!startDate || !endDate) {
                return '';
            }

            const start = moment(startDate);
            const end = moment(endDate);

            if (start.isSame(end, 'day')) {
                return start.format('MMM D, YYYY');
            }
            return `${start.format('MMM D, YYYY')} - ${end.format('MMM D, YYYY')}`;
        }

        static getDefaultDateRange() {
            const today = moment().format('YYYY-MM-DD');
            return {
                start: moment().subtract(29, 'days').format('YYYY-MM-DD'),
                end: today
            };
        }
    }

    class DatePickerHandler {
        constructor() {
            this.initializeEventListeners();
        }

        initializeEventListeners() {
            this.initializeFilterToggles();
            this.initializeMoreFilters();
            this.initializeDatePicker();
            this.initializeCustomDatePicker();
            this.initializeDateSelection();
            this.initializeFilterClicks();
        }

        initializeFilterToggles() {
            jQuery(document).off('click', '.js-filters-toggle').on('click', '.js-filters-toggle', e => {
                const $target = jQuery(e.currentTarget);
                jQuery('.js-widget-filters').removeClass('is-active');
                jQuery('.postbox').removeClass('has-focus');
                $target.closest('.js-widget-filters').toggleClass('is-active');
                $target.closest('.postbox').toggleClass('has-focus');

                const targetTopPosition = $target[0].getBoundingClientRect().top;
                if (targetTopPosition < 350) {
                    $target.closest('.js-widget-filters').addClass('is-down');
                }
            });
        }

        initializeMoreFilters() {
            jQuery(document).off('click', '.js-show-more-filters').on('click', '.js-show-more-filters', e => {
                e.preventDefault();
                jQuery(e.currentTarget).closest('.c-footer__filters__list').find('.js-more-filters').addClass('is-open');
            });

            jQuery(document).off('click', '.js-close-more-filters').on('click', '.js-close-more-filters', e => {
                e.preventDefault();
                jQuery(e.currentTarget).closest('.js-more-filters').removeClass('is-open');
            });
        }

        initializeDatePicker() {
            jQuery('.js-datepicker-input').each(function () {
                if (!jQuery(this).data('daterangepicker')) {
                    jQuery(this).daterangepicker({
                        autoUpdateInput: false,
                        autoApply: true,
                        locale: {
                            cancelLabel: 'Clear',
                            format: 'YYYY-MM-DD'
                        }
                    });
                }
            });
        }

        initializeCustomDatePicker() {
            jQuery(document).off('click', 'button[data-filter="custom"]').on('click', 'button[data-filter="custom"]', e => {
                const $target = jQuery(e.currentTarget);
                const metaboxKey = $target.attr("data-metabox-key");
                const dateInput = jQuery('#' + metaboxKey + ' .inside .js-datepicker-input').first();

                this.setupDateRangePicker(dateInput, metaboxKey);
                dateInput.data('daterangepicker').show();
            });
        }

        setupDateRangePicker(dateInput, metaboxKey) {
            if (!dateInput.data('daterangepicker')) {
                dateInput.daterangepicker({
                    autoUpdateInput: false,
                    autoApply: true,
                    locale: {
                        cancelLabel: 'Clear',
                        format: 'YYYY-MM-DD'
                    }
                });

                dateInput.on('apply.daterangepicker', (ev, picker) => {
                    const dates = {
                        startDate: picker.startDate.format('YYYY-MM-DD'),
                        endDate: picker.endDate.format('YYYY-MM-DD')
                    };
                    this.handleDateSelection(metaboxKey, dates, picker);
                });
            }
        }

        initializeDateSelection() {
            jQuery('.js-datepicker-input').off('apply.daterangepicker').on('apply.daterangepicker', (ev, picker) => {
                const $metabox = jQuery(ev.currentTarget).closest('.postbox');
                const metaboxId = $metabox.attr('id');
                const dates = {
                    startDate: picker.startDate.format('YYYY-MM-DD'),
                    endDate: picker.endDate.format('YYYY-MM-DD')
                };
                this.handleDateSelection(metaboxId, dates, picker);
            });

            jQuery('.js-datepicker-input').off('hide.daterangepicker').on('hide.daterangepicker', (ev, picker) => {
                if (picker.startDate) {
                    const $metabox = jQuery(ev.currentTarget).closest('.postbox');
                    const metaboxId = $metabox.attr('id');
                    const dates = {
                        startDate: picker.startDate.format('YYYY-MM-DD'),
                        endDate: picker.endDate ? picker.endDate.format('YYYY-MM-DD') : picker.startDate.format('YYYY-MM-DD')
                    };
                    this.handleDateSelection(metaboxId, dates, picker, true);
                }
            });
        }

        handleDateSelection(metaboxId, dates, picker, isHide = false) {
            const $metabox = jQuery('#' + metaboxId);
            const dateRangeText = dates.startDate === dates.endDate ?
                picker.startDate.format('MMM D, YYYY') :
                picker.startDate.format('MMM D, YYYY') + ' - ' + picker.endDate.format('MMM D, YYYY');

            this.updateUIElements($metabox, dateRangeText, isHide);
            this.loadMetaBoxData(metaboxId, dates);
        }

        updateUIElements($metabox, dateRangeText, isHide) {
            const titleText = isHide ? 'Custom Range' : wps_js._('str_custom');
            $metabox.find('.js-filter-title').text(titleText);
            $metabox.find('.hs-filter-range').text(dateRangeText);
            $metabox.find('.js-filters-toggle').text(titleText);
            $metabox.find('.c-footer__filters').removeClass('is-active');
            jQuery('.postbox.has-focus').removeClass('has-focus');
        }

        initializeFilterClicks() {
            jQuery(document).off('click', '.c-footer__filters__list-item:not(.js-show-more-filters):not(.js-close-more-filters):not([data-filter="custom"])')
                .on('click', '.c-footer__filters__list-item:not(.js-show-more-filters):not(.js-close-more-filters):not([data-filter="custom"])', e => {
                    const $target = jQuery(e.currentTarget);
                    const filter = $target.data('filter');
                    const $metabox = $target.closest('.postbox');
                    const metaboxId = $metabox.attr('id');
                    const dates = DateManager.getDateRange(filter);

                    this.updateFilterUI($metabox, $target, dates);
                    this.loadMetaBoxData(metaboxId, dates, filter);
                });
        }

        updateFilterUI($metabox, $target, dates) {
            $metabox.find('.js-filter-title').text($target.text());
            $metabox.find('.hs-filter-range').text(DateManager.formatDateRange(dates.start, dates.end));
            $metabox.find('.js-filters-toggle').text($target.text());
            $metabox.find('.c-footer__filters').removeClass('is-active');
            $target.closest('.postbox.has-focus').removeClass('has-focus');
        }

        loadMetaBoxData(metaboxId, dates, filter = 'custom') {
            wps_js.showLoadingSkeleton(metaboxId);
            loadMetaBoxData(metaboxId, dates.startDate || dates.start, dates.endDate || dates.end, filter)
                .then(response => {
                    wps_js.handleMetaBoxRender(response, metaboxId);
                })
                .catch(error => console.error(`Error loading metabox ${metaboxId}:`, error));
        }
    }

    // Initialize DatePickerHandler
    wps_js.datePickerHandler = new DatePickerHandler();
    wps_js.initDatePickerHandlers = function () {
        wps_js.datePickerHandler.initializeEventListeners();
    };

    function loadMetaBoxData(metaBoxKey, startDate = null, endDate = null, date_filter = null) {
        return new Promise((resolve, reject) => {
            const keyName = metaBoxKey.replace(/-/g, '_').replace('widget', 'metabox');
            let data = {
                'action': `${keyName}_get_data`,
                'wps_nonce': wps_js.global.rest_api_nonce,
                'current_page': wps_js.global.page
            };

            if (date_filter) {
                data.date_filter = date_filter;
            }

            if (startDate && endDate) {
                data.from = startDate;
                data.to = endDate;
            }

            const successHandler = `${metaBoxKey}_success`;
            const errorHandler = `${metaBoxKey}_error`;

            wps_js[successHandler] = function (data) {
                resolve(data);
                return data;
            };

            wps_js[errorHandler] = function (error) {
                reject(error);
                return error;
            };

            wps_js.ajaxQ(
                wps_js.global.admin_url + 'admin-ajax.php',
                data,
                successHandler,
                errorHandler,
                'GET',
                false
            );
        });
    }

    wps_js.handleMetaBoxRender = function (response, metaBoxKey) {
        const keyName = metaBoxKey.replace(/-/g, '_');
        if (typeof wps_js[`render_${keyName}`] === 'function') {
            wps_js[`render_${keyName}`](response, metaBoxKey);
            wps_js.handelReloadButton(metaBoxKey);
            wps_js.handelMetaBoxFooter(metaBoxKey, response);
        }
    };

    function handleScreenOptionsChange() {
        let activeOptions = [];
        // Check if the screen options element exists
        if ($('#adv-settings').length > 0) {
            $('#adv-settings input[type="checkbox"]').each(function () {
                if ($(this).is(':checked')) {
                    // Get the ID and remove the '-hide' suffix
                    let optionId = $(this).attr('id').replace('-hide', '');
                    activeOptions.push(optionId);
                }
            });
        } else {
             activeOptions = [
                ...(Array.isArray(meta_list_side) ? meta_list_side : []),
                ...(Array.isArray(meta_list_normal) ? meta_list_normal : [])
            ];

            if (isInsideDashboard) {
                if (meta_list_column3) activeOptions = [...activeOptions, ...meta_list_column3];
                if (meta_list_column4) activeOptions = [...activeOptions, ...meta_list_column4];
            }
        }
        return activeOptions;
    }

    function refreshMetaBox(metaBoxKey) {
        loadMetaBoxData(metaBoxKey).then(response => {
            wps_js.handleMetaBoxRender(response, metaBoxKey);
        });
    }

    // Initialize meta boxes on page load
    let activeOptions = handleScreenOptionsChange();

    let normalIndex = 0, sideIndex = 0, column3Index = 0, column4Index = 0;
    let normalLength = meta_list_normal ? meta_list_normal.length : 0;
    let sideLength = meta_list_side ? meta_list_side.length : 0;
    let column3Length = isInsideDashboard ? meta_list_column3 ? meta_list_column3.length : 0 : 0;
    let column4Length = isInsideDashboard ? meta_list_column4 ? meta_list_column4.length : 0 : 0;
    let isMobile = isInsideDashboard ? window.innerWidth < 800 : window.innerWidth < 759;


    // Loop while either list has elements to process
    function processMetaBoxes(metaList, index, length) {
        if (!metaList || length === 0) return index; // Skip if metaList is null or empty

        while (index < length) {
            if (activeOptions.includes(metaList[index])) {
                refreshMetaBox(metaList[index]);
            }
            index++;
        }
        return index;
    }

    while (normalIndex < normalLength || sideIndex < sideLength || (isInsideDashboard && (column3Index < column3Length || column4Index < column4Length))) {
        if (isMobile) {
            if (isInsideDashboard) {
                normalIndex = processMetaBoxes(meta_list_normal, normalIndex, normalLength);
                sideIndex = processMetaBoxes(meta_list_side, sideIndex, sideLength);
                if (meta_list_column3) column3Index = processMetaBoxes(meta_list_column3, column3Index, column3Length);
                if (meta_list_column4) column4Index = processMetaBoxes(meta_list_column4, column4Index, column4Length);

            } else {
                sideIndex = processMetaBoxes(meta_list_side, sideIndex, sideLength);
                normalIndex = processMetaBoxes(meta_list_normal, normalIndex, normalLength);
            }

        } else {
            function processNextMetaBox(metaList, index, length) {
                if (!metaList || length === 0) return index;
                while (index < length && !activeOptions.includes(metaList[index])) {
                    index++;
                }
                if (index < length) {
                    refreshMetaBox(metaList[index]);
                    index++;
                }
                return index;
            }

            if (isInsideDashboard) {
                normalIndex = processNextMetaBox(meta_list_normal, normalIndex, normalLength);
                sideIndex = processNextMetaBox(meta_list_side, sideIndex, sideLength);
                column3Index = processNextMetaBox(meta_list_column3, column3Index, column3Length);
                column4Index = processNextMetaBox(meta_list_column4, column4Index, column4Length);
            } else {
                sideIndex = processNextMetaBox(meta_list_side, sideIndex, sideLength);
                normalIndex = processNextMetaBox(meta_list_normal, normalIndex, normalLength);
            }
        }
    }

    jQuery(document).on('change', '#adv-settings input[type="checkbox"]', function () {
        let metaBoxKey = $(this).attr('id').replace('-hide', '');

        if ($(this).is(':checked')) {
            refreshMetaBox(metaBoxKey);
        }
    });

    // Bind refresh button event for manual refresh
    function bindRefreshEvents(metaList) {
        metaList.forEach((metaBoxKey) => {
            jQuery(document).on('click', `#${metaBoxKey} .wps-refresh`, function () {
                wps_js.showLoadingSkeleton(metaBoxKey);
                refreshMetaBox(metaBoxKey);
            });
        });
    }

    // Bind refresh button events for both lists
    if (meta_list_side) bindRefreshEvents(meta_list_side);
    if (meta_list_normal) bindRefreshEvents(meta_list_normal);
    if (isInsideDashboard) {
        if (meta_list_column3) bindRefreshEvents(meta_list_column3);
        if (meta_list_column4) bindRefreshEvents(meta_list_column4);
    }

    // Export utility functions
    wps_js.metaBoxInner = key => jQuery('#' + key + ' .inside');

    wps_js.showLoadingSkeleton = function (metaBoxKey) {
        let metaBoxInner = jQuery('#' + metaBoxKey + ' .inside');
        metaBoxInner.html('<div class="wps-skeleton-container"><div class="wps-skeleton-container__skeleton wps-skeleton-container__skeleton--full wps-skeleton-container__skeleton--h-150"></div></div>');
    };

    wps_js.handelReloadButton = key => {
        const selector = "#" + key + " .handle-actions button:first";
        if (!jQuery('#' + key + ' .wps-refresh').length) {
            jQuery(`<button class="handlediv wps-refresh" type="button" title="${wps_js._('reload')}"></button>`).insertBefore(selector);
        }
    };

    wps_js.handelMetaBoxFooter = function (key, response) {
        let html = '<div class="c-footer"><div class="c-footer__filter js-widget-filters">';
        if (response.options && response.options.datepicker) {
            let startDateResponse;
            let endDateResponse;
            let dateFilterTitle = wps_js._(`str_30days`);
            let dateFilterType = wps_js._(`str_30days`);
            if (response?.filters && response.filters.date && response.filters.date.filter) {
                const dateFormat = wps_js.isset(wps_js.global, 'options', 'wp_date_format') ? wps_js.global['options']['wp_date_format'] : 'MM/DD/YYYY';
                let momentDateFormat = phpToMomentFormat(dateFormat);
                const startDateFormat = momentDateFormat.replace(/,?\s?(YYYY|YY)[-/\s]?,?|[-/\s]?(YYYY|YY)[-/\s]?,?/g, "");
                const fromDate = moment(response.filters.date.from);
                const toDate = moment(response.filters.date.to);
                if (fromDate.year() === toDate.year()) {
                    startDateResponse = fromDate.format(startDateFormat);
                } else {
                    startDateResponse = fromDate.format(momentDateFormat);
                }
                endDateResponse = toDate.format(momentDateFormat);
                dateFilterType = response.filters.date.type === 'custom' ? startDateResponse + ' _ ' + endDateResponse : wps_js._(`str_${response.filters.date.filter}`);
                dateFilterTitle = response.filters.date.type === 'custom' ? wps_js._('str_custom') : wps_js._(`str_${response.filters.date.filter}`)
            }

            html += `
                <button class="c-footer__filter__btn js-filters-toggle">` + dateFilterType + `</button>
                <div class="c-footer__filters">
                    <div class="c-footer__filters__current-filter">
                        <span class="c-footer__current-filter__title js-filter-title">` + dateFilterTitle + `</span>
                         <span class="c-footer__current-filter__date-range hs-filter-range">` + startDateResponse + ' - ' + endDateResponse + `</span>
                    </div>
                    <div class="c-footer__filters__list">
                        <button data-metabox-key="${key}" data-filter="today" class="c-footer__filters__list-item">` + wps_js._('str_today') + `</button>
                        <button data-metabox-key="${key}" data-filter="yesterday" class="c-footer__filters__list-item">` + wps_js._('str_yesterday') + `</button>
                        <button data-metabox-key="${key}" data-filter="this_week" class="c-footer__filters__list-item">` + wps_js._('str_this_week') + `</button>
                        <button data-metabox-key="${key}" data-filter="last_week" class="c-footer__filters__list-item">` + wps_js._('str_last_week') + `</button>
                        <button data-metabox-key="${key}" data-filter="this_month" class="c-footer__filters__list-item">` + wps_js._('str_this_month') + `</button>
                        <button data-metabox-key="${key}" data-filter="last_month" class="c-footer__filters__list-item">` + wps_js._('str_last_month') + `</button>
                        <button class="c-footer__filters__list-item c-footer__filters__list-item--more js-show-more-filters">` + wps_js._('str_more') + `</button>
                        <div class="c-footer__filters__more-filters js-more-filters">
                            <button data-metabox-key="${key}" data-filter="7days" class="c-footer__filters__list-item">` + wps_js._('str_7days') + `</button>
                            <button data-metabox-key="${key}" data-filter="28days" class="c-footer__filters__list-item">` + wps_js._('str_28days') + `</button>
                            <button data-metabox-key="${key}" data-filter="30days" class="c-footer__filters__list-item">` + wps_js._('str_30days') + `</button>
                            <button data-metabox-key="${key}" data-filter="90days" class="c-footer__filters__list-item">` + wps_js._('str_90days') + `</button>
                            <button data-metabox-key="${key}" data-filter="6months" class="c-footer__filters__list-item">` + wps_js._('str_6months') + `</button>
                            <button data-metabox-key="${key}" data-filter="this_year" class="c-footer__filters__list-item">` + wps_js._('str_this_year') + `</button>
                            <button data-metabox-key="${key}" data-filter="last_year" class="c-footer__filters__list-item">` + wps_js._('str_last_year') + `</button>
                            <button class="c-footer__filters__close-more-filters js-close-more-filters">` + wps_js._('str_back') + `</button>
                        </div>
                        <input type="text" class="c-footer__filters__custom-date-input js-datepicker-input"/>
                        <button data-metabox-key="${key}" data-filter="custom" class="c-footer__filters__list-item c-footer__filters__list-item--custom js-custom-datepicker">` + wps_js._('str_custom') + `</button>
                    </div>
                </div> `;
        }
        html += `</div>`;
        if (response.options && response.options.button) {
            html += response.options.button;
        }
        html += `</div></div>`;
        let selector = jQuery("#" + key + " h2.hndle");

        if (key === 'wp-statistics-useronline-widget') {
            const current_online = jQuery(".wps-currently-online");
            if (current_online.length && current_online.text() >= 0) {
                const container = selector.find('.wps-wps-currently-online__container');

                if (container.length) {
                    container.find('.wps-wps-currently-online__text').text(current_online.text());
                } else {
                    const online = `<span class="wps-wps-currently-online__container">
                                <span class="wps-wps-currently-online__dot"></span>
                                <span class="wps-wps-currently-online__text">${current_online.text()}</span>
                            </span>`;
                    selector.append(online);
                }
            } else {
                selector.find('.wps-wps-currently-online__container').remove()
            }
        }


        if (key === 'wp-statistics-quickstats-widget') {
            const selector = jQuery("#" + key + " div.handle-actions");
            if (selector.length && !selector.find('.wps-overview-btn').length) {
                const link = `<a href="${wps_js.global.admin_url}admin.php?page=wps_overview_page" class="wps-overview-btn">${wps_js._('go_to_overview')}</a>`;
                selector.prepend(link);
                const overviewBtn = selector.find('.wps-overview-btn');
                if (overviewBtn.length) {
                    overviewBtn.on('click', function (e) {
                        e.preventDefault();
                        window.location.href = this.href;
                    });
                }
            }
        }


        if (response.meta && response.meta.description) {
            if (selector.length && !selector.find('.wps-tooltip').length) {
                const tooltip = response.meta.description;
                const newTitle = '<a href="#" class="wps-tooltip" title="' + tooltip + '"><i class="wps-tooltip-icon"></i></a>';
                if (tooltip) selector.append(newTitle);
            }
        }

        wps_js.metaBoxInner(key).append(html);
    }

    document.addEventListener('click', function (event) {
        if (event.target && event.target.id === 'js-close-notice') {
            let params = {
                'action': 'wp_statistics_dismiss_notices',
                'wps_nonce': wps_js.global.rest_api_nonce,
                'notice_id': 'enable_email_metabox_notice'
            };

            jQuery.ajax({
                url: wps_js.global.admin_url + 'admin-ajax.php',
                type: 'POST',
                dataType: 'json',
                data: params,
                timeout: 30000,
                success: function ({data, success}) {
                    if (success === false) return console.log(data);
                    event.target.parentElement.parentElement.style.display = 'none';
                },
                error: function (xhr, status, error) {
                    console.log(error);
                }
            });
        }
    });

}

Youez - 2016 - github.com/yon3zu
LinuXploit