HEX
Server: LiteSpeed
System: Linux s3604.bom1.stableserver.net 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User: dmstechonline (1480)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/dmstechonline/businessclub.dmstech.online/wp-content/themes/rishi/updater/notice.js
document.addEventListener('DOMContentLoaded', function() {
    let activationLink = document.querySelector('.rishi-activation-link');
    let activationAttribute = document.querySelector('.notice-rishi-theme-activation-root');

    // Check if the element exists before attaching the event listener
    if (null !== activationLink) {

        activationLink.addEventListener('click', function(event) {
            // Prevent the default action of the link
            event.preventDefault();

            let activationNonce = activationAttribute.dataset.nonce;
            let activationURL = activationAttribute.dataset.link;
            let xhr = new XMLHttpRequest();
            let url = wp.ajax.settings.url; // Replace ajaxurl with the actual URL if needed
            let data = {
                action: "rishi_activate_license_updates",
                nonceToken: activationNonce // Make sure nonceToken is defined in your scope
            };

            // Convert the data object to a URL-encoded string
            let encodedData = Object.keys(data).map(function(key) {
                return encodeURIComponent(key) + '=' + encodeURIComponent(data[key]);
            }).join('&');

            xhr.open('POST', url, true);
            xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            xhr.onreadystatechange = function() {
                if (xhr.readyState ===  4 && xhr.status ===  200) {
                    let response = JSON.parse(xhr.responseText);
                    if (response.success) {
                        if (response.data.license === "valid") {
                            location.assign(activationURL); // Make sure redirectURL is defined in your scope
                        }
                    } 
                } else if (xhr.readyState ===  4) {
                    // Handle errors
                    console.error('An error occurred during the transaction');
                }
            };
            xhr.send(encodedData);
        });
    }
});