Merge pull request #1 from D1034181036/feature/performance-optimization
Performance optimization: CSV data preprocessing
This commit is contained in:
12
index.html
12
index.html
@@ -73,8 +73,12 @@
|
||||
// 用 pako 解壓縮
|
||||
var csvData = pako.inflate(uintArray, { to: 'string' });
|
||||
|
||||
// 文字框改變時 call searchCSV()
|
||||
// CSV 資料預處理
|
||||
var lines = csvData.split('\n').map(line => {
|
||||
return [removeAccents(line.toLowerCase()), line];
|
||||
});
|
||||
|
||||
// 文字框改變時 call searchCSV()
|
||||
function searchCSV() {
|
||||
var input = removeAccents(document.getElementById('searchInput').value.toLowerCase());
|
||||
|
||||
@@ -84,14 +88,12 @@
|
||||
return;
|
||||
}
|
||||
|
||||
var lines = csvData.split('\n');
|
||||
var matchingLines = '';
|
||||
|
||||
// 搜尋每一行
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var line = removeAccents(lines[i].toLowerCase());
|
||||
if (line.includes(input)) {
|
||||
matchingLines += lines[i] + '<br>';
|
||||
if (lines[i][0].includes(input)) {
|
||||
matchingLines += lines[i][1] + '<br>';
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user