diff --git a/index.html b/index.html index 987bbeb..74a03ab 100644 --- a/index.html +++ b/index.html @@ -358,7 +358,7 @@
@@ -372,7 +372,7 @@Piattaforma multi-agente in cui tu scegli dove salvare i dati e quale AI utilizzare. Crea workflow automatici in linguaggio naturale.
@@ -584,6 +584,58 @@ }); }); }); + + // --- Auto-detect OS & download latest release --- + const RELEASE_API = 'https://git.muticolturano.com/api/v1/repos/roberto/adiuva/releases/latest'; + const RELEASES_PAGE = 'https://git.muticolturano.com/roberto/adiuva/releases'; + + function detectOS() { + const ua = navigator.userAgent || navigator.platform || ''; + if (/Win/i.test(ua)) return 'windows'; + if (/Linux/i.test(ua)) { + // Heuristic: most desktop Linux users on Debian/Ubuntu + return 'linux'; + } + return 'unknown'; + } + + // Update hero button label based on OS + (function updateLabel() { + const os = detectOS(); + const heroBtn = document.getElementById('hero-download'); + if (heroBtn) { + if (os === 'windows') heroBtn.textContent = 'Scarica per Windows (.exe)'; + else if (os === 'linux') heroBtn.textContent = 'Scarica per Linux (.deb)'; + } + })(); + + async function downloadLatest(e) { + e.preventDefault(); + try { + const res = await fetch(RELEASE_API); + if (!res.ok) throw new Error('API error'); + const release = await res.json(); + const assets = release.assets || []; + const os = detectOS(); + + let asset; + if (os === 'windows') { + asset = assets.find(a => a.name.endsWith('.exe')); + } else if (os === 'linux') { + asset = assets.find(a => a.name.endsWith('.deb')) || + assets.find(a => a.name.endsWith('.rpm')); + } + + if (asset && asset.browser_download_url) { + window.location.href = asset.browser_download_url; + } else { + // Fallback: send to releases page + window.location.href = RELEASES_PAGE; + } + } catch { + window.location.href = RELEASES_PAGE; + } + }