Skip to content

Commit ac2ff6a

Browse files
committed
align search and date filter, fix functionality
1 parent d5ad2f6 commit ac2ff6a

File tree

3 files changed

+34
-27
lines changed

3 files changed

+34
-27
lines changed

src/problems-by-company/company.css

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ body {
1313
}
1414

1515
h1 {
16-
font-size: 36px;
17-
margin-bottom: 20px;
16+
font-size: 30px;
1817
color: lightcyan;
1918
}
2019

@@ -90,9 +89,22 @@ select {
9089
padding: 5px;
9190
}
9291

93-
#companySearch {
92+
#dateSelect {
93+
color: #fff;
9494
background-color: #373737;
95+
border: '2px solid white';
96+
width: 150px;
97+
height: 35px;
98+
margin-left: 10px;
99+
border-radius: 5px;
100+
}
101+
102+
#companySearch {
95103
color: #fff;
96-
padding: 5px;
97-
margin-bottom: 20px;
104+
background-color: #373737;
105+
border: '2px solid white';
106+
width: 250px;
107+
height: 30px;
108+
border-radius: 5px;
109+
text-align: center;
98110
}

src/problems-by-company/company.html

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<nav id="navbar">
1111
</nav>
1212
<div class="row">
13-
<input type="text" id="companySearch" list="companyList" placeholder="Search for a company...">
13+
<input type="text" id="companySearch" list="companyList" placeholder="Search for a company">
1414
<datalist id="companyList"></datalist>
1515
<select id="dateSelect">
1616
<option value="freq_6months">6 months</option>
@@ -20,16 +20,10 @@
2020
</select>
2121
</div>
2222
<h1 id="title">Amazon</h1>
23-
<p>
24-
<span id="score">Score</span> = The number of times the question was asked between 2021-2023
25-
</p>
2623
<table id="solutionTable">
2724
<tr>
2825
<th id="#" class="header">#</th>
29-
<!-- <th id="Difficulty" class="header">Difficulty</th> -->
3026
<th id="Title" class="header">Title</th>
31-
<!-- <th id="Score" class="header">Score</th> -->
32-
<!-- <th id="Acceptance" class="header">Acceptance</th> -->
3327
<th id="Frequency" class="header">Frequency</th>
3428
</tr>
3529
</table>

src/problems-by-company/company.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -200,28 +200,28 @@ async function addCompaniesToSelect() {
200200
}
201201
});
202202

203-
// Event when the "Enter" key is pressed
204-
companySearch.addEventListener('keydown', (event) => {
205-
if (event.key === 'Enter') {
206-
const selectedCompany = companySearch.value;
207-
if (selectedCompany) {
208-
chrome.storage.local.set({ clickedCompany: selectedCompany }, () => {
209-
location.reload();
210-
});
211-
}
212-
}
213-
});
214-
215-
// Event when an option is selected from the dropdown
216-
companySearch.addEventListener('change', () => {
217-
const selectedCompany = companySearch.value;
203+
// Event when the "Enter" key is pressed or an option is selected from the dropdown
204+
const handleSelection = () => {
205+
const inputValue = companySearch.value;
206+
// Find the selected company in a case-insensitive manner
207+
const selectedCompany = Array.from(uniqueCompanies).find(
208+
(company) => company.toLowerCase() === inputValue.toLowerCase()
209+
);
218210
if (selectedCompany) {
219211
chrome.storage.local.set({ clickedCompany: selectedCompany }, () => {
220212
location.reload();
221213
});
222214
}
215+
};
216+
217+
companySearch.addEventListener('keydown', (event) => {
218+
if (event.key === 'Enter') {
219+
handleSelection();
220+
}
223221
});
224222

223+
companySearch.addEventListener('change', handleSelection);
224+
225225
// Convert the Set to an Array and sort it alphabetically
226226
const sortedCompanies = Array.from(uniqueCompanies).sort();
227227

@@ -232,6 +232,7 @@ async function addCompaniesToSelect() {
232232
});
233233
}
234234

235+
235236
// Keep track of the sorting order for each column
236237
const sortOrders = {
237238
'#': false,

0 commit comments

Comments
 (0)