| 1 |
/* |
| 2 |
* Licensed to the Apache Software Foundation (ASF) under one |
| 3 |
* or more contributor license agreements. See the NOTICE file |
| 4 |
* distributed with this work for additional information |
| 5 |
* regarding copyright ownership. The ASF licenses this file |
| 6 |
* to you under the Apache License, Version 2.0 (the |
| 7 |
* "License"); you may not use this file except in compliance |
| 8 |
* with the License. You may obtain a copy of the License at |
| 9 |
* |
| 10 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
* |
| 12 |
* Unless required by applicable law or agreed to in writing, |
| 13 |
* software distributed under the License is distributed on an |
| 14 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 |
* KIND, either express or implied. See the License for the |
| 16 |
* specific language governing permissions and limitations |
| 17 |
* under the License. |
| 18 |
*/ |
| 19 |
|
| 20 |
var htrace = htrace || {}; |
| 21 |
|
| 22 |
// A pair of span trees: one going up, and the other going down. |
| 23 |
// This represents a single search result. |
| 24 |
htrace.SearchResult = Backbone.Model.extend({ |
| 25 |
initialize: function(options) { |
| 26 |
this.set("childrenRoot", { |
| 27 |
root: options.span, |
| 28 |
contents: null, |
| 29 |
}); |
| 30 |
this.set("childrenRoot", { |
| 31 |
root: options.span, |
| 32 |
contents: null, |
| 33 |
}); |
| 34 |
|
| 35 |
this.set("parentsRoot", options.span); |
| 36 |
}, |
| 37 |
|
| 38 |
getBegin: function() { |
| 39 |
var begin = this.get("span").get("begin"); |
| 40 |
var children = this.get("children"); |
| 41 |
for (var childIdx = 0; childIdx < children.length; childIdx++) { |
| 42 |
begin = Math.min(begin, children[childIdx].getBegin()); |
| 43 |
} |
| 44 |
return begin; |
| 45 |
}, |
| 46 |
|
| 47 |
getEnd: function() { |
| 48 |
var end = this.get("span").get("end"); |
| 49 |
var children = this.get("children"); |
| 50 |
for (var childIdx = 0; childIdx < children.length; childIdx++) { |
| 51 |
end = Math.max(end, children[childIdx].getEnd()); |
| 52 |
} |
| 53 |
return end; |
| 54 |
} |
| 55 |
}); |