Speed up log highlight

Allow reverse selection
This commit is contained in:
Ruud
2014-05-11 00:52:55 +02:00
parent 4ff2794c83
commit 33e5dd1fdb
+15 -6
View File
@@ -7,6 +7,7 @@ Page.Log = new Class({
title: 'Show recent logs.', title: 'Show recent logs.',
has_tab: false, has_tab: false,
log_items: [],
report_text: '\ report_text: '\
### Steps to reproduce:\n\ ### Steps to reproduce:\n\
1. ..\n\ 1. ..\n\
@@ -48,7 +49,8 @@ Running on: ...\n\
}, },
'onComplete': function (json) { 'onComplete': function (json) {
self.log.set('text', ''); self.log.set('text', '');
self.log.adopt(self.createLogElements(json.log)); self.log_items = self.createLogElements(json.log);
self.log.adopt(self.log_items);
self.log.removeClass('loading'); self.log.removeClass('loading');
var nav = new Element('ul.nav', { var nav = new Element('ul.nav', {
@@ -160,13 +162,20 @@ Running on: ...\n\
if(parent_start) if(parent_start)
start_node = parent_start; start_node = parent_start;
var nodes = [start_node], var index = {
current_node = start_node; 'start': self.log_items.indexOf(start_node),
'end': self.log_items.indexOf(end_node)
};
while(current_node != end_node){ if(index.start > index.end){
current_node = current_node.getNext('.time'); index = {
nodes.include(current_node); 'start': index.end,
'end': index.start
};
} }
var nodes = self.log_items.slice(index.start, index.end + 1);
nodes.each(function(node, nr){ nodes.each(function(node, nr){
node.addClass('highlight'); node.addClass('highlight');
node.getElements('span').each(function(span){ node.getElements('span').each(function(span){