* Sorts array of DOM elements by its depth in DOM tree. * @param {HTMLElement[]} arr - array to sort. * @param {boolean} descending - order of sort.
(arr, descending)
| 138 | * @param {boolean} descending - order of sort. |
| 139 | */ |
| 140 | function sortByDepth(arr, descending) { |
| 141 | arr.sort(function (a, b) { |
| 142 | return dom(descending ? b : a).parents().length - dom(descending ? a : b).parents().length; |
| 143 | }); |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * Groups given highlights by timestamp. |