Files
EasyDNS-Web/internal/server/web/static/app.js
T
Mateusz Gruszczyński 8c4d463f1e
Go quality gates / test (push) Waiting to run
first commit
2026-11-30 11:37:40 +01:00

19 lines
1.2 KiB
JavaScript

/* EasyDNS UI progressive enhancements. No secrets, auth state or API tokens in JS. */
(() => {
'use strict';
const side = document.getElementById('sidebar');
const toggle = document.getElementById('menuToggle');
const cover = document.getElementById('sidebarOverlay');
const close = () => { side?.classList.remove('open'); cover?.classList.remove('open'); toggle?.setAttribute('aria-expanded', 'false'); };
toggle?.addEventListener('click', () => {const on = side.classList.toggle('open');cover?.classList.toggle('open', on);toggle.setAttribute('aria-expanded', String(on));});
cover?.addEventListener('click', close);
document.addEventListener('keydown', e => {if(e.key === 'Escape') close();});
document.querySelectorAll('.notice-dismiss').forEach(el => el.addEventListener('click', () => el.closest('.notice')?.remove()));
document.querySelectorAll('.bar-fill[data-count]').forEach(bar => {
const count = Number(bar.dataset.count), total = Number(bar.dataset.total);
const ratio = Number.isFinite(count) && Number.isFinite(total) && total > 0 ? 100 * count / total : 0;
bar.style.width = Math.max(0, Math.min(100, ratio)) + '%';
bar.title = ratio.toFixed(1) + '% of total';
});
})();