Feat: Update available checker.
This commit is contained in:
+3
-1
@@ -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"
|
||||
}
|
||||
+3
-1
@@ -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"
|
||||
}
|
||||
+3
-1
@@ -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"
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
})();
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
<?php
|
||||
$js_dir = __DIR__ . '/../js/';
|
||||
include $js_dir . 'config.js';
|
||||
$js_modules = ['utils', 'favorites', 'epg', 'mobile', 'tooltip', 'sources', 'm3u', 'player', 'themes', 'search', 'program', 'live'];
|
||||
$js_modules = ['utils', 'favorites', 'epg', 'mobile', 'tooltip', 'sources', 'm3u', 'player', 'themes', 'search', 'program', 'updater', 'live'];
|
||||
foreach ($js_modules as $mod) {
|
||||
echo file_get_contents($js_dir . $mod . '.js');
|
||||
}
|
||||
|
||||
@@ -869,6 +869,21 @@
|
||||
opacity: .3; margin: 0;
|
||||
}
|
||||
|
||||
|
||||
/* ── UPDATE BADGE ────────────────────────────────────────────────────────── */
|
||||
.update-badge {
|
||||
background: var(--accent); color: #000;
|
||||
font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
|
||||
padding: 4px 10px; text-decoration: none; white-space: nowrap;
|
||||
animation: pulse-badge 2s ease-in-out infinite;
|
||||
border-radius: 2px; margin-left: 4px;
|
||||
}
|
||||
.update-badge:hover { opacity: .85; }
|
||||
@keyframes pulse-badge {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: .65; }
|
||||
}
|
||||
|
||||
</style>
|
||||
<link id="themeStylesheet" rel="stylesheet" href="themes/default.css">
|
||||
</head>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"version": "1.4.0"
|
||||
}
|
||||
Reference in New Issue
Block a user