@@ -29,6 +29,13 @@ function populateFormFromURL() {
29
29
}
30
30
} ) ;
31
31
32
+ // Restore visibility toggles from URL
33
+ [ "show-boards" , "show-shields" ] . forEach ( toggle => {
34
+ if ( hashParams . has ( toggle ) ) {
35
+ document . getElementById ( toggle ) . checked = hashParams . get ( toggle ) === "true" ;
36
+ }
37
+ } ) ;
38
+
32
39
// Restore supported features from URL
33
40
if ( hashParams . has ( "features" ) ) {
34
41
const features = hashParams . get ( "features" ) . split ( "," ) ;
@@ -70,6 +77,11 @@ function updateURL() {
70
77
}
71
78
} ) ;
72
79
80
+ [ "show-boards" , "show-shields" ] . forEach ( toggle => {
81
+ const isChecked = document . getElementById ( toggle ) . checked ;
82
+ isChecked ? hashParams . delete ( toggle ) : hashParams . set ( toggle , "false" ) ;
83
+ } ) ;
84
+
73
85
// Add supported features to URL
74
86
const selectedTags = [ ...document . querySelectorAll ( '.tag' ) ] . map ( tag => tag . textContent ) ;
75
87
selectedTags . length ? hashParams . set ( "features" , selectedTags . join ( "," ) ) : hashParams . delete ( "features" ) ;
@@ -228,6 +240,16 @@ document.addEventListener("DOMContentLoaded", function () {
228
240
filterBoards ( ) ;
229
241
} ) ;
230
242
243
+ boardsToggle = document . getElementById ( "show-boards" ) ;
244
+ boardsToggle . addEventListener ( "change" , ( ) => {
245
+ filterBoards ( ) ;
246
+ } ) ;
247
+
248
+ shieldsToggle = document . getElementById ( "show-shields" ) ;
249
+ shieldsToggle . addEventListener ( "change" , ( ) => {
250
+ filterBoards ( ) ;
251
+ } ) ;
252
+
231
253
form . addEventListener ( "input" , function ( ) {
232
254
filterBoards ( ) ;
233
255
} ) ;
@@ -246,6 +268,9 @@ function resetForm() {
246
268
fillSocSeriesSelect ( ) ;
247
269
fillSocSocSelect ( ) ;
248
270
271
+ document . getElementById ( "show-boards" ) . checked = true ;
272
+ document . getElementById ( "show-shields" ) . checked = true ;
273
+
249
274
// Clear supported features
250
275
document . querySelectorAll ( '.tag' ) . forEach ( tag => tag . remove ( ) ) ;
251
276
document . getElementById ( 'tag-input' ) . value = '' ;
@@ -269,11 +294,13 @@ function filterBoards() {
269
294
const archSelect = document . getElementById ( "arch" ) . value ;
270
295
const vendorSelect = document . getElementById ( "vendor" ) . value ;
271
296
const socSocSelect = document . getElementById ( "soc" ) ;
297
+ const showBoards = document . getElementById ( "show-boards" ) . checked ;
298
+ const showShields = document . getElementById ( "show-shields" ) . checked ;
272
299
273
300
const selectedTags = [ ...document . querySelectorAll ( '.tag' ) ] . map ( tag => tag . textContent ) ;
274
301
275
302
const resetFiltersBtn = document . getElementById ( "reset-filters" ) ;
276
- if ( nameInput || archSelect || vendorSelect || socSocSelect . selectedOptions . length || selectedTags . length ) {
303
+ if ( nameInput || archSelect || vendorSelect || socSocSelect . selectedOptions . length || selectedTags . length || ! showBoards || ! showShields ) {
277
304
resetFiltersBtn . classList . remove ( "btn-disabled" ) ;
278
305
} else {
279
306
resetFiltersBtn . classList . add ( "btn-disabled" ) ;
@@ -287,17 +314,22 @@ function filterBoards() {
287
314
const boardVendor = board . getAttribute ( "data-vendor" ) || "" ;
288
315
const boardSocs = ( board . getAttribute ( "data-socs" ) || "" ) . split ( " " ) . filter ( Boolean ) ;
289
316
const boardSupportedFeatures = ( board . getAttribute ( "data-supported-features" ) || "" ) . split ( " " ) . filter ( Boolean ) ;
317
+ const isShield = board . classList . contains ( "shield" ) ;
290
318
291
319
let matches = true ;
292
320
293
321
const selectedSocs = [ ...socSocSelect . selectedOptions ] . map ( ( { value } ) => value ) ;
294
322
295
- matches =
296
- ! ( nameInput && ! boardName . includes ( nameInput ) ) &&
297
- ! ( archSelect && ! boardArchs . includes ( archSelect ) ) &&
298
- ! ( vendorSelect && boardVendor !== vendorSelect ) &&
299
- ( selectedSocs . length === 0 || selectedSocs . some ( ( soc ) => boardSocs . includes ( soc ) ) ) &&
300
- ( selectedTags . length === 0 || selectedTags . every ( ( tag ) => boardSupportedFeatures . includes ( tag ) ) ) ;
323
+ if ( ( isShield && ! showShields ) || ( ! isShield && ! showBoards ) ) {
324
+ matches = false ;
325
+ } else {
326
+ matches =
327
+ ! ( nameInput && ! boardName . includes ( nameInput ) ) &&
328
+ ! ( archSelect && ! boardArchs . includes ( archSelect ) ) &&
329
+ ! ( vendorSelect && boardVendor !== vendorSelect ) &&
330
+ ( selectedSocs . length === 0 || selectedSocs . some ( ( soc ) => boardSocs . includes ( soc ) ) ) &&
331
+ ( selectedTags . length === 0 || selectedTags . every ( ( tag ) => boardSupportedFeatures . includes ( tag ) ) ) ;
332
+ }
301
333
302
334
board . classList . toggle ( "hidden" , ! matches ) ;
303
335
} ) ;
0 commit comments