-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwp-server-log-viewer.js
More file actions
65 lines (59 loc) · 1.72 KB
/
wp-server-log-viewer.js
File metadata and controls
65 lines (59 loc) · 1.72 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
'use strict';
(function($) {
$(window).load(function() {
// auto-scroll to bottom of log viewers on page load
$('.log-table-view').each(function() {
$(this).scrollTop($('table', this).height())
});
$('.page-title-action').click(function(e) {
e.preventDefault();
$('#log-dialog').dialog('open');
});
$('#log-dialog').dialog({
title: 'Add New Log',
dialogClass: 'wp-dialog',
autoOpen: false,
draggable: false,
width: 'auto',
modal: true,
resizable: false,
closeOnEscape : true,
position: {
my: "center",
at: "center",
of: window
},
create: function(){
$('.ui-dialog-titlebar-close').addClass('ui-button');
},
open: function(){
$('.ui-widget-overlay').bind('click',function(){
$('#log-dialog').dialog('close');
})
}
});
});
$('.log-table-view').on('scroll', function(e) {
var $this = $(this);
if( 0 == $this.scrollTop() && 0 == $this.find('.overlay').length ) {
var $overlay = $('<div class="overlay"><div>');
$this.append( $overlay );
// load more lines
var offset = $('td', this).length;
var payload = {
'action': 'fetch_log_rows',
'logfile': $this.data('logfile'),
'offset': $('td', this).length,
'regex': $this.data('regex'),
'cutoff_bytes': $this.data('logbytes')
};
console.log(payload);
$.post(window.ajaxurl, payload, function(response) {
var oldheight = $('table', $this).height();
$('tbody', $this).prepend(response);
$this.scrollTop($('table', $this).height() - oldheight);
$overlay.remove();
});
}
});
})(jQuery);