- Mehrere Begriffe mit AND/OR verknuepfen — Volltext-Substring, case-insensitive, link-nach-rechts ausgewertet.
+ Mehrere Begriffe mit AND/OR verknuepfen — Volltext-Substring, case-insensitive, links-nach-rechts ausgewertet.
-
-
-
-
-
-
+
+
-
+
-
- Tipp: Felder mit Inhalt werden zusammengeführt — leere Felder werden ignoriert
+
+
+ Leere Felder werden ignoriert · Min. 1 Feld · ✕ entfernt ein Feld
@@ -3485,32 +3476,94 @@
const open = panel.style.display !== 'none';
panel.style.display = open ? 'none' : 'block';
if (btn) btn.textContent = open ? '⌃ Erweitert' : '⌄ Einklappen';
+ if (!open) ensureAdvancedRows();
+ }
+
+ // Dynamische Such-Reihen-Struktur:
+ // advRows = [{term, op}, ...] — die erste Reihe hat op=null,
+ // jede weitere bekommt einen UND/ODER-Selektor links und einen ✕ rechts.
+ let advRows = [{ term: '', op: null }];
+
+ function ensureAdvancedRows() {
+ if (!advRows.length) advRows = [{ term: '', op: null }];
+ renderAdvancedRows();
+ }
+
+ function addAdvancedRow() {
+ // Vor dem Re-render aktuelle Werte aus DOM uebernehmen damit nichts verloren geht
+ syncAdvancedRowsFromDOM();
+ advRows.push({ term: '', op: 'AND' });
+ renderAdvancedRows();
+ // Fokus auf das neue Feld
+ const last = document.querySelector(`#adv-rows-container .adv-row:last-child input.adv-term`);
+ if (last) last.focus();
+ }
+
+ function removeAdvancedRow(idx) {
+ syncAdvancedRowsFromDOM();
+ if (advRows.length <= 1) return; // erste bleibt
+ advRows.splice(idx, 1);
+ // Erste Reihe hat immer op=null
+ if (advRows[0]) advRows[0].op = null;
+ renderAdvancedRows();
+ }
+
+ function syncAdvancedRowsFromDOM() {
+ const rows = document.querySelectorAll('#adv-rows-container .adv-row');
+ const next = [];
+ rows.forEach((row, i) => {
+ const term = (row.querySelector('input.adv-term')?.value || '');
+ const op = i === 0 ? null : (row.querySelector('select.adv-op')?.value || 'AND');
+ next.push({ term, op });
+ });
+ if (next.length) advRows = next;
+ }
+
+ function renderAdvancedRows() {
+ const container = document.getElementById('adv-rows-container');
+ if (!container) return;
+ const inputStyle = 'flex:1;min-width:0;background:#080810;color:#E0E0F0;border:1px solid #1E1E2E;padding:6px;border-radius:4px;font-family:inherit;font-size:12px;';
+ const selectStyle = 'background:#080810;color:#E0E0F0;border:1px solid #1E1E2E;padding:6px;border-radius:4px;font-family:inherit;font-size:11px;width:70px;';
+ container.innerHTML = advRows.map((r, i) => {
+ const ph = i === 0 ? 'z.B. flugzeug' : 'z.B. cessna';
+ const term = (r.term || '').replace(/"/g, '"');
+ if (i === 0) {
+ return `
+ Start
+
+
+
`;
+ }
+ const op = r.op || 'AND';
+ return `
+
+
+
+
`;
+ }).join('');
}
function clearAdvancedSearch() {
- ['adv-term-1','adv-term-2','adv-term-3'].forEach(id => {
- const el = document.getElementById(id); if (el) el.value = '';
- });
+ advRows = [{ term: '', op: null }];
+ renderAdvancedRows();
}
/** Mehrere Volltext-Suchen + Boolean-Kombination (links nach rechts).
* Backend bleibt simpel — wir machen N parallele search-text-Calls
* und kombinieren die ID-Mengen client-seitig per AND/OR. */
async function runAdvancedSearch() {
- const terms = [
- document.getElementById('adv-term-1')?.value?.trim() || '',
- document.getElementById('adv-term-2')?.value?.trim() || '',
- document.getElementById('adv-term-3')?.value?.trim() || '',
- ];
- const ops = [
- document.getElementById('adv-op-1')?.value || 'AND',
- document.getElementById('adv-op-2')?.value || 'AND',
- ];
+ syncAdvancedRowsFromDOM();
const info = document.getElementById('brain-search-info');
- // Felder mit Inhalt zusammen mit dem ops-Op DAVOR sammeln
+ // Nur Reihen mit Inhalt einsammeln. Die erste belegte Reihe wird zum
+ // Start-Term (op=null), egal an welchem Index sie ursprünglich war.
const active = [];
- for (let i = 0; i < 3; i++) {
- if (terms[i]) active.push({ term: terms[i], op: i === 0 ? null : ops[i - 1] });
+ for (const r of advRows) {
+ const t = (r.term || '').trim();
+ if (!t) continue;
+ active.push({ term: t, op: active.length === 0 ? null : (r.op || 'AND') });
}
if (active.length === 0) {
if (info) info.style.display = 'none';