Update index.html
Browse files- index.html +46 -32
index.html
CHANGED
@@ -289,8 +289,9 @@ function performSearch() {
|
|
289 |
}
|
290 |
|
291 |
const searchType = Array.from(searchTypeRadios).find(radio => radio.checked).value;
|
|
|
292 |
|
293 |
-
|
294 |
|
295 |
if (searchType === 'contains') {
|
296 |
const exactMatches = [];
|
@@ -298,55 +299,68 @@ function performSearch() {
|
|
298 |
const endsWithMatches = [];
|
299 |
const otherContainsMatches = [];
|
300 |
|
|
|
301 |
excelData.forEach(row => {
|
|
|
302 |
row.forEach((cell, index) => {
|
|
|
303 |
const columnIndex = String.fromCharCode('A'.charCodeAt(0) + index);
|
304 |
-
if(columnIndex === mainWordColumn || mapping[columnIndex]){
|
|
|
305 |
const normalizedCell = normalizeText(cell);
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
|
|
|
|
|
|
|
|
320 |
}
|
321 |
});
|
|
|
|
|
322 |
});
|
323 |
-
filteredData = [...new Set([...exactMatches, ...startsWithMatches,...endsWithMatches, ...otherContainsMatches])];
|
324 |
|
325 |
}
|
326 |
else if (searchType === 'startsWith') {
|
327 |
filteredData = excelData.filter(row =>
|
328 |
row.some((cell, index) => {
|
329 |
const columnIndex = String.fromCharCode('A'.charCodeAt(0) + index);
|
330 |
-
if(columnIndex === mainWordColumn || mapping[columnIndex]){
|
331 |
const normalizedCell = normalizeText(cell);
|
332 |
-
|
|
|
333 |
}
|
334 |
return false;
|
335 |
}));
|
336 |
} else if (searchType === 'exact') {
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
|
|
|
|
350 |
}
|
351 |
|
352 |
displayData(filteredData);
|
|
|
289 |
}
|
290 |
|
291 |
const searchType = Array.from(searchTypeRadios).find(radio => radio.checked).value;
|
292 |
+
// const useWordBoundary = wordBoundaryCheckbox.checked; // Removed
|
293 |
|
294 |
+
let filteredData = [];
|
295 |
|
296 |
if (searchType === 'contains') {
|
297 |
const exactMatches = [];
|
|
|
299 |
const endsWithMatches = [];
|
300 |
const otherContainsMatches = [];
|
301 |
|
302 |
+
|
303 |
excelData.forEach(row => {
|
304 |
+
let rowMatches = false;
|
305 |
row.forEach((cell, index) => {
|
306 |
+
|
307 |
const columnIndex = String.fromCharCode('A'.charCodeAt(0) + index);
|
308 |
+
if(columnIndex === mainWordColumn || mapping[columnIndex]){ //Prioritize the main columns
|
309 |
+
|
310 |
const normalizedCell = normalizeText(cell);
|
311 |
+
// Removed word boundary logic
|
312 |
+
|
313 |
+
|
314 |
+
if (normalizedCell.includes(searchTerm)) {
|
315 |
+
if (normalizedCell === searchTerm) {
|
316 |
+
exactMatches.push(row);
|
317 |
+
}
|
318 |
+
else if(normalizedCell.startsWith(searchTerm)){
|
319 |
+
startsWithMatches.push(row);
|
320 |
+
}
|
321 |
+
else if(normalizedCell.endsWith(searchTerm)){
|
322 |
+
endsWithMatches.push(row)
|
323 |
+
}
|
324 |
+
else{
|
325 |
+
otherContainsMatches.push(row)
|
326 |
+
}
|
327 |
+
rowMatches = true;
|
328 |
+
}
|
329 |
}
|
330 |
});
|
331 |
+
|
332 |
+
|
333 |
});
|
334 |
+
filteredData = [...new Set([...exactMatches, ...startsWithMatches,...endsWithMatches, ...otherContainsMatches])]; // Remove duplicates, and combine
|
335 |
|
336 |
}
|
337 |
else if (searchType === 'startsWith') {
|
338 |
filteredData = excelData.filter(row =>
|
339 |
row.some((cell, index) => {
|
340 |
const columnIndex = String.fromCharCode('A'.charCodeAt(0) + index);
|
341 |
+
if(columnIndex === mainWordColumn || mapping[columnIndex]){ //Prioritize the main columns
|
342 |
const normalizedCell = normalizeText(cell);
|
343 |
+
// Removed word boundary logic
|
344 |
+
return normalizedCell.startsWith(searchTerm);
|
345 |
}
|
346 |
return false;
|
347 |
}));
|
348 |
} else if (searchType === 'exact') {
|
349 |
+
|
350 |
+
filteredData = excelData.filter(row =>
|
351 |
+
row.some((cell, index) => {
|
352 |
+
const columnIndex = String.fromCharCode('A'.charCodeAt(0) + index);
|
353 |
+
if(columnIndex === mainWordColumn || mapping[columnIndex]){ //Prioritize the main columns
|
354 |
+
|
355 |
+
const normalizedCell = normalizeText(cell);
|
356 |
+
// Removed word boundary logic
|
357 |
+
return normalizedCell === searchTerm; // Strict equality
|
358 |
+
|
359 |
+
}
|
360 |
+
return false;
|
361 |
+
}));
|
362 |
+
|
363 |
+
|
364 |
}
|
365 |
|
366 |
displayData(filteredData);
|