// snackbar.js — лёгкие уведомления (без зависимостей) // showSnackbar(msg, type='info') — type: info, success, error function showSnackbar(msg, type) { type = type || 'info'; let container = document.getElementById('snackbar-container'); if (!container) { container = document.createElement('div'); container.id = 'snackbar-container'; container.className = 'snackbar-container'; container.setAttribute('role', 'status'); container.setAttribute('aria-live', 'polite'); document.body.appendChild(container); } const el = document.createElement('div'); el.className = 'snackbar ' + type; el.textContent = msg; el.onclick = function() { el.remove(); }; container.appendChild(el); // Limit stacking const all = container.querySelectorAll('.snackbar'); if (all.length > 4) all[0].remove(); // Auto-hide: info/success 4s, error 8s const delay = (type === 'error') ? 8000 : 4000; setTimeout(function() { if (el.parentNode) el.remove(); }, delay); }