Add dates/events section — loads from schedule webhook, shows cards with date/time
This commit is contained in:
+77
@@ -8,6 +8,7 @@ const USER_URL = 'https://n8n.odoo4projects.com/webhook/paraguay/user';
|
||||
const PROFILE_URL = 'https://n8n.odoo4projects.com/webhook/paraguay/profile';
|
||||
const WIKI_URL = 'https://n8n.odoo4projects.com/webhook/paraguay/wiki';
|
||||
const COMMUNITY_URL = 'https://n8n.odoo4projects.com/webhook/paraguay/community';
|
||||
const SCHEDULE_URL = 'https://n8n.odoo4projects.com/webhook/paraguay/schedule';
|
||||
|
||||
let currentLang = 'de';
|
||||
|
||||
@@ -283,6 +284,7 @@ function checkSession() {
|
||||
document.getElementById('newsletter-section').style.display = 'block';
|
||||
loadUsers();
|
||||
loadWiki();
|
||||
loadDates();
|
||||
} else {
|
||||
document.body.dataset.loggedIn = 'false';
|
||||
document.getElementById('login-btn').style.display = 'inline-flex';
|
||||
@@ -720,6 +722,81 @@ function searchWiki(term) {
|
||||
renderWikiCards(filtered);
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// DATES / EVENTS
|
||||
// ========================================
|
||||
async function loadDates() {
|
||||
try {
|
||||
const response = await fetch(SCHEDULE_URL);
|
||||
if (!response.ok) throw new Error('Failed to fetch');
|
||||
const result = await response.json();
|
||||
|
||||
if (result.data && Array.isArray(result.data) && result.data.length > 0) {
|
||||
renderDates(result.data);
|
||||
} else {
|
||||
document.getElementById('dates-list').innerHTML =
|
||||
`<p class="no-events">${isDE() ? 'Keine Termine geplant' : 'No events scheduled'}</p>`;
|
||||
}
|
||||
} catch (error) {
|
||||
document.getElementById('dates-list').innerHTML =
|
||||
`<p class="no-events">${isDE() ? 'Fehler beim Laden' : 'Error loading events'}</p>`;
|
||||
}
|
||||
}
|
||||
|
||||
function renderDates(events) {
|
||||
const container = document.getElementById('dates-list');
|
||||
container.innerHTML = '';
|
||||
|
||||
// Sort events by date
|
||||
const sorted = events.sort((a, b) => new Date(a.start) - new Date(b.start));
|
||||
|
||||
sorted.forEach(event => {
|
||||
const card = document.createElement('div');
|
||||
card.className = 'date-card';
|
||||
|
||||
// Parse date/time from ISO string
|
||||
const startDate = new Date(event.start);
|
||||
const endDate = new Date(event.end);
|
||||
|
||||
// Format date: yyyy.mm.dd
|
||||
const day = String(startDate.getDate()).padStart(2, '0');
|
||||
const month = String(startDate.getMonth() + 1).padStart(2, '0');
|
||||
const year = startDate.getFullYear();
|
||||
const dateStr = `${year}.${month}.${day}`;
|
||||
|
||||
// Format time: HH:MM (local time)
|
||||
const startHour = String(startDate.getHours()).padStart(2, '0');
|
||||
const startMinute = String(startDate.getMinutes()).padStart(2, '0');
|
||||
const endHour = String(endDate.getHours()).padStart(2, '0');
|
||||
const endMinute = String(endDate.getMinutes()).padStart(2, '0');
|
||||
const startStr = `${startHour}:${startMinute}`;
|
||||
const endStr = `${endHour}:${endMinute}`;
|
||||
|
||||
card.innerHTML = `
|
||||
<div class="date-header">
|
||||
<div class="date-icon">📅</div>
|
||||
<h3 class="date-headline">${escapeHtml(event.headline || 'Unbenanntes Event')}</h3>
|
||||
</div>
|
||||
<div class="date-info">
|
||||
<div class="date-row">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>
|
||||
<span>${dateStr}</span>
|
||||
</div>
|
||||
<div class="date-row">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
|
||||
<span>${isDE() ? 'Start' : 'Start'} ${startStr}</span>
|
||||
</div>
|
||||
<div class="date-row">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
|
||||
<span>${isDE() ? 'Ende' : 'End'} ${endStr}</span>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
container.appendChild(card);
|
||||
});
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// COOKIES
|
||||
// ========================================
|
||||
|
||||
Reference in New Issue
Block a user