Spaces:
Sleeping
Sleeping
File size: 3,390 Bytes
6973475 9f28e8f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | /* AutoMLOps β shared utilities */
// ββ Toast notifications ββββββββββββββββββββββββββββββββββββββββββββββββββββ
function showToast(message, type = 'info', duration = 3500) {
const area = document.getElementById('toast-area');
if (!area) return;
const icons = { success: 'β
', error: 'β', info: 'βΉοΈ' };
const toast = document.createElement('div');
toast.className = `toast ${type}`;
toast.innerHTML = `<span>${icons[type] || 'βΉοΈ'}</span><span>${message}</span>`;
area.appendChild(toast);
setTimeout(() => {
toast.style.opacity = '0';
toast.style.transform = 'translateX(40px)';
toast.style.transition = 'opacity .3s, transform .3s';
setTimeout(() => toast.remove(), 300);
}, duration);
}
// ββ Responsive sidebar toggle ββββββββββββββββββββββββββββββββββββββββββββββ
(function () {
function checkWidth() {
const toggle = document.getElementById('sidebar-toggle');
if (toggle) toggle.style.display = window.innerWidth <= 768 ? 'inline-flex' : 'none';
}
window.addEventListener('resize', checkWidth);
document.addEventListener('DOMContentLoaded', checkWidth);
// Close sidebar when clicking outside on mobile
document.addEventListener('click', (e) => {
const sidebar = document.getElementById('sidebar');
const toggle = document.getElementById('sidebar-toggle');
if (window.innerWidth <= 768 && sidebar && sidebar.classList.contains('open')) {
if (!sidebar.contains(e.target) && e.target !== toggle) {
sidebar.classList.remove('open');
}
}
});
})();
// ββ Generic tab switcher βββββββββββββββββββββββββββββββββββββββββββββββββββ
function activateTab(panelId, btn, groupClass) {
document.querySelectorAll(`.${groupClass}`).forEach(p => p.classList.remove('active'));
document.querySelectorAll(`[data-tab-group="${groupClass}"]`).forEach(b => b.classList.remove('active'));
document.getElementById(panelId)?.classList.add('active');
if (btn) btn.classList.add('active');
}
// ββ Light / dark theme βββββββββββββββββββββββββββββββββββββββββββββββββββββ
function toggleTheme() {
document.body.classList.add('theme-transition');
const current = document.documentElement.getAttribute('data-theme') || 'dark';
const next = current === 'dark' ? 'light' : 'dark';
document.documentElement.setAttribute('data-theme', next);
localStorage.setItem('theme', next);
const icon = document.getElementById('theme-icon');
if (icon) icon.className = next === 'dark' ? 'fa-solid fa-moon' : 'fa-solid fa-sun';
document.dispatchEvent(new CustomEvent('themechange', { detail: next }));
setTimeout(() => document.body.classList.remove('theme-transition'), 300);
}
document.addEventListener('DOMContentLoaded', function () {
const current = document.documentElement.getAttribute('data-theme') || 'dark';
const icon = document.getElementById('theme-icon');
if (icon) icon.className = current === 'dark' ? 'fa-solid fa-moon' : 'fa-solid fa-sun';
});
|