U-Garika / index.html
Kgshop's picture
Update index.html
a9e0658 verified
Raw
History Blame Contribute Delete
3.88 kB
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>У Гарика - приложение</title>
<link rel="manifest" href="/manifest.json">
<link rel="stylesheet" href="style.css">
<link rel="apple-touch-icon" href="/icon.png">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<link rel="icon" type="image/png" sizes="192x192" href="/icon.png">
<link rel="icon" href="icon.png" type="image/png">
<meta name="google-site-verification" content="V6EqDTA9Oj9V1OfNbnBHj5RKrdcXlABD8tqfEFVUHJY" />
<meta name="description" content=" ">
</head>
<body>
<iframe
src="https://metastore-full.hf.space/633275/catalog?mode=online&staff_id="
frameborder="0"
allowfullscreen
allow="cross-origin-isolated; cookies"></iframe>
<!-- Кнопка скрыта по умолчанию и отображается только при готовности к установке -->
<button id="installButton" style="display: none;">Установить приложение</button>
<script>
let deferredPrompt;
const installButton = document.getElementById('installButton');
// Отслеживаем событие готовности к установке PWA (в основном Android и десктопные браузеры Chrome/Edge)
window.addEventListener('beforeinstallprompt', (event) => {
event.preventDefault();
deferredPrompt = event;
installButton.style.display = 'block';
installButton.classList.add('pulse-animation');
});
// Обработчик клика по кнопке установки
installButton.addEventListener('click', async () => {
if (deferredPrompt) {
deferredPrompt.prompt();
const { outcome } = await deferredPrompt.userChoice;
if (outcome === 'accepted') {
console.log('Пользователь принял запрос на установку');
} else {
console.log('Пользователь отклонил запрос на установку');
}
deferredPrompt = null;
installButton.style.display = 'none';
installButton.classList.remove('pulse-animation');
}
});
// Скрываем кнопку, если приложение уже успешно установлено
window.addEventListener('appinstalled', () => {
console.log('Приложение успешно установлено');
installButton.style.display = 'none';
installButton.classList.remove('pulse-animation');
deferredPrompt = null;
});
// Регистрация Service Worker
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/service-worker.js')
.then((registration) => {
console.log('Сервисный рабочий процесс зарегистрирован:', registration);
})
.catch((error) => {
console.log('Ошибка регистрации сервисного рабочего процесса:', error);
});
});
}
// Перехват ошибок
window.addEventListener('error', (event) => {
console.error('Произошла ошибка:', event.message, event.filename, event.lineno);
});
</script>
</body>
</html>