Fix bugs & patch standalone mode for iOS app.

This commit is contained in:
VIART Mathieu 2026-03-03 15:59:58 +00:00
parent 3f3fd3a48c
commit dbc4a3786d
4 changed files with 39 additions and 29 deletions

View file

@ -12,7 +12,7 @@
gtag("config", "G-220WPFE2DM");
</script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover, user-scalable=no, maximum-scale=1, minimum-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="LeGrandGeoQuiz">
<meta name="theme-color" content="#0d0f14">
@ -320,7 +320,7 @@
</button>
<button class="preset-btn" onclick="applyPreset('small',this)">
<span class="p-icon">🔬</span>
<span class="p-name"> 1M hab.</span>
<span class="p-name" data-i18n="presetSmallPop"></span>
</button>
<button class="preset-btn" onclick="applyPreset('france-neighbors',this)">
<span class="p-icon">🇫🇷🤝</span>
@ -503,7 +503,10 @@
</div>
<script src="config.js"></script>
<script>
// Config optionnelle — présente en self-host, absente sur GitHub Pages
// L'API par défaut est définie dans daily.js via window.GEOQUIZ_API
</script>
<script src="js/translations.js"></script>
<script src="js/data.js"></script>
<script src="js/utils.js"></script>
@ -524,7 +527,7 @@ initApp();
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('/sw.js').catch(function(err) {
navigator.serviceWorker.register('/legrandgeoquiz/sw.js').catch(function(err) {
console.warn('SW registration failed:', err);
});
});

View file

@ -2,15 +2,22 @@
// Disable zoom gestures but allow normal scrolling
(function() {
// 1. Prevent double-tap zoom
// 1. Prevent double-tap zoom — sans bloquer les clics légitimes
var lastTouchEnd = 0;
var lastTouchX = 0;
var lastTouchY = 0;
document.addEventListener('touchend', function(e) {
var now = Date.now();
if (now - lastTouchEnd <= 300) {
// Double tap detected, prevent zoom
var t = e.changedTouches[0];
var dx = Math.abs(t.clientX - lastTouchX);
var dy = Math.abs(t.clientY - lastTouchY);
// Double-tap détecté : même zone (<30px) en moins de 300ms
if (now - lastTouchEnd <= 300 && dx < 30 && dy < 30) {
e.preventDefault();
}
lastTouchEnd = now;
lastTouchX = t.clientX;
lastTouchY = t.clientY;
}, { passive: false });
// 2. Prevent pinch-to-zoom

View file

@ -2,8 +2,8 @@
"name": "LeGrandGeoQuiz",
"short_name": "GeoQuiz",
"description": "Test your geography knowledge with LeGrandGeoQuiz",
"start_url": "/",
"scope": "/",
"start_url": "/legrandgeoquiz/",
"scope": "/legrandgeoquiz/",
"display": "standalone",
"orientation": "portrait-primary",
"background_color": "#0d0f14",

40
sw.js
View file

@ -6,25 +6,25 @@ var CACHE_NAME = 'geoquiz-v1';
// Assets à précacher au moment de l'installation
var PRECACHE_URLS = [
'/',
'/index.html',
'/manifest.json',
'/favicon.svg',
'/country.json',
'/css/styles.css',
'/js/game.js',
'/js/game-end.js',
'/js/daily.js',
'/js/data.js',
'/js/hints.js',
'/js/mobile.js',
'/js/ribbon.js',
'/js/seed.js',
'/js/setup.js',
'/js/translations.js',
'/js/ui-effects.js',
'/js/utils.js',
'/js/zoom-prevention.js'
'/legrandgeoquiz/',
'/legrandgeoquiz/index.html',
'/legrandgeoquiz/manifest.json',
'/legrandgeoquiz/favicon.svg',
'/legrandgeoquiz/country.json',
'/legrandgeoquiz/css/styles.css',
'/legrandgeoquiz/js/game.js',
'/legrandgeoquiz/js/game-end.js',
'/legrandgeoquiz/js/daily.js',
'/legrandgeoquiz/js/data.js',
'/legrandgeoquiz/js/hints.js',
'/legrandgeoquiz/js/mobile.js',
'/legrandgeoquiz/js/ribbon.js',
'/legrandgeoquiz/js/seed.js',
'/legrandgeoquiz/js/setup.js',
'/legrandgeoquiz/js/translations.js',
'/legrandgeoquiz/js/ui-effects.js',
'/legrandgeoquiz/js/utils.js',
'/legrandgeoquiz/js/zoom-prevention.js'
];
// ── Install : précacher tous les assets du jeu ────────────────────────────────
@ -92,7 +92,7 @@ self.addEventListener('fetch', function(event) {
}).catch(function() {
// Fallback ultime offline : index.html pour les navigations
if (event.request.mode === 'navigate') {
return caches.match('/index.html');
return caches.match('/legrandgeoquiz/index.html');
}
});
})