jQuery(document).ready(function($) { $('#mxchat-activation-form').on('submit', function(event) { event.preventDefault(); var formData = { action: 'mxchat_activate_license', email: $('#mxchat_pro_email').val(), key: $('#mxchat_activation_key').val(), security: mxchatAdmin.nonce }; $.post(mxchatAdmin.ajax_url, formData, function(response) { if (response.success) { $('#mxchat-license-status').text('Active'); } else { $('#mxchat-license-status').text('Inactive'); alert(response.data); } }); }); $('.mxchat-nav-tab').on('click', function(e) { e.preventDefault(); $('.mxchat-nav-tab').removeClass('mxchat-nav-tab-active'); $(this).addClass('mxchat-nav-tab-active'); $('.mxchat-tab-content').removeClass('active').hide(); var activeTab = $(this).attr('href'); $(activeTab).addClass('active').show(); }); // Activate the first tab by default $('.mxchat-nav-tab-active').trigger('click'); // Toggle visibility of API key $('#toggleApiKeyVisibility').on('click', function() { var apiKeyInput = $('#api_key'); if (apiKeyInput.attr('type') === 'password') { apiKeyInput.attr('type', 'text'); $(this).text('Hide'); } else { apiKeyInput.attr('type', 'password'); $(this).text('Show'); } }); // Toggle visibility of WooCommerce Consumer Secret $('#toggleWooCommerceSecretVisibility').on('click', function() { var secretInput = $('#woocommerce_consumer_secret'); if (secretInput.attr('type') === 'password') { secretInput.attr('type', 'text'); $(this).text('Hide'); } else { secretInput.attr('type', 'password'); $(this).text('Show'); } }); // Toggle visibility of Loops API Key $('#toggleLoopsApiKeyVisibility').on('click', function() { var loopsApiKeyInput = $('#loops_api_key'); if (loopsApiKeyInput.attr('type') === 'password') { loopsApiKeyInput.attr('type', 'text'); $(this).text('Hide'); } else { loopsApiKeyInput.attr('type', 'password'); $(this).text('Show'); } }); // Toggle visibility of X.AI API Key $('#toggleXaiApiKeyVisibility').on('click', function() { var xaiApiKeyInput = $('#xai_api_key'); if (xaiApiKeyInput.attr('type') === 'password') { xaiApiKeyInput.attr('type', 'text'); $(this).text('Hide'); } else { xaiApiKeyInput.attr('type', 'password'); $(this).text('Show'); } }); });