@@ -125,6 +125,16 @@ coverage.assign_shortkeys = function () {
125
125
126
126
// Create the events for the filter box.
127
127
coverage . wire_up_filter = function ( ) {
128
+ // Populate the filter and hide inputs if there are saved values for them
129
+ const saved_filter_value = localStorage . getItem ( coverage . FILTER_STORAGE ) ;
130
+ if ( saved_filter_value ) {
131
+ document . getElementById ( "filter" ) . value = saved_filter_value ;
132
+ }
133
+ const saved_hide100_value = localStorage . getItem ( coverage . HIDE_STORAGE ) ;
134
+ if ( saved_hide100_value ) {
135
+ document . getElementById ( "hide100" ) . checked = JSON . parse ( saved_hide100_value ) ;
136
+ }
137
+
128
138
// Cache elements.
129
139
const table = document . querySelector ( "table.index" ) ;
130
140
const table_body_rows = table . querySelectorAll ( "tbody tr" ) ;
@@ -138,8 +148,12 @@ coverage.wire_up_filter = function () {
138
148
totals [ totals . length - 1 ] = { "numer" : 0 , "denom" : 0 } ; // nosemgrep: eslint.detect-object-injection
139
149
140
150
var text = document . getElementById ( "filter" ) . value ;
151
+ // Store filter value
152
+ localStorage . setItem ( coverage . FILTER_STORAGE , text ) ;
141
153
const casefold = ( text === text . toLowerCase ( ) ) ;
142
154
const hide100 = document . getElementById ( "hide100" ) . checked ;
155
+ // Store hide value
156
+ localStorage . setItem ( coverage . HIDE_STORAGE , JSON . stringify ( hide100 ) ) ;
143
157
144
158
// Hide / show elements.
145
159
table_body_rows . forEach ( row => {
@@ -240,6 +254,8 @@ coverage.wire_up_filter = function () {
240
254
document . getElementById ( "filter" ) . dispatchEvent ( new Event ( "input" ) ) ;
241
255
document . getElementById ( "hide100" ) . dispatchEvent ( new Event ( "input" ) ) ;
242
256
} ;
257
+ coverage . FILTER_STORAGE = "COVERAGE_FILTER_VALUE" ;
258
+ coverage . HIDE_STORAGE = "COVERAGE_HIDE_VALUE" ;
243
259
244
260
// Set up the click-to-sort columns.
245
261
coverage . wire_up_sorting = function ( ) {
0 commit comments