Files
linkspin/public/assets/tools.js
T

18 lines
1.3 KiB
JavaScript

// /tools glue: mounts the Control Room shell around the legacy panes and keeps the topbar + rail in step with the
// active pane (my.js owns the panes themselves; the hash is the source of truth).
(function () {
const TITLES = { overview: 'Start', promo: 'Promo tools', training: 'Training', pipeline: 'Pipeline', line: 'My line', profile: 'Profile' };
const pane = () => { const h = (location.hash || '').slice(1); return TITLES[h] ? h : 'overview'; };
const railKey = p => p === 'promo' ? 'promo' : 'tools';
CR.mount({ active: railKey(pane()), title: TITLES[pane()], crumb: 'Control room', sub: '' });
function sync() {
const p = pane(); const h1 = document.querySelector('.topbar h1'); if (h1) h1.textContent = TITLES[p];
document.title = TITLES[p] + ' · LinkSpin';
const want = railKey(p) === 'promo' ? '/tools#promo' : '/tools';
document.querySelectorAll('.rail a').forEach(a => { const href = a.getAttribute('href') || ''; if (href.startsWith('/tools')) a.classList.toggle('on', href === want); });
}
window.addEventListener('hashchange', sync); sync();
// the shell owns the session: sign-in dialog, who-button, status strip, login ad, first username. my.js waits for this.
CR.requireSession(() => { window.LS_SESSION_READY = true; window.dispatchEvent(new CustomEvent('ls:session')); });
})();