Skip to content

Commit 592772d

Browse files
authored
(ref)
1 parent 388ce1f commit 592772d

1 file changed

Lines changed: 4 additions & 18 deletions

File tree

index.html

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
background: white;
4848
border-radius: 12px;
4949
padding: 24px;
50-
margin-bottom: 16px; /* Giảm margin để nhường chỗ cho summary */
50+
margin-bottom: 16px;
5151
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
5252
}
5353

@@ -265,11 +265,10 @@
265265
<div class="container">
266266
<div class="search-section">
267267
<div class="search-grid">
268-
<!-- HTML MỚI: Thêm ô tìm kiếm SBD -->
269268
<div class="search-item">
270269
<label for="searchSbd">Số báo danh</label>
271270
<div class="input-wrapper">
272-
<input type="text" id="searchSbd" placeholder="Nhập SBD..." pattern="[0-9]*" maxlength="6">
271+
<input type="number" id="searchSbd" placeholder="Nhập SBD..." maxlength="6">
273272
<span class="clear-input" data-target="searchSbd">×</span>
274273
</div>
275274
</div>
@@ -303,8 +302,7 @@
303302
</div>
304303
</div>
305304
</div>
306-
307-
<!-- HTML MỚI: Thêm dòng hiển thị kết quả -->
305+
308306
<div id="resultsSummary" class="results-summary"></div>
309307

310308
<div class="table-section">
@@ -354,21 +352,18 @@
354352
initElements() {
355353
this.elements = {
356354
tableBody: document.getElementById('tableBody'),
357-
// JS CẬP NHẬT
358355
searchSbd: document.getElementById('searchSbd'),
359356
searchName: document.getElementById('searchName'),
360357
searchSchool: document.getElementById('searchSchool'),
361358
searchClass: document.getElementById('searchClass'),
362359
searchTotal: document.getElementById('searchTotal'),
363360
tableHeaders: document.querySelectorAll('th[data-column]'),
364361
clearInputs: document.querySelectorAll('.clear-input'),
365-
// JS CẬP NHẬT
366362
resultsSummary: document.getElementById('resultsSummary')
367363
};
368364
}
369365

370366
initEvents() {
371-
// JS CẬP NHẬT
372367
['searchSbd', 'searchName', 'searchSchool', 'searchClass', 'searchTotal'].forEach(id => {
373368
this.elements[id].addEventListener('input', () => this.handleSearch());
374369
});
@@ -394,8 +389,6 @@
394389
const csvText = await response.text();
395390
this.parseCSV(csvText);
396391
this.filteredData = [...this.data];
397-
398-
// JS CẬP NHẬT
399392
this.updateResultsSummary();
400393
this.renderTable();
401394
} catch (error) {
@@ -438,7 +431,6 @@
438431
}
439432

440433
filterData() {
441-
// JS CẬP NHẬT
442434
const sbdFilter = this.elements.searchSbd.value.trim();
443435
const nameFilter = this.elements.searchName.value.toLowerCase().trim();
444436
const schoolFilter = this.elements.searchSchool.value.toLowerCase().trim();
@@ -449,7 +441,6 @@
449441
this.filteredData = [...this.data];
450442
} else {
451443
this.filteredData = this.data.filter(row => {
452-
// JS CẬP NHẬT
453444
return (!sbdFilter || row.sbd.includes(sbdFilter)) &&
454445
(!nameFilter || row.name.toLowerCase().includes(nameFilter)) &&
455446
(!schoolFilter || row.school.toLowerCase().includes(schoolFilter)) &&
@@ -458,12 +449,10 @@
458449
});
459450
}
460451

461-
// JS CẬP NHẬT
462452
this.updateResultsSummary();
463453
this.renderTable();
464454
}
465455

466-
// JS MỚI: Hàm cập nhật thông báo kết quả
467456
updateResultsSummary() {
468457
const filteredCount = this.filteredData.length;
469458
const totalCount = this.data.length;
@@ -526,13 +515,11 @@
526515
let r, g, b;
527516

528517
if (percentage < 50) {
529-
// Dải màu từ Đỏ (229, 62, 62) -> Vàng (245, 158, 11)
530518
const p = percentage / 50;
531519
r = Math.round(229 + p * (245 - 229));
532520
g = Math.round(62 + p * (158 - 62));
533521
b = Math.round(62 + p * (11 - 62));
534522
} else {
535-
// Dải màu từ Vàng (245, 158, 11) -> Xanh (16, 185, 129)
536523
const p = (percentage - 50) / 50;
537524
r = Math.round(245 + p * (16 - 245));
538525
g = Math.round(158 + p * (185 - 158));
@@ -562,15 +549,14 @@
562549

563550
const sortKeys = ['sbd', 'name', 'class', 'school', 'van', 'toan', 'anh', 'total'];
564551
const sortKey = sortKeys[columnIndex];
565-
const isNumeric = columnIndex >= 4 || columnIndex === 0; // SBD cũng là số
552+
const isNumeric = columnIndex >= 4 || columnIndex === 0;
566553
const direction = this.currentSort.direction === 'asc' ? 1 : -1;
567554

568555
this.filteredData.sort((a, b) => {
569556
const aVal = a[sortKey];
570557
const bVal = b[sortKey];
571558

572559
if (isNumeric) {
573-
// Sửa lại để so sánh SBD như số nếu có thể
574560
if(sortKey === 'sbd') {
575561
return (parseInt(aVal, 10) - parseInt(bVal, 10)) * direction;
576562
}

0 commit comments

Comments
 (0)