-
Notifications
You must be signed in to change notification settings - Fork 1
/
webview.html
89 lines (77 loc) · 2.74 KB
/
webview.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
<meta name="MobileOptimized" content="176" />
<meta name="HandheldFriendly" content="True" />
<meta name="robots" content="noindex,nofollow" />
<title></title>
<script src="https://telegram.org/js/telegram-web-app.js?1"></script>
<script>
function setThemeClass() {
document.documentElement.className = Telegram.WebApp.colorScheme;
}
Telegram.WebApp.onEvent('themeChanged', setThemeClass);
setThemeClass();
</script>
<style>
body {
font-family: sans-serif;
background-color: var(--tg-theme-bg-color, #ffffff);
color: var(--tg-theme-text-color, #222222);
font-size: 16px;
margin: 0;
padding: 0;
color-scheme: var(--tg-color-scheme);
}
section {
padding: 15px 15px;
text-align: center;
display: flex;
flex-direction: column;
}
a {
background-color: #5da6db;
border-radius: 25px;
display: inline-block;
cursor: pointer;
color: #ffffff;
font-family: Arial;
padding: 16px 31px;
text-decoration: none;
}
span {
padding: 15px;
}
</style>
</head>
<body>
<section>
<h1 id="greeting"></h1>
<h1 id="greeting2"></h1>
<a href="javascript:;" onclick="return requestLocation();"></i>Отметиться</a>
<br>
<span id="locationData"></span>
</section>
<script type="application/javascript">
Telegram.WebApp.ready();
const initData = Telegram.WebApp.initData || '';
const initDataUnsafe = Telegram.WebApp.initDataUnsafe || {};
document.querySelector('#greeting').innerHTML = `Привет, ${initDataUnsafe.user.first_name}!`;
document.querySelector('#greeting2').innerHTML = `Привет, ${initDataUnsafe.user.id}!`;
function requestLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
document.querySelector('#locationData').innerHTML = '' + position.coords.latitude + ', ' + position.coords.longitude + '';
});
} else {
document.querySelector('#locationData').innerHTML = '(Geolocation is not supported in this browser)';
}
return false;
}
</script>
</body>
</html>