| @@ -65,5 +65,41 @@ | ||
| 65 | 65 | //console.log(xhr.responseText); |
| 66 | 66 | } |
| 67 | 67 | }); |
| 68 | 68 | }); |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + // Export functionality | |
| 74 | + $('#mxchat-export-transcripts').on('click', function() { | |
| 75 | + var $button = $(this); | |
| 76 | + $button.prop('disabled', true).addClass('loading'); | |
| 77 | + | |
| 78 | + // Create a form and submit it (this way handles large datasets better than AJAX) | |
| 79 | + var $form = $('<form>', { | |
| 80 | + 'method': 'post', | |
| 81 | + 'action': ajaxurl | |
| 82 | + }); | |
| 83 | + | |
| 84 | + $form.append($('<input>', { | |
| 85 | + 'type': 'hidden', | |
| 86 | + 'name': 'action', | |
| 87 | + 'value': 'mxchat_export_transcripts' | |
| 88 | + })); | |
| 89 | + | |
| 90 | + $form.append($('<input>', { | |
| 91 | + 'type': 'hidden', | |
| 92 | + 'name': 'security', | |
| 93 | + 'value': mxchatAdmin.export_nonce | |
| 94 | + })); | |
| 95 | + | |
| 96 | + $form.appendTo('body').submit(); | |
| 97 | + | |
| 98 | + // Re-enable the button after a short delay | |
| 99 | + setTimeout(function() { | |
| 100 | + $button.prop('disabled', false).removeClass('loading'); | |
| 101 | + }, 2000); | |
| 102 | + }); | |
| 103 | + | |
| 104 | + | |
| 69 | 105 | }); |