| 1 |
jQuery(document).ready(function($) { |
| 2 |
$('#mxchat-select-all-transcripts').click(function() { |
| 3 |
var checkedStatus = this.checked; |
| 4 |
$('#mxchat-transcripts').find('input[type=checkbox]').each(function() { |
| 5 |
$(this).prop('checked', checkedStatus); |
| 6 |
}); |
| 7 |
}); |
| 8 |
|
| 9 |
$.ajax({ |
| 10 |
url: ajaxurl, |
| 11 |
type: 'POST', |
| 12 |
data: { |
| 13 |
action: 'mxchat_fetch_chat_history' |
| 14 |
}, |
| 15 |
success: function(response) { |
| 16 |
$('#mxchat-transcripts').html(response); |
| 17 |
} |
| 18 |
}); |
| 19 |
|
| 20 |
$('#mxchat-delete-form').submit(function(e) { |
| 21 |
e.preventDefault(); |
| 22 |
var checkedSessionIds = $('input[name="delete_session_ids[]"]:checked').map(function() { |
| 23 |
return $(this).val(); |
| 24 |
}).get(); |
| 25 |
$.ajax({ |
| 26 |
url: ajaxurl, |
| 27 |
type: 'POST', |
| 28 |
data: { |
| 29 |
action: 'mxchat_delete_chat_history', |
| 30 |
delete_session_ids: checkedSessionIds, |
| 31 |
security: $('#mxchat_delete_chat_nonce').val() |
| 32 |
}, |
| 33 |
success: function(response) { |
| 34 |
var jsonResponse = JSON.parse(response); |
| 35 |
if (jsonResponse.success) { |
| 36 |
alert("Success: " + jsonResponse.success); |
| 37 |
} else if (jsonResponse.error) { |
| 38 |
alert("Error: " + jsonResponse.error); |
| 39 |
} else { |
| 40 |
//console.log("Unexpected response format."); |
| 41 |
} |
| 42 |
location.reload(); |
| 43 |
}, |
| 44 |
error: function(xhr, status, error) { |
| 45 |
//console.error("AJAX Error: " + status + " - " + error); |
| 46 |
//console.log(xhr.responseText); |
| 47 |
} |
| 48 |
}); |
| 49 |
}); |
| 50 |
}); |
| 51 |
|