File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ <h1>Honda OBD0/1 ECU Component List</h1>
28
28
</ header >
29
29
< main >
30
30
< h2 > Components</ h2 >
31
+ < div id ="search-container ">
32
+ < input type ="search " id ="componentSearch " placeholder ="Search components... ">
33
+ < small > Search by ID, type, specs or notes</ small >
34
+ </ div >
31
35
< div id ="table-container ">
32
36
< table >
33
37
< thead >
Original file line number Diff line number Diff line change @@ -84,4 +84,15 @@ fetch('./hondaecucomponents.json')
84
84
credits . appendChild ( li ) ;
85
85
} ) ;
86
86
}
87
- } ) . catch ( err => console . error ( 'Failed to load components:' , err ) ) ;
87
+ } ) . catch ( err => console . error ( 'Failed to load components:' , err ) ) ;
88
+
89
+ document . getElementById ( 'componentSearch' ) . addEventListener ( 'input' , e => {
90
+ const searchTerm = e . target . value . toLowerCase ( ) ;
91
+ const componentGroups = document . getElementsByClassName ( 'component-group' ) ;
92
+
93
+ Array . from ( componentGroups ) . forEach ( tbody => {
94
+ const searchText = [ ...Array . from ( tbody . querySelector ( '.component-row' ) . children ) . map ( cell => cell . dataset . original || cell . textContent ) , tbody . querySelector ( '.notes-cell' ) ?. textContent || '' ] . join ( ' ' ) . toLowerCase ( ) ;
95
+
96
+ tbody . style . display = searchText . includes ( searchTerm ) ? '' : 'none' ;
97
+ } ) ;
98
+ } ) ;
Original file line number Diff line number Diff line change 84
84
position : static;
85
85
text-transform : uppercase;
86
86
}
87
+
88
+ # search-container { display : none; }
87
89
}
88
90
89
91
.component-group {
@@ -142,4 +144,24 @@ th {
142
144
143
145
.honda-link {
144
146
color : var (--honda-red );
147
+ }
148
+
149
+ # search-container {
150
+ margin : 1rem 0 ;
151
+ }
152
+
153
+ # componentSearch {
154
+ width : 100% ;
155
+ max-width : 300px ;
156
+ padding : 0.5rem ;
157
+ border : 1px solid # d1d5db ;
158
+ border-radius : 0.25rem ;
159
+ font-size : 1rem ;
160
+ }
161
+
162
+ # search-container small {
163
+ display : block;
164
+ margin-top : 0.25rem ;
165
+ color : # 4b5563 ;
166
+ font-size : 0.75rem ;
145
167
}
You can’t perform that action at this time.
0 commit comments