You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
1.5 KiB
75 lines
1.5 KiB
Page.Log = new Class({
|
|
|
|
Extends: PageBase,
|
|
|
|
name: 'log',
|
|
title: 'Show recent logs.',
|
|
|
|
indexAction: function(){
|
|
var self = this;
|
|
|
|
self.getLogs(0);
|
|
|
|
},
|
|
|
|
getLogs: function(nr){
|
|
var self = this;
|
|
|
|
if(self.log) self.log.destroy();
|
|
self.log = new Element('div.container.loading', {
|
|
'text': 'loading...'
|
|
}).inject(self.el);
|
|
|
|
Api.request('logging.get', {
|
|
'data': {
|
|
'nr': nr
|
|
},
|
|
'onComplete': function(json){
|
|
self.log.set('html', self.addColors(json.log));
|
|
self.log.removeClass('loading');
|
|
|
|
new Fx.Scroll(window, {'duration': 0}).toBottom();
|
|
|
|
var nav = new Element('ul.nav').inject(self.log, 'top');
|
|
for (var i = 0; i < json.total; i++) {
|
|
new Element('li', {
|
|
'text': i+1,
|
|
'class': nr == i ? 'active': '',
|
|
'events': {
|
|
'click': function(e){
|
|
self.getLogs(e.target.get('text')-1);
|
|
}
|
|
}
|
|
}).inject(nav);
|
|
};
|
|
|
|
new Element('li', {
|
|
'text': 'clear',
|
|
'events': {
|
|
'click': function(){
|
|
Api.request('logging.clear', {
|
|
'onComplete': function(){
|
|
self.getLogs(0);
|
|
}
|
|
});
|
|
|
|
}
|
|
}
|
|
}).inject(nav)
|
|
}
|
|
});
|
|
|
|
},
|
|
|
|
addColors: function(text){
|
|
var self = this;
|
|
|
|
text = text.replace(/\u001b\[31m/gi, '</span><span class="error">')
|
|
text = text.replace(/\u001b\[36m/gi, '</span><span class="debug">')
|
|
text = text.replace(/\u001b\[0m\n/gi, '</span><span class="time">')
|
|
text = text.replace(/\u001b\[0m/gi, '</span><span>')
|
|
|
|
return '<span class="time">' + text + '</span>';
|
|
}
|
|
|
|
})
|