| 1 |
function switchSectionTab(btn, panelId) { |
| 2 |
document.querySelectorAll('.section-tab').forEach(function(t) { t.classList.remove('is-selected'); }); |
| 3 |
document.querySelectorAll('.section-panel').forEach(function(p) { p.classList.remove('active'); }); |
| 4 |
btn.classList.add('is-selected'); |
| 5 |
var panel = document.getElementById(panelId); |
| 6 |
if (panel) panel.classList.add('active'); |
| 7 |
history.replaceState(null, '', '#' + panelId); |
| 8 |
} |
| 9 |
|
| 10 |
(function() { |
| 11 |
var hash = window.location.hash.replace('#', ''); |
| 12 |
if (hash) { |
| 13 |
var panel = document.getElementById(hash); |
| 14 |
var tab = document.querySelector('[data-tab="' + hash + '"]'); |
| 15 |
if (panel && tab) switchSectionTab(tab, hash); |
| 16 |
} |
| 17 |
})(); |
| 18 |
|
| 19 |
function downloadVersion(versionId) { |
| 20 |
fetch('/api/versions/' + versionId + '/download') |
| 21 |
.then(function(res) { |
| 22 |
if (!res.ok) throw new Error('Failed to get download URL'); |
| 23 |
return res.json(); |
| 24 |
}) |
| 25 |
.then(function(data) { |
| 26 |
window.location.href = data.download_url; |
| 27 |
}) |
| 28 |
.catch(function(err) { |
| 29 |
showToast(err.message || 'Download failed'); |
| 30 |
}); |
| 31 |
} |
| 32 |
|