function switchSectionTab(btn, panelId) { document.querySelectorAll('.section-tab').forEach(function(t) { t.classList.remove('is-selected'); }); document.querySelectorAll('.section-panel').forEach(function(p) { p.classList.remove('active'); }); btn.classList.add('is-selected'); var panel = document.getElementById(panelId); if (panel) panel.classList.add('active'); history.replaceState(null, '', '#' + panelId); } (function() { var hash = window.location.hash.replace('#', ''); if (hash) { var panel = document.getElementById(hash); var tab = document.querySelector('[data-tab="' + hash + '"]'); if (panel && tab) switchSectionTab(tab, hash); } })(); function downloadVersion(versionId) { fetch('/api/versions/' + versionId + '/download') .then(function(res) { if (!res.ok) throw new Error('Failed to get download URL'); return res.json(); }) .then(function(data) { window.location.href = data.download_url; }) .catch(function(err) { showToast(err.message || 'Download failed'); }); }