HEX
Server: Apache
System: Linux webm003.cluster111.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User: assotraipi (849654)
PHP: 5.4.45
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/assotraipi/www/wp-content/plugins/download-monitor/assets/js/api-keys-generator.js
jQuery(document).ready(function($) {

    $('.dlm-keygen-user-select').select2({
        ajax: {
            url: dlm_ajax.ajaxurl,
            dataType: 'json',
            delay: 250,
            data: function(params) {
                return {
                    q: params.term, // search term
                    action: 'dlm_keygen_search_users', // AJAX action
                    _ajax_nonce: dlm_ajax.nonce,
                };
            },
            processResults: function(data) {
                return {
                    results: data
                };
            },
            cache: true
        },
        minimumInputLength: 2, // Minimum length before searching
        placeholder: 'Search for a user',
        width: '400px'
    });


    $(document).on('click', '.dlm-keygen-generate', function(e) {
        e.preventDefault();
        user_id = $(this).parent().find( '.dlm-keygen-user-select').val();

        $.ajax({
            url: dlm_ajax.ajaxurl,
            type: 'POST', // Assuming you are sending a POST request
            dataType: 'json',
            data: {
                user_id: user_id,
                action: 'dlm_action_api_key', // AJAX action
                dlm_action: 'generate',
                _ajax_nonce: dlm_ajax.nonce, // Include the nonce for security
            },
            success: function(data) {
                if( data.success ){
                    location.reload();
                }
            },
            error: function(jqXHR, textStatus, errorThrown) {
                // Handle any errors here
                console.error('Error: ' + textStatus + ', ' + errorThrown);
            }
        });
    });


    $(document).on('click', '.dlm-regenerate-key', function( e ) {
        e.preventDefault();
        var user_id = $(this).data('user-id');

        $.ajax({
            url: dlm_ajax.ajaxurl,
            type: 'POST', // Assuming you are sending a POST request
            dataType: 'json',
            data: {
                user_id: user_id,
                action: 'dlm_action_api_key', // AJAX action
                dlm_action: 'regenerate',
                _ajax_nonce: dlm_ajax.nonce, // Include the nonce for security
            },
            success: function(data) {
                if( data.success ){
                    location.reload();
                }
            },
            error: function(jqXHR, textStatus, errorThrown) {
                // Handle any errors here
                console.error('Error: ' + textStatus + ', ' + errorThrown);
            }
        });
    });


    $(document).on('click', '.dlm-revoke-key', function( e ) {
        e.preventDefault();
        var user_id = $(this).data('user-id');

        $.ajax({
            url: dlm_ajax.ajaxurl,
            type: 'POST', // Assuming you are sending a POST request
            dataType: 'json',
            data: {
                user_id: user_id,
                action: 'dlm_action_api_key', // AJAX action
                dlm_action: 'revoke',
                _ajax_nonce: dlm_ajax.nonce, // Include the nonce for security
            },
            success: function(data) {
                if( data.success ){
                    location.reload();
                }
            },
            error: function(jqXHR, textStatus, errorThrown) {
                // Handle any errors here
                console.error('Error: ' + textStatus + ', ' + errorThrown);
            }
        });
    });

});