# mxchat-basic/2.1.8/js/mxchat_transcripts.js

MxChat – AI Chatbot &amp; Content Generation for WordPress, version 2.1.8. 106 lines.

- Page: https://pluginprobe.com/plugins/mxchat-basic/2.1.8/code/js/mxchat_transcripts.js
- Raw: https://pluginprobe.com/plugins/mxchat-basic/2.1.8/raw/js/mxchat_transcripts.js
- Modified: 2025-05-02T03:25:08+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/mxchat-basic/2.1.8/code/js/mxchat_transcripts.js#L10-L20`.

```javascript
    jQuery(document).ready(function($) {
        const selectButton = $('#mxchat-select-all-transcripts');
            let isSelected = false;
        
            selectButton.click(function() {
                isSelected = !isSelected;
                $(this).toggleClass('selected');
                
                // Update button text
                const buttonText = $(this).find('.button-text');
                buttonText.text(isSelected ? 'Deselect All' : 'Select All');
                
                // Update checkboxes
                $('#mxchat-transcripts').find('input[type=checkbox]').prop('checked', isSelected);
            });

        // Search functionality
        $('#mxchat-search-transcripts').on('input', function() {
            var searchTerm = $(this).val().toLowerCase();
            $('.mxchat-session').each(function() {
                var sessionText = $(this).text().toLowerCase();
                $(this).toggle(sessionText.includes(searchTerm));
            });
        });

        // Load transcripts
        $.ajax({
            url: ajaxurl,
            type: 'POST',
            data: {
                action: 'mxchat_fetch_chat_history'
            },
            success: function(response) {
                $('#mxchat-transcripts').html(response);
            }
        });

        // Your existing delete form submission code remains the same
        $('#mxchat-delete-form').submit(function(e) {
        e.preventDefault();
        var checkedSessionIds = $('input[name="delete_session_ids[]"]:checked').map(function() {
            return $(this).val();
        }).get();
        $.ajax({
            url: ajaxurl,
            type: 'POST',
            data: {
                action: 'mxchat_delete_chat_history',
                delete_session_ids: checkedSessionIds,
                security: $('#mxchat_delete_chat_nonce').val()
            },
            success: function(response) {
                var jsonResponse = JSON.parse(response);
                if (jsonResponse.success) {
                    alert("Success: " + jsonResponse.success);
                } else if (jsonResponse.error) {
                    alert("Error: " + jsonResponse.error);
                } else {
                    //console.log("Unexpected response format.");
                }
                location.reload();
            },
            error: function(xhr, status, error) {
                //console.error("AJAX Error: " + status + " - " + error);
                //console.log(xhr.responseText);
            }
        });
    });
    
    
    
    
    // Export functionality
    $('#mxchat-export-transcripts').on('click', function() {
        var $button = $(this);
        $button.prop('disabled', true).addClass('loading');

        // Create a form and submit it (this way handles large datasets better than AJAX)
        var $form = $('<form>', {
            'method': 'post',
            'action': ajaxurl
        });

        $form.append($('<input>', {
            'type': 'hidden',
            'name': 'action',
            'value': 'mxchat_export_transcripts'
        }));

        $form.append($('<input>', {
            'type': 'hidden',
            'name': 'security',
            'value': mxchatAdmin.export_nonce
        }));

        $form.appendTo('body').submit();

        // Re-enable the button after a short delay
        setTimeout(function() {
            $button.prop('disabled', false).removeClass('loading');
        }, 2000);
    });
    
    
});

```
