Kgshop commited on
Commit
b86da75
·
verified ·
1 Parent(s): 3fe07a0

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +141 -19
index.html CHANGED
@@ -1,19 +1,141 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="ru">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Jayli_q - приложение </title>
7
+ <link rel="manifest" href="/manifest.json">
8
+ <link rel="stylesheet" href="style.css">
9
+ <link rel="apple-touch-icon" href="/icon.png">
10
+ <meta name="apple-mobile-web-app-capable" content="yes">
11
+ <meta name="apple-mobile-web-app-status-bar-style" content="default">
12
+ <link rel="icon" type="image/png" sizes="192x192" href="/icon.png">
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/247300/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">
29
+ <h2>Установите приложение</h2>
30
+ <a href="#" id="openZoomModal">
31
+ <img src="https://huggingface.co/spaces/Morshen/alpha/resolve/main/pwa_ios.png" alt="Инструкция по установке PWA на iOS">
32
+ </a>
33
+ <p>1. Нажмите кнопку "Поделиться" внизу Safari.</p>
34
+ <p>2. Выберите "На экран «Домой»".</p>
35
+ <p>3. Подтвердите установку.</p>
36
+ <button id="closeIosModal">Закрыть</button>
37
+ </div>
38
+ </div>
39
+
40
+ <div id="imageZoomModal">
41
+ <span id="closeZoomModal">×</span>
42
+ <img id="zoomedImage" src="" alt="Увеличенное изображение">
43
+ </div>
44
+
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');
52
+ const imageZoomModal = document.getElementById('imageZoomModal');
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
+ }
59
+
60
+ function isInStandaloneMode() {
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();
72
+ const { outcome } = await deferredPrompt.userChoice;
73
+ if (outcome === 'accepted') {
74
+ console.log('Пользователь принял запрос на установку');
75
+ } else {
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';
91
+ localStorage.setItem('iosInstallPromptShown', 'true');
92
+ });
93
+
94
+ closeIosModal.addEventListener('click', () => {
95
+ iosInstallModal.style.display = 'none';
96
+ });
97
+
98
+ openZoomModal.addEventListener('click', (event) => {
99
+ event.preventDefault();
100
+ zoomedImage.src = 'https://huggingface.co/spaces/Morshen/alpha/resolve/main/pwa_ios.png';
101
+ imageZoomModal.style.display = 'block';
102
+ });
103
+
104
+ closeZoomModal.addEventListener('click', () => {
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);
119
+ }
120
+
121
+ if ('serviceWorker' in navigator) {
122
+ window.addEventListener('load', () => {
123
+ navigator.serviceWorker.register('/service-worker.js')
124
+ .then((registration) => {
125
+ console.log('Сервисный рабочий процесс зарегистрирован:', registration);
126
+ })
127
+ .catch((error) => {
128
+ console.log('Ошибка регистрации сервисного рабочего процесса:', error);
129
+ });
130
+ });
131
+ }
132
+
133
+ // Отладка сообщений от iframe -- УДАЛЕНО, так как не решает проблему авторизации и не несет полезной нагрузки в данном контексте. Для отладки лучше использовать инструменты разработчика в браузере.
134
+
135
+ // Перехват ошибок
136
+ window.addEventListener('error', (event) => {
137
+ console.error('Произошла ошибка:', event.message, event.filename, event.lineno);
138
+ });
139
+ </script>
140
+ </body>
141
+ </html>