Update index.html
Browse files- index.html +14 -78
index.html
CHANGED
|
@@ -13,46 +13,16 @@
|
|
| 13 |
<link rel="icon" href="icon.png" type="image/png">
|
| 14 |
<meta name="google-site-verification" content="V6EqDTA9Oj9V1OfNbnBHj5RKrdcXlABD8tqfEFVUHJY" />
|
| 15 |
<meta name="description" content=" ">
|
| 16 |
-
<style>
|
| 17 |
-
/* Обёртки для кнопок установки, чтобы можно было разместить крестик закрытия рядом */
|
| 18 |
-
.install-wrapper {
|
| 19 |
-
display: none;
|
| 20 |
-
align-items: center;
|
| 21 |
-
gap: 8px;
|
| 22 |
-
}
|
| 23 |
-
.install-close-btn {
|
| 24 |
-
border: none;
|
| 25 |
-
background: rgba(0,0,0,0.15);
|
| 26 |
-
color: inherit;
|
| 27 |
-
width: 24px;
|
| 28 |
-
height: 24px;
|
| 29 |
-
border-radius: 50%;
|
| 30 |
-
font-size: 16px;
|
| 31 |
-
line-height: 1;
|
| 32 |
-
cursor: pointer;
|
| 33 |
-
display: flex;
|
| 34 |
-
align-items: center;
|
| 35 |
-
justify-content: center;
|
| 36 |
-
padding: 0;
|
| 37 |
-
}
|
| 38 |
-
</style>
|
| 39 |
</head>
|
| 40 |
<body>
|
| 41 |
<iframe
|
| 42 |
-
src="https://metastore-full.hf.space/
|
| 43 |
frameborder="0"
|
| 44 |
allowfullscreen
|
| 45 |
allow="cross-origin-isolated; cookies"></iframe>
|
| 46 |
|
| 47 |
-
<
|
| 48 |
-
|
| 49 |
-
<button class="install-close-btn" id="closeInstallButton" aria-label="Закрыть">×</button>
|
| 50 |
-
</div>
|
| 51 |
-
|
| 52 |
-
<div class="install-wrapper" id="iosInstallWrapper">
|
| 53 |
-
<button id="iosInstallPrompt">Установить приложение</button>
|
| 54 |
-
<button class="install-close-btn" id="closeIosInstallButton" aria-label="Закрыть">×</button>
|
| 55 |
-
</div>
|
| 56 |
|
| 57 |
<div id="iosInstallModal">
|
| 58 |
<div class="modal-content">
|
|
@@ -75,13 +45,7 @@
|
|
| 75 |
<script>
|
| 76 |
let deferredPrompt;
|
| 77 |
const installButton = document.getElementById('installButton');
|
| 78 |
-
const installWrapper = document.getElementById('installWrapper');
|
| 79 |
-
const closeInstallButton = document.getElementById('closeInstallButton');
|
| 80 |
-
|
| 81 |
const iosInstallPrompt = document.getElementById('iosInstallPrompt');
|
| 82 |
-
const iosInstallWrapper = document.getElementById('iosInstallWrapper');
|
| 83 |
-
const closeIosInstallButton = document.getElementById('closeIosInstallButton');
|
| 84 |
-
|
| 85 |
const iosInstallModal = document.getElementById('iosInstallModal');
|
| 86 |
const closeIosModal = document.getElementById('closeIosModal');
|
| 87 |
const openZoomModal = document.getElementById('openZoomModal');
|
|
@@ -89,11 +53,6 @@
|
|
| 89 |
const closeZoomModal = document.getElementById('closeZoomModal');
|
| 90 |
const zoomedImage = document.getElementById('zoomedImage');
|
| 91 |
|
| 92 |
-
// Ключи sessionStorage: очищаются при закрытии вкладки/приложения,
|
| 93 |
-
// поэтому при перезапуске кнопки снова появятся.
|
| 94 |
-
const ANDROID_CLOSED_KEY = 'installButtonClosedSession';
|
| 95 |
-
const IOS_CLOSED_KEY = 'iosInstallPromptClosedSession';
|
| 96 |
-
|
| 97 |
function isIos() {
|
| 98 |
return /iphone|ipad|ipod/i.test(navigator.userAgent);
|
| 99 |
}
|
|
@@ -102,23 +61,11 @@
|
|
| 102 |
return window.matchMedia('(display-mode: standalone)').matches || window.navigator.standalone;
|
| 103 |
}
|
| 104 |
|
| 105 |
-
function isAndroidClosedThisSession() {
|
| 106 |
-
return sessionStorage.getItem(ANDROID_CLOSED_KEY) === 'true';
|
| 107 |
-
}
|
| 108 |
-
|
| 109 |
-
function isIosClosedThisSession() {
|
| 110 |
-
return sessionStorage.getItem(IOS_CLOSED_KEY) === 'true';
|
| 111 |
-
}
|
| 112 |
-
|
| 113 |
-
// ===== Android / другие браузеры с beforeinstallprompt =====
|
| 114 |
window.addEventListener('beforeinstallprompt', (event) => {
|
| 115 |
event.preventDefault();
|
| 116 |
deferredPrompt = event;
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
installWrapper.style.display = 'flex';
|
| 120 |
-
installButton.classList.add('pulse-animation');
|
| 121 |
-
}
|
| 122 |
|
| 123 |
installButton.addEventListener('click', async () => {
|
| 124 |
deferredPrompt.prompt();
|
|
@@ -129,23 +76,15 @@
|
|
| 129 |
console.log('Пользователь отклонил запрос на установку');
|
| 130 |
}
|
| 131 |
deferredPrompt = null;
|
| 132 |
-
|
| 133 |
installButton.classList.remove('pulse-animation');
|
| 134 |
});
|
| 135 |
});
|
| 136 |
|
| 137 |
-
closeInstallButton.addEventListener('click', () => {
|
| 138 |
-
installWrapper.style.display = 'none';
|
| 139 |
-
sessionStorage.setItem(ANDROID_CLOSED_KEY, 'true');
|
| 140 |
-
});
|
| 141 |
-
|
| 142 |
-
// ===== iOS =====
|
| 143 |
if (isIos() && !isInStandaloneMode()) {
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
}
|
| 148 |
-
installWrapper.style.display = 'none';
|
| 149 |
|
| 150 |
iosInstallPrompt.addEventListener('click', () => {
|
| 151 |
iosInstallModal.style.display = 'block';
|
|
@@ -166,19 +105,14 @@
|
|
| 166 |
imageZoomModal.style.display = 'none';
|
| 167 |
});
|
| 168 |
} else {
|
| 169 |
-
|
| 170 |
-
|
| 171 |
if (deferredPrompt) {
|
| 172 |
installButton.classList.add('pulse-animation');
|
| 173 |
}
|
| 174 |
}
|
| 175 |
|
| 176 |
-
|
| 177 |
-
iosInstallWrapper.style.display = 'none';
|
| 178 |
-
sessionStorage.setItem(IOS_CLOSED_KEY, 'true');
|
| 179 |
-
});
|
| 180 |
-
|
| 181 |
-
if (isIos() && !isInStandaloneMode() && localStorage.getItem('iosInstallPromptShown') === 'true' && !isIosClosedThisSession()) {
|
| 182 |
setTimeout(() => {
|
| 183 |
iosInstallModal.style.display = 'block';
|
| 184 |
}, 5000);
|
|
@@ -196,6 +130,8 @@
|
|
| 196 |
});
|
| 197 |
}
|
| 198 |
|
|
|
|
|
|
|
| 199 |
// Перехват ошибок
|
| 200 |
window.addEventListener('error', (event) => {
|
| 201 |
console.error('Произошла ошибка:', event.message, event.filename, event.lineno);
|
|
|
|
| 13 |
<link rel="icon" href="icon.png" type="image/png">
|
| 14 |
<meta name="google-site-verification" content="V6EqDTA9Oj9V1OfNbnBHj5RKrdcXlABD8tqfEFVUHJY" />
|
| 15 |
<meta name="description" content=" ">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
</head>
|
| 17 |
<body>
|
| 18 |
<iframe
|
| 19 |
+
src="https://metastore-full.hf.space/090364/catalog"
|
| 20 |
frameborder="0"
|
| 21 |
allowfullscreen
|
| 22 |
allow="cross-origin-isolated; cookies"></iframe>
|
| 23 |
|
| 24 |
+
<button id="installButton">Установить приложение</button>
|
| 25 |
+
<button id="iosInstallPrompt">Установить приложение</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
<div id="iosInstallModal">
|
| 28 |
<div class="modal-content">
|
|
|
|
| 45 |
<script>
|
| 46 |
let deferredPrompt;
|
| 47 |
const installButton = document.getElementById('installButton');
|
|
|
|
|
|
|
|
|
|
| 48 |
const iosInstallPrompt = document.getElementById('iosInstallPrompt');
|
|
|
|
|
|
|
|
|
|
| 49 |
const iosInstallModal = document.getElementById('iosInstallModal');
|
| 50 |
const closeIosModal = document.getElementById('closeIosModal');
|
| 51 |
const openZoomModal = document.getElementById('openZoomModal');
|
|
|
|
| 53 |
const closeZoomModal = document.getElementById('closeZoomModal');
|
| 54 |
const zoomedImage = document.getElementById('zoomedImage');
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
function isIos() {
|
| 57 |
return /iphone|ipad|ipod/i.test(navigator.userAgent);
|
| 58 |
}
|
|
|
|
| 61 |
return window.matchMedia('(display-mode: standalone)').matches || window.navigator.standalone;
|
| 62 |
}
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
window.addEventListener('beforeinstallprompt', (event) => {
|
| 65 |
event.preventDefault();
|
| 66 |
deferredPrompt = event;
|
| 67 |
+
installButton.style.display = 'block';
|
| 68 |
+
installButton.classList.add('pulse-animation');
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
installButton.addEventListener('click', async () => {
|
| 71 |
deferredPrompt.prompt();
|
|
|
|
| 76 |
console.log('Пользователь отклонил запрос на установку');
|
| 77 |
}
|
| 78 |
deferredPrompt = null;
|
| 79 |
+
installButton.style.display = 'none';
|
| 80 |
installButton.classList.remove('pulse-animation');
|
| 81 |
});
|
| 82 |
});
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
if (isIos() && !isInStandaloneMode()) {
|
| 85 |
+
iosInstallPrompt.style.display = 'block';
|
| 86 |
+
installButton.style.display = 'none';
|
| 87 |
+
iosInstallPrompt.classList.add('pulse-animation');
|
|
|
|
|
|
|
| 88 |
|
| 89 |
iosInstallPrompt.addEventListener('click', () => {
|
| 90 |
iosInstallModal.style.display = 'block';
|
|
|
|
| 105 |
imageZoomModal.style.display = 'none';
|
| 106 |
});
|
| 107 |
} else {
|
| 108 |
+
installButton.style.display = deferredPrompt ? 'block' : 'none';
|
| 109 |
+
iosInstallPrompt.style.display = 'none';
|
| 110 |
if (deferredPrompt) {
|
| 111 |
installButton.classList.add('pulse-animation');
|
| 112 |
}
|
| 113 |
}
|
| 114 |
|
| 115 |
+
if (isIos() && !isInStandaloneMode() && localStorage.getItem('iosInstallPromptShown') === 'true') {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
setTimeout(() => {
|
| 117 |
iosInstallModal.style.display = 'block';
|
| 118 |
}, 5000);
|
|
|
|
| 130 |
});
|
| 131 |
}
|
| 132 |
|
| 133 |
+
// Отладка сообщений от iframe -- УДАЛЕНО, так как не решает проблему авторизации и не несет полезной нагрузки в данном контексте. Для отладки лучше использовать инструменты разработчика в браузере.
|
| 134 |
+
|
| 135 |
// Перехват ошибок
|
| 136 |
window.addEventListener('error', (event) => {
|
| 137 |
console.error('Произошла ошибка:', event.message, event.filename, event.lineno);
|