File size: 10,864 Bytes
d1900e5 3271f75 d1900e5 6494095 d1900e5 b9e72c1 9345bb0 e7aba96 3271f75 d1900e5 3271f75 5ed82df d1900e5 3271f75 1b16896 d1900e5 3271f75 a2084e7 3271f75 7731cce d1900e5 5ed82df 7731cce d1900e5 5ed82df 7731cce 5ed82df 7731cce 5ed82df d1900e5 7731cce 6494095 5ed82df d1900e5 5ed82df d1900e5 5ed82df 1b16896 7731cce 1b16896 6494095 1b16896 6494095 1b16896 6494095 7731cce 5ed82df 7731cce 5ed82df 7731cce 5ed82df 5175686 5ed82df d1900e5 5ed82df | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | <!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Anvico - приложение</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=" ">
<style>
/* Базовые стили для экрана пароля, чтобы он выглядел аккуратно */
#passwordScreen {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
width: 100%;
background-color: #f4f4f9;
font-family: Arial, sans-serif;
position: fixed;
top: 0;
left: 0;
z-index: 9999;
}
.password-container {
background: white;
padding: 30px;
border-radius: 12px;
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
text-align: center;
max-width: 90%;
width: 320px;
}
.password-container h2 {
margin-top: 0;
color: #333;
}
.password-container input {
width: 100%;
padding: 12px;
margin: 15px 0;
border: 1px solid #ccc;
border-radius: 8px;
box-sizing: border-box;
font-size: 16px;
}
.password-container button {
width: 100%;
padding: 12px;
background-color: #007bff;
color: white;
border: none;
border-radius: 8px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s;
}
.password-container button:hover {
background-color: #0056b3;
}
#errorMessage {
color: red;
font-size: 14px;
display: none;
margin-top: 10px;
}
/* Скрываем основной контент до ввода пароля */
#mainContent {
display: none;
height: 100vh;
width: 100%;
}
</style>
</head>
<body>
<!-- ЭКРАН ВВОДА ПАРОЛЯ -->
<div id="passwordScreen">
<div class="password-container">
<h2>Доступ закрыт</h2>
<p style="color: #666; font-size: 14px;">Введите пароль для входа в приложение</p>
<input type="password" id="passwordInput" placeholder="Введите пароль">
<button id="loginButton">Войти</button>
<div id="errorMessage">Неверный пароль. Попробуйте еще раз.</div>
</div>
</div>
<!-- ОСНОВНОЕ СОДЕРЖИМОЕ ПРИЛОЖЕНИЯ -->
<div id="mainContent">
<!-- Атрибут src заменен на data-src, чтобы страница не загружалась в фоне до ввода пароля -->
<iframe
id="appIframe"
data-src="https://metastore-full.hf.space/219382/catalog"
frameborder="0"
allowfullscreen
allow="cross-origin-isolated; cookies"
style="width: 100%; height: 100%; border: none;"></iframe>
<button id="installButton">Установить приложение</button>
<button id="iosInstallPrompt">Установить приложение</button>
<div id="iosInstallModal">
<div class="modal-content">
<h2>Установите приложение Anvico</h2>
<a href="#" id="openZoomModal">
<img src="https://huggingface.co/spaces/Morshen/alpha/resolve/main/pwa_ios.png" alt="Инструкция по установке PWA на iOS">
</a>
<p>1. Нажмите кнопку "Поделиться" внизу Safari.</p>
<p>2. Выберите "На экран «Домой»".</p>
<p>3. Подтвердите установку.</p>
<button id="closeIosModal">Закрыть</button>
</div>
</div>
<div id="imageZoomModal">
<span id="closeZoomModal">×</span>
<img id="zoomedImage" src="" alt="Увеличенное изображение">
</div>
</div>
<script>
// === ЛОГИКА АВТОРИЗАЦИИ ===
const passwordScreen = document.getElementById('passwordScreen');
const mainContent = document.getElementById('mainContent');
const passwordInput = document.getElementById('passwordInput');
const loginButton = document.getElementById('loginButton');
const errorMessage = document.getElementById('errorMessage');
const appIframe = document.getElementById('appIframe');
// Функция для разблокировки приложения
function unlockApp() {
passwordScreen.style.display = 'none';
mainContent.style.display = 'block';
// Загружаем iframe только после успешного входа
if (!appIframe.src) {
appIframe.src = appIframe.getAttribute('data-src');
}
}
// Проверяем, сохранен ли пароль на этом устройстве
if (localStorage.getItem('isAnvicoAuthenticated') === 'true') {
unlockApp();
}
// Обработчик кнопки "Войти"
loginButton.addEventListener('click', () => {
if (passwordInput.value === '999888008') {
localStorage.setItem('isAnvicoAuthenticated', 'true');
unlockApp();
} else {
errorMessage.style.display = 'block';
}
});
// Вход по нажатию Enter на клавиатуре
passwordInput.addEventListener('keypress', (event) => {
if (event.key === 'Enter') {
loginButton.click();
}
});
// === ОРИГИНАЛЬНАЯ ЛОГИКА PWA ===
let deferredPrompt;
const installButton = document.getElementById('installButton');
const iosInstallPrompt = document.getElementById('iosInstallPrompt');
const iosInstallModal = document.getElementById('iosInstallModal');
const closeIosModal = document.getElementById('closeIosModal');
const openZoomModal = document.getElementById('openZoomModal');
const imageZoomModal = document.getElementById('imageZoomModal');
const closeZoomModal = document.getElementById('closeZoomModal');
const zoomedImage = document.getElementById('zoomedImage');
function isIos() {
return /iphone|ipad|ipod/i.test(navigator.userAgent);
}
function isInStandaloneMode() {
return window.matchMedia('(display-mode: standalone)').matches || window.navigator.standalone;
}
window.addEventListener('beforeinstallprompt', (event) => {
event.preventDefault();
deferredPrompt = event;
installButton.style.display = 'block';
installButton.classList.add('pulse-animation');
installButton.addEventListener('click', async () => {
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');
});
});
if (isIos() && !isInStandaloneMode()) {
iosInstallPrompt.style.display = 'block';
installButton.style.display = 'none';
iosInstallPrompt.classList.add('pulse-animation');
iosInstallPrompt.addEventListener('click', () => {
iosInstallModal.style.display = 'block';
localStorage.setItem('iosInstallPromptShown', 'true');
});
closeIosModal.addEventListener('click', () => {
iosInstallModal.style.display = 'none';
});
openZoomModal.addEventListener('click', (event) => {
event.preventDefault();
zoomedImage.src = 'https://huggingface.co/spaces/Morshen/alpha/resolve/main/pwa_ios.png';
imageZoomModal.style.display = 'block';
});
closeZoomModal.addEventListener('click', () => {
imageZoomModal.style.display = 'none';
});
} else {
installButton.style.display = deferredPrompt ? 'block' : 'none';
iosInstallPrompt.style.display = 'none';
if (deferredPrompt) {
installButton.classList.add('pulse-animation');
}
}
if (isIos() && !isInStandaloneMode() && localStorage.getItem('iosInstallPromptShown') === 'true') {
setTimeout(() => {
iosInstallModal.style.display = 'block';
}, 5000);
}
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> |