coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:13 -0300
diff --git a/coverage/htmlfiles/coverage_html.js b/coverage/htmlfiles/coverage_html.js index a28c1bef8..0a859a537 100644 --- a/coverage/htmlfiles/coverage_html.js +++ b/coverage/htmlfiles/coverage_html.js @@ -81,7 +81,32 @@ function sortColumn(th) { .forEach(tr => tr.parentElement.appendChild(tr)); // Save the sort order for next time. - localStorage.setItem(coverage.INDEX_SORT_STORAGE, JSON.stringify({column, direction})); + if (th.id !== "region") { + let th_id = "file"; // Sort by file if we don't have a column id + let current_direction = direction; + const stored_list = localStorage.getItem(coverage.INDEX_SORT_STORAGE); + if (stored_list) { + ({th_id, direction} = JSON.parse(stored_list)) + } + localStorage.setItem(coverage.INDEX_SORT_STORAGE, JSON.stringify({ + "th_id": th.id, + "direction": current_direction + })); + if (th.id !== th_id || document.getElementById("region")) { + // Sort column has changed, unset sorting by function or class. + localStorage.setItem(coverage.SORTED_BY_REGION, JSON.stringify({ + "by_region": false, + "region_direction": current_direction + })); + } + } + else { + // Sort column has changed to by function or class, remember that. + localStorage.setItem(coverage.SORTED_BY_REGION, JSON.stringify({ + "by_region": true, + "region_direction": direction + })); + } } // Find all the elements with data-shortcut attribute, and use them to assign a shortcut key. @@ -223,18 +248,39 @@ coverage.wire_up_sorting = function () { ); // Look for a localStorage item containing previous sort settings: - var column = 0, direction = "ascending"; + let th_id = "file", direction = "ascending"; const stored_list = localStorage.getItem(coverage.INDEX_SORT_STORAGE); if (stored_list) { - ({column, direction} = JSON.parse(stored_list)); + ({th_id, direction} = JSON.parse(stored_list)); + } + let by_region = false, region_direction = "ascending"; + const sorted_by_region = localStorage.getItem(coverage.SORTED_BY_REGION); + if (sorted_by_region) { + ({ + by_region, + region_direction + } = JSON.parse(sorted_by_region)); } - const th = document.querySelector("[data-sortable]").tHead.rows[0].cells[column]; // nosemgrep: eslint.detect-object-injection + const region_id = "region"; + if (by_region && document.getElementById(region_id)) { + direction = region_direction; + } + // If we are in a page that has a column with id of "region", sort on + // it if the last sort was by function or class. + let th; + if (document.getElementById(region_id)) { + th = document.getElementById(by_region ? region_id : th_id); + } + else { + th = document.getElementById(th_id); + } th.setAttribute("aria-sort", direction === "ascending" ? "descending" : "ascending"); th.click() }; coverage.INDEX_SORT_STORAGE = "COVERAGE_INDEX_SORT_2"; +coverage.SORTED_BY_REGION = "COVERAGE_SORT_REGION"; // Loaded on index.html coverage.index_ready = function () { diff --git a/coverage/htmlfiles/index.html b/coverage/htmlfiles/index.html index 2c1dee02f..f75d18b43 100644 --- a/coverage/htmlfiles/index.html +++ b/coverage/htmlfiles/index.html @@ -82,18 +82,18 @@
coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:13 -0300
File | -class | -statements | -missing | -excluded | -coverage | +File | +class | +statements | +missing | +excluded | +coverage |
---|