-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmapping-of-image-posts.js
executable file
·50 lines (44 loc) · 1.31 KB
/
mapping-of-image-posts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
jQuery(document).ready(function($) {
var messages = $('#messages');
var pos = 0;
var alter = 1;
function update() {
$.ajax( ajaxurl, {
type : 'POST',
async : true,
data : { action: 'mapping_of_image_posts', pos: pos },
success : function( response ) {
alter++;
alternate = '';
if ( ( alter % 2 ) == 0 ) alternate = ' class="alternate"';
var e = $('<div'+alternate+'></div>');
if ( 'finish' == response.status ) {
e = $('<div'+alternate+'></div>');
$('#moip_loader').hide();
$('#moip_download_file').show();
}
if (response.status == 'error') {
e.addClass('error').text(response.message);
} else {
pos = response.data;
if (response.status != 'finish') update();
if ( response.message ) {
e.text(response.message);
messages.append(e);
}
}
if (response.status == 'finish') {
e = $('<div class="row-title"></div>').text('Number of unique images written: ' + response.data);
messages.append(e);
}
},
error: function() {
}
});
}
$('#moip_start').click( function() {
$(this).attr('disabled',true);
$('#moip_loader').show();
update();
});
});