Spaces:
Running
Running
Update index.html
Browse files- index.html +10 -23
index.html
CHANGED
|
@@ -37,7 +37,7 @@
|
|
| 37 |
}
|
| 38 |
|
| 39 |
#installButton {
|
| 40 |
-
display: none;
|
| 41 |
position: fixed;
|
| 42 |
bottom: 20px;
|
| 43 |
left: 50%;
|
|
@@ -53,11 +53,8 @@
|
|
| 53 |
</style>
|
| 54 |
</head>
|
| 55 |
<body>
|
| 56 |
-
<header>
|
| 57 |
-
<!-- Удалены текст и элемент с количеством посетителей -->
|
| 58 |
-
</header>
|
| 59 |
<iframe src="https://eum-lovat.vercel.app" allowfullscreen></iframe>
|
| 60 |
-
|
| 61 |
<button id="installButton">Install App</button>
|
| 62 |
|
| 63 |
<script>
|
|
@@ -65,41 +62,31 @@
|
|
| 65 |
const installButton = document.getElementById('installButton');
|
| 66 |
|
| 67 |
function showInstallPromotion() {
|
| 68 |
-
installButton.style.display = 'block';
|
| 69 |
installButton.addEventListener('click', async () => {
|
| 70 |
if (deferredPrompt) {
|
| 71 |
-
deferredPrompt.prompt();
|
| 72 |
const { outcome } = await deferredPrompt.userChoice;
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
console.log('User dismissed the install prompt');
|
| 77 |
-
}
|
| 78 |
-
deferredPrompt = null; // Очищаем deferredPrompt
|
| 79 |
-
installButton.style.display = 'none'; // Скрываем кнопку после установки или отклонения
|
| 80 |
}
|
| 81 |
});
|
| 82 |
}
|
| 83 |
|
| 84 |
window.addEventListener('beforeinstallprompt', (event) => {
|
| 85 |
-
// Предотвращаем автоматическое появление баннера установки
|
| 86 |
event.preventDefault();
|
| 87 |
deferredPrompt = event;
|
| 88 |
-
// Показываем кнопку установки или другой UI, чтобы предложить пользователю установить PWA
|
| 89 |
showInstallPromotion();
|
| 90 |
});
|
| 91 |
|
| 92 |
if ('serviceWorker' in navigator) {
|
| 93 |
window.addEventListener('load', () => {
|
| 94 |
navigator.serviceWorker.register('/service-worker.js')
|
| 95 |
-
.then((registration) =>
|
| 96 |
-
|
| 97 |
-
})
|
| 98 |
-
.catch((error) => {
|
| 99 |
-
console.log('Service Worker registration failed:', error);
|
| 100 |
-
});
|
| 101 |
});
|
| 102 |
}
|
| 103 |
</script>
|
| 104 |
</body>
|
| 105 |
-
</html>
|
|
|
|
| 37 |
}
|
| 38 |
|
| 39 |
#installButton {
|
| 40 |
+
display: none;
|
| 41 |
position: fixed;
|
| 42 |
bottom: 20px;
|
| 43 |
left: 50%;
|
|
|
|
| 53 |
</style>
|
| 54 |
</head>
|
| 55 |
<body>
|
| 56 |
+
<header></header>
|
|
|
|
|
|
|
| 57 |
<iframe src="https://eum-lovat.vercel.app" allowfullscreen></iframe>
|
|
|
|
| 58 |
<button id="installButton">Install App</button>
|
| 59 |
|
| 60 |
<script>
|
|
|
|
| 62 |
const installButton = document.getElementById('installButton');
|
| 63 |
|
| 64 |
function showInstallPromotion() {
|
| 65 |
+
installButton.style.display = 'block';
|
| 66 |
installButton.addEventListener('click', async () => {
|
| 67 |
if (deferredPrompt) {
|
| 68 |
+
deferredPrompt.prompt();
|
| 69 |
const { outcome } = await deferredPrompt.userChoice;
|
| 70 |
+
console.log(outcome === 'accepted' ? 'User accepted the install prompt' : 'User dismissed the install prompt');
|
| 71 |
+
deferredPrompt = null;
|
| 72 |
+
installButton.style.display = 'none';
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
}
|
| 74 |
});
|
| 75 |
}
|
| 76 |
|
| 77 |
window.addEventListener('beforeinstallprompt', (event) => {
|
|
|
|
| 78 |
event.preventDefault();
|
| 79 |
deferredPrompt = event;
|
|
|
|
| 80 |
showInstallPromotion();
|
| 81 |
});
|
| 82 |
|
| 83 |
if ('serviceWorker' in navigator) {
|
| 84 |
window.addEventListener('load', () => {
|
| 85 |
navigator.serviceWorker.register('/service-worker.js')
|
| 86 |
+
.then((registration) => console.log('Service Worker registered:', registration))
|
| 87 |
+
.catch((error) => console.log('Service Worker registration failed:', error));
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
});
|
| 89 |
}
|
| 90 |
</script>
|
| 91 |
</body>
|
| 92 |
+
</html>
|