first commit

This commit is contained in:
Nathan FONTEYNE 2026-07-08 11:05:21 +02:00
commit 244cdbedd7
44 changed files with 3386 additions and 0 deletions

30
public/js/render.js Normal file
View file

@ -0,0 +1,30 @@
function renderList(container, items, templateFn, emptyMessage) {
if (!items.length) {
container.innerHTML = `<p class="empty">${escapeHtml(emptyMessage || 'Rien à afficher pour le moment.')}</p>`;
return;
}
container.innerHTML = items.map(templateFn).join('');
}
function escapeHtml(str) {
return String(str ?? '').replace(/[&<>"']/g, (c) => ({
'&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;',
}[c]));
}
function youtubeEmbedUrl(url) {
try {
const parsed = new URL(url);
let videoId = null;
if (parsed.hostname === 'youtu.be') {
videoId = parsed.pathname.slice(1);
} else if (parsed.pathname === '/watch') {
videoId = parsed.searchParams.get('v');
} else if (parsed.pathname.startsWith('/embed/')) {
videoId = parsed.pathname.split('/embed/')[1];
}
return videoId ? `https://www.youtube.com/embed/${videoId}` : null;
} catch {
return null;
}
}