Menp überarbeitet
Some checks failed
Host-Based Deploy (Java 21 Fix) / build-and-run (push) Has been cancelled
Some checks failed
Host-Based Deploy (Java 21 Fix) / build-and-run (push) Has been cancelled
This commit is contained in:
@@ -168,22 +168,53 @@
|
||||
|
||||
async function doSearch(q, overlay) {
|
||||
try {
|
||||
const res = await fetch('/social/users/search?q=' + encodeURIComponent(q));
|
||||
const res = await fetch('/search?q=' + encodeURIComponent(q) + '&limit=3');
|
||||
if (!res.ok) { overlay.innerHTML = '<div class="topbar-search-hint">Fehler bei der Suche.</div>'; return; }
|
||||
const users = await res.json();
|
||||
if (!users || users.length === 0) {
|
||||
const data = await res.json();
|
||||
const { users = [], locations = [], events = [] } = data;
|
||||
|
||||
if (!users.length && !locations.length && !events.length) {
|
||||
overlay.innerHTML = '<div class="topbar-search-hint">Keine Ergebnisse.</div>';
|
||||
return;
|
||||
}
|
||||
overlay.innerHTML = users.map(u => {
|
||||
const av = u.profilePicture
|
||||
? `<img src="data:image/png;base64,${esc(u.profilePicture)}" class="topbar-search-avatar" alt="">`
|
||||
: `<span class="topbar-search-avatar topbar-search-avatar--placeholder">${IC('PROFILE')}</span>`;
|
||||
return `<a href="/community/benutzer.html?userId=${esc(u.userId)}" class="topbar-search-result">
|
||||
${av}
|
||||
<span style="font-size:0.92rem;font-weight:600;">${esc(u.name)}</span>
|
||||
</a>`;
|
||||
}).join('');
|
||||
|
||||
let html = '';
|
||||
|
||||
if (users.length) {
|
||||
html += `<div class="topbar-search-section">Personen</div>`;
|
||||
html += users.map(u => {
|
||||
const av = u.profilePicture
|
||||
? `<img src="data:image/png;base64,${esc(u.profilePicture)}" class="topbar-search-avatar" alt="">`
|
||||
: `<span class="topbar-search-avatar topbar-search-avatar--placeholder">${IC('PROFILE')}</span>`;
|
||||
return `<a href="/community/benutzer.html?userId=${esc(u.userId)}" class="topbar-search-result">
|
||||
${av}<span>${esc(u.name)}</span></a>`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
if (locations.length) {
|
||||
html += `<div class="topbar-search-section">Locations</div>`;
|
||||
html += locations.map(l => {
|
||||
const av = l.profilePicture
|
||||
? `<img src="data:image/png;base64,${esc(l.profilePicture)}" class="topbar-search-avatar" alt="">`
|
||||
: `<span class="topbar-search-avatar topbar-search-avatar--placeholder">📍</span>`;
|
||||
return `<a href="/community/location-detail.html?id=${esc(l.locationId)}" class="topbar-search-result">
|
||||
${av}<span>${esc(l.name)}</span></a>`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
if (events.length) {
|
||||
html += `<div class="topbar-search-section">Veranstaltungen</div>`;
|
||||
html += events.map(e => {
|
||||
const av = e.imageData
|
||||
? `<img src="${esc(e.imageData)}" class="topbar-search-avatar" alt="">`
|
||||
: `<span class="topbar-search-avatar topbar-search-avatar--placeholder">🗓</span>`;
|
||||
return `<a href="/community/event-detail.html?eventId=${esc(e.eventId)}" class="topbar-search-result">
|
||||
${av}<span>${esc(e.title)}</span></a>`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
html += `<a href="/search.html?q=${encodeURIComponent(q)}" class="topbar-search-all">Alle Ergebnisse anzeigen →</a>`;
|
||||
overlay.innerHTML = html;
|
||||
} catch (e) {
|
||||
overlay.innerHTML = '<div class="topbar-search-hint">Fehler bei der Suche.</div>';
|
||||
}
|
||||
@@ -207,6 +238,7 @@
|
||||
if (_activePanel === panel && panel.classList.contains('open')) {
|
||||
closeAllPanels(); return;
|
||||
}
|
||||
if (window.__navClose) window.__navClose();
|
||||
closeAllPanels();
|
||||
positionPanel(panel, btn);
|
||||
panel.classList.add('open');
|
||||
|
||||
Reference in New Issue
Block a user