Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions coverage/htmlfiles/coverage_html.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ coverage.assign_shortkeys = function () {

// Create the events for the filter box.
coverage.wire_up_filter = function () {
// Populate the filter and hide inputs if there are saved values for them
const saved_filter_value = localStorage.getItem(coverage.FILTER_STORAGE);
if (saved_filter_value) {
document.getElementById("filter").value = saved_filter_value;
}
const saved_hide100_value = localStorage.getItem(coverage.HIDE_STORAGE);
if (saved_hide100_value) {
document.getElementById("hide100").checked = JSON.parse(saved_hide100_value);
}

// Cache elements.
const table = document.querySelector("table.index");
const table_body_rows = table.querySelectorAll("tbody tr");
Expand All @@ -138,8 +148,12 @@ coverage.wire_up_filter = function () {
totals[totals.length - 1] = { "numer": 0, "denom": 0 }; // nosemgrep: eslint.detect-object-injection

var text = document.getElementById("filter").value;
// Store filter value
localStorage.setItem(coverage.FILTER_STORAGE, text);
const casefold = (text === text.toLowerCase());
const hide100 = document.getElementById("hide100").checked;
// Store hide value
localStorage.setItem(coverage.HIDE_STORAGE, JSON.stringify(hide100));

// Hide / show elements.
table_body_rows.forEach(row => {
Expand Down Expand Up @@ -240,6 +254,8 @@ coverage.wire_up_filter = function () {
document.getElementById("filter").dispatchEvent(new Event("input"));
document.getElementById("hide100").dispatchEvent(new Event("input"));
};
coverage.FILTER_STORAGE = "COVERAGE_FILTER_VALUE";
coverage.HIDE_STORAGE = "COVERAGE_HIDE_VALUE";

// Set up the click-to-sort columns.
coverage.wire_up_sorting = function () {
Expand Down