bluesky-Connector/assets/js/admin.js
2024-11-21 01:05:37 -08:00

64 lines
1.9 KiB
JavaScript

jQuery(document).ready(function($) {
// Retry posting to Bluesky
$('.bluesky-retry-post').on('click', function(e) {
e.preventDefault();
var button = $(this);
var postId = button.data('post-id');
button.prop('disabled', true);
$.ajax({
url: ajaxurl,
type: 'POST',
data: {
action: 'bluesky_retry_post',
post_id: postId,
nonce: blueskyAdmin.nonce
},
success: function(response) {
if (response.success) {
location.reload();
} else {
alert(response.data.message || 'Error retrying post');
button.prop('disabled', false);
}
},
error: function() {
alert('Network error. Please try again.');
button.prop('disabled', false);
}
});
});
// Share post to Bluesky
$('.bluesky-share-post').on('click', function(e) {
e.preventDefault();
var button = $(this);
var postId = button.data('post-id');
button.prop('disabled', true);
$.ajax({
url: ajaxurl,
type: 'POST',
data: {
action: 'bluesky_share_post',
post_id: postId,
nonce: blueskyAdmin.nonce
},
success: function(response) {
if (response.success) {
location.reload();
} else {
alert(response.data.message || 'Error sharing post');
button.prop('disabled', false);
}
},
error: function() {
alert('Network error. Please try again.');
button.prop('disabled', false);
}
});
});
});