feat: add URL hash routing for RADAR tabs (#newsfeed, #govtracker)

This commit is contained in:
jae 2026-04-15 16:00:59 +00:00
parent 4485940c3c
commit 0f4ce1a5f7

View file

@ -359,14 +359,11 @@
govtracker: '> .GOV domain intelligence — tracking U.S. government infrastructure registry'
};
document.querySelectorAll('.radar-view-btn').forEach(function(btn) {
btn.addEventListener('click', function(e) {
e.preventDefault();
var view = this.dataset.view;
function switchToView(view) {
// Toggle button states
document.querySelectorAll('.radar-view-btn').forEach(function(b) { b.classList.remove('active'); });
this.classList.add('active');
var activeBtn = document.querySelector('.radar-view-btn[data-view="' + view + '"]');
if (activeBtn) activeBtn.classList.add('active');
// Toggle views
document.getElementById('viewNewsfeed').classList.toggle('hidden', view !== 'newsfeed');
@ -375,12 +372,35 @@
// Update subtitle
document.getElementById('radarSubtitle').innerHTML = subtitles[view] || '';
// Update URL hash without scrolling
history.replaceState(null, '', '#' + view);
// Lazy-load gov tracker data on first switch
if (view === 'govtracker' && !GovTracker.loaded) {
GovTracker.loadAll();
}
}
document.querySelectorAll('.radar-view-btn').forEach(function(btn) {
btn.addEventListener('click', function(e) {
e.preventDefault();
switchToView(this.dataset.view);
});
});
// Check URL hash on load
var hash = window.location.hash.replace('#', '');
if (hash === 'govtracker' || hash === 'newsfeed') {
switchToView(hash);
}
// Handle browser back/forward
window.addEventListener('hashchange', function() {
var h = window.location.hash.replace('#', '');
if (h === 'govtracker' || h === 'newsfeed') {
switchToView(h);
}
});
}
// ═══════════════════════════════════════════════════