Your learning signal
Fallows
Keep a short list of modules you want to revisit. This list stays in your current browser.
`;
const footerHTML = `
`;
document.querySelector('header').innerHTML = headerHTML;
document.querySelector('footer').innerHTML = footerHTML;
const key = 'framewiseTracked';
let ids = JSON.parse(localStorage.getItem(key) || '[]');
const params = new URLSearchParams(location.search);
const trackId = params.get('track');
const removeId = params.get('remove');
if (trackId && !ids.includes(trackId)) {
ids.push(trackId);
localStorage.setItem(key, JSON.stringify(ids));
}
if (removeId) {
ids = ids.filter(x => x !== removeId);
localStorage.setItem(key, JSON.stringify(ids));
window.location.href = './fallows.html';
}
fetch('./catalog.json').then(r => r.json()).then(items => {
const found = items.filter(x => ids.includes(x.id));
const grid = document.querySelector('#tracked-grid');
if (found.length) {
grid.innerHTML = found.map(x => `
${x.category}
${x.title}
${x.summary}
`).join('');
} else {
grid.innerHTML = ``;
}
document.querySelectorAll('[data-remove]').forEach(el => {
el.addEventListener('click', function(e) {
e.preventDefault();
ids = ids.filter(x => x !== el.dataset.remove);
localStorage.setItem(key, JSON.stringify(ids));
location.href = './fallows.html';
});
});
});
(function() {
const banner = document.querySelector('[data-cookie-banner]');
const closeBtn = document.querySelector('[data-cookie-close]');
if (banner && closeBtn) {
if (!localStorage.getItem('cookieConsent')) {
banner.classList.remove('hidden');
banner.classList.add('flex');
}
closeBtn.addEventListener('click', function() {
localStorage.setItem('cookieConsent', 'true');
banner.classList.remove('flex');
banner.classList.add('hidden');
});
}
const themeBtn = document.querySelector('[data-theme-toggle]');
if (themeBtn) {
themeBtn.addEventListener('click', () => {
document.documentElement.classList.toggle('dark');
localStorage.setItem('theme', document.documentElement.classList.contains('dark') ? 'dark' : 'light');
});
}
const loginBtn = document.querySelector('[data-login-open]');
const registerBtn = document.querySelector('[data-register-open]');
const loginModal = document.querySelector('[data-login-modal]');
const registerModal = document.querySelector('[data-register-modal]');
function closeModals() {
if (loginModal) loginModal.classList.add('hidden');
if (registerModal) registerModal.classList.add('hidden');
}
if (loginBtn && loginModal) {
loginBtn.addEventListener('click', () => { loginModal.classList.remove('hidden'); loginModal.classList.add('flex'); });
}
if (registerBtn && registerModal) {
registerBtn.addEventListener('click', () => { closeModals(); registerModal.classList.remove('hidden'); registerModal.classList.add('flex'); });
}
document.querySelectorAll('[data-modal-close]').forEach(b => b.addEventListener('click', closeModals));
const mobileBtn = document.querySelector('[data-mobile-open]');
const mobilePanel = document.querySelector('[data-mobile-panel]');
if (mobileBtn && mobilePanel) {
mobileBtn.addEventListener('click', () => mobilePanel.classList.toggle('hidden'));
}
})();