| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * EventsView displays a filtered list of all events sharing a source, and | 6 * EventsView displays a filtered list of all events sharing a source, and |
| 7 * a details pane for the selected sources. | 7 * a details pane for the selected sources. |
| 8 * | 8 * |
| 9 * +----------------------++----------------+ | 9 * +----------------------++----------------+ |
| 10 * | filter box || | | 10 * | filter box || | |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 * Returns |filterText| with all recognized directives removed. | 278 * Returns |filterText| with all recognized directives removed. |
| 279 */ | 279 */ |
| 280 parseStringDirectives_: function(filterText, filter) { | 280 parseStringDirectives_: function(filterText, filter) { |
| 281 var directives = ['type', 'id']; | 281 var directives = ['type', 'id']; |
| 282 for (var i = 0; i < directives.length; ++i) { | 282 for (var i = 0; i < directives.length; ++i) { |
| 283 while (true) { | 283 while (true) { |
| 284 var directive = directives[i]; | 284 var directive = directives[i]; |
| 285 var filterInfo = this.parseDirective_(filterText, directive); | 285 var filterInfo = this.parseDirective_(filterText, directive); |
| 286 if (filterInfo == null) | 286 if (filterInfo == null) |
| 287 break; | 287 break; |
| 288 if (!filter[directive]) | 288 |
| 289 filter[directive] = []; | 289 // Split parameters around commas and remove empty elements. |
| 290 filter[directive].push(filterInfo.parameter); | 290 var parameters = filterInfo.parameter.split(','); |
| 291 parameters = parameters.filter(function(string) { |
| 292 return string.length > 0; |
| 293 }); |
| 294 |
| 295 // If there's already a matching filter, take the intersection. |
| 296 // This behavior primarily exists for tests. It is not correct |
| 297 // when one of the 'type' filters is a partial match. |
| 298 if (filter[directive]) { |
| 299 parameters = parameters.filter(function(string) { |
| 300 return filter[directive].indexOf(string) != -1; |
| 301 }); |
| 302 } |
| 303 |
| 304 filter[directive] = parameters; |
| 291 filterText = filterInfo.remainingText; | 305 filterText = filterInfo.remainingText; |
| 292 } | 306 } |
| 293 } | 307 } |
| 294 return filterText; | 308 return filterText; |
| 295 }, | 309 }, |
| 296 | 310 |
| 297 /* | 311 /* |
| 298 * Converts |filterText| into an object representing the filter. | 312 * Converts |filterText| into an object representing the filter. |
| 299 */ | 313 */ |
| 300 createFilter_: function(filterText) { | 314 createFilter_: function(filterText) { |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 var source1Text = source1.getSourceTypeString(); | 689 var source1Text = source1.getSourceTypeString(); |
| 676 var source2Text = source2.getSourceTypeString(); | 690 var source2Text = source2.getSourceTypeString(); |
| 677 var compareResult = source1Text.localeCompare(source2Text); | 691 var compareResult = source1Text.localeCompare(source2Text); |
| 678 if (compareResult != 0) | 692 if (compareResult != 0) |
| 679 return compareResult; | 693 return compareResult; |
| 680 return compareSourceId(source1, source2); | 694 return compareSourceId(source1, source2); |
| 681 } | 695 } |
| 682 | 696 |
| 683 return EventsView; | 697 return EventsView; |
| 684 })(); | 698 })(); |
| OLD | NEW |