admin.js
2.96 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
(function($){
$(function(){
// make some checkboxes behave like radio boxes
$('input.jsprocessor').on('change', function() {
$('input.jsprocessor').not(this).prop('checked', false);
});
// disable collapse
$('.postbox h3, .postbox .handlediv').unbind('click.postboxes');
// variables
var $fastvelocity_min_processed = $('#fastvelocity_min_processed'),
$fastvelocity_min_jsprocessed = $('#fastvelocity_min_jsprocessed',$fastvelocity_min_processed),
$fastvelocity_min_jsprocessed_ul = $('ul',$fastvelocity_min_jsprocessed),
$fastvelocity_min_cssprocessed = $('#fastvelocity_min_cssprocessed',$fastvelocity_min_processed),
$fastvelocity_min_cssprocessed_ul = $('ul',$fastvelocity_min_cssprocessed),
$fastvelocity_min_noprocessed = $('#fastvelocity_min_noprocessed'),
timeout = null,
stamp = null;
$($fastvelocity_min_processed).on('click','.log',function(e){
e.preventDefault();
$(this).parent().nextAll('pre').slideToggle();
});
$($fastvelocity_min_processed).on('click','.purge',function(e){
e.preventDefault();
getFiles({purge:$(this).attr('href').substr(1)});
$(this).parent().parent().remove();
});
function getFiles(extra) {
stamp = new Date().getTime();
var data = {
'action': 'fastvelocity_min_files',
'stamp': stamp
};
if(extra) {
for (var attrname in extra) { data[attrname] = extra[attrname]; }
}
$.post(ajaxurl, data, function(response) {
if(stamp == response.stamp) {
if(response.js.length > 0) {
$fastvelocity_min_jsprocessed.show();
$(response.js).each(function(){
var $li = $fastvelocity_min_jsprocessed_ul.find('li.'+this.hash);
if($li.length > 0) {
if($li.find('pre').html() != this.log) {
$li.find('pre').html(this.log);
}
} else {
$fastvelocity_min_jsprocessed_ul.append('<li class="'+this.hash+'"><span class="filename">'+this.filename+'</span> <span class="actions"><a href="#" class="log button button-primary">View Log</a> <a href="#'+this.hash+'" class="button button-secondary purge">Delete</a></span><pre>'+this.log+'</pre></li><div class="clear"></div>');
}
});
}
if(response.css.length > 0) {
$(response.css).each(function(){
var $li = $fastvelocity_min_cssprocessed_ul.find('li.'+this.hash);
if($li.length > 0) {
if($li.find('pre').html() != this.log) {
$li.find('pre').html(this.log);
}
} else {
$fastvelocity_min_cssprocessed_ul.append('<li class="'+this.hash+'"><span class="filename">'+this.filename+'</span> <span class="actions"><a href="#" class="log button button-primary">View Log</a> <a href="#'+this.hash+'" class="button button-secondary purge">Delete</a></span><pre>'+this.log+'</pre></li><div class="clear"></div>');
}
});
}
// check for new files
timeout = setTimeout(getFiles, 2500);
}
});
}
getFiles();
});
})(jQuery);