let allData = []; function sanitize(str) { return str.replaceAll("\\", "/"); } function populateFilters(data) { const catSet = new Set(); const tagSet = new Set(); data.forEach(item => { catSet.add(item.properties?.Category?.[0]); (item.properties?.Tags || []).forEach(tag => tagSet.add(tag)); }); const catFilter = document.getElementById("categoryFilter"); [...catSet].sort().forEach(cat => { const option = document.createElement("option"); option.value = cat; option.textContent = cat; catFilter.appendChild(option); }); const tagFilter = document.getElementById("tagFilter"); [...tagSet].sort().forEach(tag => { const option = document.createElement("option"); option.value = tag; option.textContent = tag; tagFilter.appendChild(option); }); } function render(data) { const gallery = document.getElementById("gallery"); gallery.innerHTML = ""; // clear data.forEach((item, index) => { const images = (item.images || []).map(sanitize); const tags = (item.properties?.Tags || []).join(', '); const category = item.properties?.Category?.[0] || 'Uncategorized'; const downloadPath = sanitize(item.download); const card = document.createElement("div"); card.className = "card"; card.setAttribute("data-category", category); card.setAttribute("data-tags", tags); const galleryGroupId = `gallery-${index}`; card.innerHTML = `