Update Tabellen und Suchalgo
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" type="image/png" href="/images/icons/favicon.png">
|
||||
<link rel="apple-touch-icon" href="/images/icons/icon-180x180.png">
|
||||
<title>Infraviewer - Volltextsuche</title>
|
||||
<style>
|
||||
* {
|
||||
@@ -385,19 +387,31 @@
|
||||
resultsDiv.innerHTML = html;
|
||||
}
|
||||
|
||||
// Feste Spaltenreihenfolge und Anzeige-Labels (siehe Spalten.txt)
|
||||
const DISPLAY_COLUMNS = [
|
||||
{ key: 'Teil', label: 'Teilenummer' },
|
||||
{ key: 'Bez', label: 'Bezeichnung' },
|
||||
{ key: 'Bez2', label: 'Bezeichnung 2' },
|
||||
{ key: 'Ben7', label: 'Englischer Text' },
|
||||
{ key: 'Ben8', label: 'Deutscher Text' },
|
||||
{ key: 'Hersteller', label: 'Hersteller' },
|
||||
{ key: 'Text', label: 'Zusatztext' },
|
||||
{ key: 'PrsVK', label: 'Verkaufspreis in €' }
|
||||
];
|
||||
|
||||
function renderRecord(record) {
|
||||
let html = '<div class="record">';
|
||||
|
||||
for (const [key, value] of Object.entries(record)) {
|
||||
const displayValue = value === null ? '<em>NULL</em>' : highlightSearchTerm(String(value));
|
||||
for (const { key, label } of DISPLAY_COLUMNS) {
|
||||
if (!(key in record)) continue;
|
||||
const value = record[key];
|
||||
const displayValue = value === null || value === undefined ? '' : highlightSearchTerm(String(value));
|
||||
html += `
|
||||
<div class="record-field">
|
||||
<span class="field-name">${escapeHtml(key)}:</span>
|
||||
<span class="field-name">${escapeHtml(label)}:</span>
|
||||
<span class="field-value">${displayValue}</span>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
html += '</div>';
|
||||
return html;
|
||||
}
|
||||
@@ -405,8 +419,12 @@
|
||||
function highlightSearchTerm(text) {
|
||||
if (!currentSearchTerm) return escapeHtml(text);
|
||||
|
||||
const words = currentSearchTerm.trim().split(/\s+/).filter(Boolean);
|
||||
if (words.length === 0) return escapeHtml(text);
|
||||
|
||||
const escapedText = escapeHtml(text);
|
||||
const searchRegex = new RegExp(`(${escapeRegex(currentSearchTerm)})`, 'gi');
|
||||
const pattern = words.map(w => escapeRegex(w)).join('|');
|
||||
const searchRegex = new RegExp(`(${pattern})`, 'gi');
|
||||
return escapedText.replace(searchRegex, '<span class="highlight">$1</span>');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user