let serverListLoaded = false; function getApiToken() { return document.querySelector('meta[name="api-token"]')?.getAttribute('content') || ''; } function toggleNotifications() { const dd = document.getElementById('notifDropdown'); if (dd.classList.contains('open')) { closeNotifications(); } else { openNotifications(); } } function openNotifications() { const dd = document.getElementById('notifDropdown'); dd.classList.add('open'); fetchNotifications(); const userMenu = document.getElementById('userMenu'); if (userMenu) userMenu.classList.remove('open'); document.addEventListener('click', notifOutsideClick); } function closeNotifications() { const dd = document.getElementById('notifDropdown'); dd.classList.remove('open'); document.removeEventListener('click', notifOutsideClick); } function notifOutsideClick(e) { const wrapper = document.querySelector('.notification-btn-wrapper'); if (!wrapper.contains(e.target)) { closeNotifications(); } const userWrapper = document.querySelector('.topbar-user-dropdown'); if (userWrapper && !userWrapper.contains(e.target)) { const userMenu = document.getElementById('userMenu'); if (userMenu) userMenu.classList.remove('open'); } } function fetchNotifications() { const list = document.getElementById('notifList'); list.innerHTML = '