@@ -92,7 +92,6 @@ let minFrequency = Number.MAX_SAFE_INTEGER;
92
92
let maxFrequency = 0 ;
93
93
94
94
95
-
96
95
async function updateFrequency ( selectedFrequency : string ) {
97
96
// Clear the existing table
98
97
const table = document . getElementById ( 'solutionTable' ) as HTMLTableElement ;
@@ -237,6 +236,56 @@ function rebuildTable() {
237
236
} ) ;
238
237
}
239
238
239
+ async function addCompaniesToSelect ( ) {
240
+ const companySearch = document . getElementById ( 'companySearch' ) as HTMLInputElement ;
241
+ const companyList = document . getElementById ( 'companyList' ) as HTMLDataListElement ;
242
+ let companies = [ ] ;
243
+
244
+ const data = await new Promise < { companyProblems : any } > ( ( resolve ) => {
245
+ chrome . storage . local . get ( 'companyProblems' , function ( data ) {
246
+ resolve ( data ) ;
247
+ } ) ;
248
+ } ) ;
249
+
250
+ const companyProblems = data . companyProblems ;
251
+ // Add all the keys to the set
252
+ Object . keys ( companyProblems ) . forEach ( ( company ) => {
253
+ if ( company ) {
254
+ companies . push ( company ) ;
255
+ }
256
+ } ) ;
257
+
258
+ // Event when the "Enter" key is pressed or an option is selected from the dropdown
259
+ const handleSelection = ( ) => {
260
+ const inputValue = companySearch . value ;
261
+ // Find the selected company in a case-insensitive manner
262
+ const selectedCompany = Array . from ( companies ) . find (
263
+ ( company ) => company . toLowerCase ( ) === inputValue . toLowerCase ( )
264
+ ) ;
265
+ if ( selectedCompany ) {
266
+ chrome . storage . local . set ( { clickedCompany : selectedCompany } , ( ) => {
267
+ location . reload ( ) ;
268
+ } ) ;
269
+ }
270
+ } ;
271
+
272
+ companySearch . addEventListener ( 'keydown' , ( event ) => {
273
+ if ( event . key === 'Enter' ) {
274
+ handleSelection ( ) ;
275
+ }
276
+ } ) ;
277
+
278
+ companySearch . addEventListener ( 'change' , handleSelection ) ;
279
+
280
+ const sortedCompanies = companies . sort ( ) ;
281
+
282
+ sortedCompanies . forEach ( ( company ) => {
283
+ const option = document . createElement ( 'option' ) ;
284
+ option . value = company ;
285
+ companyList . appendChild ( option ) ;
286
+ } ) ;
287
+ }
288
+
240
289
241
290
// Keep track of the sorting order for each column
242
291
const sortOrders = {
0 commit comments