diff --git a/locales/en.json b/locales/en.json index 328e822..2605fc5 100644 --- a/locales/en.json +++ b/locales/en.json @@ -49,5 +49,7 @@ "shift_back": "◄ 1h", "shift_fwd": "1h ►", "fav_add": "Add to favorites", - "fav_remove": "Remove from favorites" + "fav_remove": "Remove from favorites", + "update_available": "↑ Update available:", + "update_title": "Click to download the latest version" } \ No newline at end of file diff --git a/locales/es.json b/locales/es.json index 5b71a3e..e4331cb 100644 --- a/locales/es.json +++ b/locales/es.json @@ -49,5 +49,7 @@ "shift_back": "◄ 1h", "shift_fwd": "1h ►", "fav_add": "Agregar a favoritos", - "fav_remove": "Quitar de favoritos" + "fav_remove": "Quitar de favoritos", + "update_available": "↑ Actualizacion disponible:", + "update_title": "Haz clic para descargar la ultima version" } \ No newline at end of file diff --git a/locales/fr.json b/locales/fr.json index 2ba1338..46cb8fe 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -49,5 +49,7 @@ "shift_back": "◄ 1h", "shift_fwd": "1h ►", "fav_add": "Ajouter aux favoris", - "fav_remove": "Retirer des favoris" + "fav_remove": "Retirer des favoris", + "update_available": "↑ Mise a jour disponible :", + "update_title": "Cliquez pour telecharger la derniere version" } \ No newline at end of file diff --git a/src/js/updater.js b/src/js/updater.js new file mode 100644 index 0000000..2206047 --- /dev/null +++ b/src/js/updater.js @@ -0,0 +1,38 @@ +// ── UPDATE CHECKER ──────────────────────────────────────────────────────────── +(async function checkForUpdate() { + try { + const [localRes, remoteRes] = await Promise.all([ + fetch('version.json'), + fetch('https://api.github.com/repos/Johnnybegood90/GridTV/releases/latest') + ]); + if (!localRes.ok || !remoteRes.ok) return; + + const local = (await localRes.json()).version ?? '0.0.0'; + const remote = (await remoteRes.json()).tag_name ?? '0.0.0'; + + const clean = v => v.replace(/^v/, ''); + const toNum = v => v.split('.').map(Number); + + const [lMaj, lMin, lPat] = toNum(clean(local)); + const [rMaj, rMin, rPat] = toNum(clean(remote)); + + const hasUpdate = + rMaj > lMaj || + (rMaj === lMaj && rMin > lMin) || + (rMaj === lMaj && rMin === lMin && rPat > lPat); + + if (!hasUpdate) return; + + const badge = document.createElement('a'); + badge.className = 'update-badge'; + badge.href = `https://github.com/Johnnybegood90/GridTV/releases/latest`; + badge.target = '_blank'; + badge.rel = 'noopener'; + badge.innerHTML = `${L.update_available} ${clean(remote)}`; + badge.title = L.update_title; + + document.querySelector('.topbar')?.appendChild(badge); + } catch (_) { + // Silencieux — pas de connexion ou rate limit GitHub + } +})(); diff --git a/src/tpl/footer.php b/src/tpl/footer.php index e0c520d..3962be4 100644 --- a/src/tpl/footer.php +++ b/src/tpl/footer.php @@ -3,7 +3,7 @@ diff --git a/version.json b/version.json new file mode 100644 index 0000000..d19a958 --- /dev/null +++ b/version.json @@ -0,0 +1,3 @@ +{ + "version": "1.4.0" +}