mirror of
https://github.com/MarshalX/telegram-crawler.git
synced 2024-11-28 19:23:11 +01:00
168 lines
8.3 KiB
HTML
168 lines
8.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<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 http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
<meta name="MobileOptimized" content="176" />
|
|
<meta name="HandheldFriendly" content="True" />
|
|
<meta name="robots" content="noindex,nofollow" />
|
|
<script src="https://tg.dev/js/telegram-web-app.js?19"></script>
|
|
<script>
|
|
function setThemeClass() {
|
|
document.documentElement.className = Telegram.WebApp.colorScheme;
|
|
}
|
|
Telegram.WebApp.onEvent('themeChanged', setThemeClass);
|
|
setThemeClass();
|
|
|
|
</script>
|
|
<link href="https://tg.dev/css/bootstrap.min.css?3" rel="stylesheet">
|
|
<link href="https://tg.dev/css/bootstrap-extra.css?2" rel="stylesheet">
|
|
<link href="/css/webappdemo.css?1" rel="stylesheet">
|
|
</head>
|
|
<body class="" style="visibility: hidden;">
|
|
<section class="">
|
|
<button id="main_btn" onclick="DemoApp.sendMessage('');">Send «Hello, World!»</button>
|
|
<button id="with_webview_btn" onclick="DemoApp.sendMessage('', true);">Send «Hello, World!» with inline webview button</button>
|
|
<button id="data_btn" onclick="DemoApp.sendTime(true);">Send current time to bot (x10)</button>
|
|
<button onclick="DemoApp.expand();">Expand Webview</button>
|
|
<button onclick="DemoApp.toggleMainButton(this);">Hide Main Button</button>
|
|
<input type="text" placeholder="Input text in regular input..." />
|
|
<div class="input" contenteditable="true" data-placeholder="Input text in contenteditable field..."></div>
|
|
<div id="peer_wrap">
|
|
<img id="peer_photo" class="chat_img" src="">
|
|
<span id="peer_name"></span>
|
|
</div>
|
|
</section>
|
|
<section>
|
|
<div id="btn_status" class="hint" style="display: none;">
|
|
</div>
|
|
<p>Test links:</p>
|
|
<ul>
|
|
<li><a id="regular_link" href="?nextpage=1">Regular link #1</a> (opens inside webview)</li>
|
|
<li><a href="https://telegram.org/" target="_blank">target="_blank" link</a> (opens outside webview)</li>
|
|
<li><a href="javascript:window.open('https://telegram.org/');">window.open() link</a> (opens outside webview)</li>
|
|
<li><a href="https://t.me/like">LikeBot t.me link</a> (opens inside Telegram app)</li>
|
|
<li><a href="javascript:Telegram.WebApp.openTelegramLink('https://t.me/vote');">web_app_open_tg_link()</a> (opens inside Telegram app)</li>
|
|
<li><a href="javascript:Telegram.WebApp.openLink('https://google.com/');">web_app_open_link()</a> (opens outside webview)</li>
|
|
<li><a href="tg://resolve?domain=vote">VoteBot tg:// link</a> (does not open)</li>
|
|
</ul>
|
|
<p>Test permissions:</p>
|
|
<ul>
|
|
<li><a href="javascript:;" onclick="return DemoApp.requestLocation(this);">Request Location</a> <span></span></li>
|
|
<li><a href="javascript:;" onclick="return DemoApp.requestVideo(this);">Request Video</a> <span></span></li>
|
|
<li><a href="javascript:;" onclick="return DemoApp.requestAudio(this);">Request Audio</a> <span></span></li>
|
|
</ul>
|
|
<p>Test alerts:</p>
|
|
<ul>
|
|
<li><a href="javascript:;" onclick="alert('Hello!');">alert</a></li>
|
|
<li><a href="javascript:;" onclick="confirm('Are you sure?');">confirm</a></li>
|
|
<li><a href="javascript:;" onclick="prompt('How old are you?');">prompt</a></li>
|
|
</ul>
|
|
<p>Haptics:</p>
|
|
<ul>
|
|
<li>Impact: <a href="javascript:Telegram.WebApp.HapticFeedback.impactOccurred('heavy');">heavy</a>, <a href="javascript:Telegram.WebApp.HapticFeedback.impactOccurred('light');">light</a>, <a href="javascript:Telegram.WebApp.HapticFeedback.impactOccurred('medium');">medium</a>, <a href="javascript:Telegram.WebApp.HapticFeedback.impactOccurred('rigid');">rigid</a>, <a href="javascript:Telegram.WebApp.HapticFeedback.impactOccurred('soft');">soft</a><br><br></li>
|
|
<li>Notification: <a href="javascript:Telegram.WebApp.HapticFeedback.notificationOccurred('error');">error</a>, <a href="javascript:Telegram.WebApp.HapticFeedback.notificationOccurred('success');">success</a>, <a href="javascript:Telegram.WebApp.HapticFeedback.notificationOccurred('warning');">warning</a><br><br></li>
|
|
<li>Selection: <a href="javascript:Telegram.WebApp.HapticFeedback.selectionChanged();">changed</a><br><br></li>
|
|
</ul>
|
|
<p>Background: <input type="color" id="bg_color_input" /> <select id="bg_color_sel">
|
|
<option value="bg_color" selected>bg_color</option>
|
|
<option value="secondary_bg_color">secondary_bg_color</option>
|
|
<option value="custom" id="bg_color_val">custom...</option>
|
|
</select></p>
|
|
<pre><code id="webview_data"></code></pre>
|
|
<div class="hint">
|
|
Data passed to webview.
|
|
<span id="webview_data_status" class="status_need">Checking hash...</span>
|
|
</div>
|
|
<pre><code id="theme_data"></code></pre>
|
|
<div class="hint">
|
|
Theme params
|
|
</div>
|
|
</section>
|
|
<div class="viewport-border"></div>
|
|
<div class="viewport-stable_border"></div>
|
|
<script src="/js/jquery.min.js"></script>
|
|
<script src="https://tg.dev/js/bootstrap.min.js"></script>
|
|
<script src="/js/webappdemo.js?1"></script>
|
|
<script>
|
|
Telegram.WebApp.onEvent('themeChanged', function() {
|
|
$('#theme_data').html(JSON.stringify(Telegram.WebApp.themeParams, null, 2));
|
|
});
|
|
|
|
$('#main_btn').toggle(!!DemoApp.initDataUnsafe.query_id);
|
|
$('#with_webview_btn').toggle(!!DemoApp.initDataUnsafe.query_id && !DemoApp.initDataUnsafe.receiver);
|
|
// $('#data_btn').toggle(!DemoApp.initDataUnsafe.query_id || !DemoApp.initDataUnsafe.receiver);
|
|
$('#webview_data').html(JSON.stringify(DemoApp.initDataUnsafe, null, 2));
|
|
$('#theme_data').html(JSON.stringify(Telegram.WebApp.themeParams, null, 2));
|
|
$('#regular_link').attr('href', $('#regular_link').attr('href') + location.hash);
|
|
$('#text_field').focus();
|
|
|
|
if (DemoApp.initDataUnsafe.receiver) {
|
|
$('#peer_wrap').show();
|
|
$('#peer_name').text(DemoApp.initDataUnsafe.receiver.first_name + ' ' + DemoApp.initDataUnsafe.receiver.last_name);
|
|
if (DemoApp.initDataUnsafe.receiver.photo_url) {
|
|
$('#peer_photo').attr('src', DemoApp.initDataUnsafe.receiver.photo_url);
|
|
} else {
|
|
$('#peer_photo').hide();
|
|
}
|
|
}
|
|
else if (DemoApp.initDataUnsafe.chat) {
|
|
$('#peer_wrap').show();
|
|
$('#peer_name').text(DemoApp.initDataUnsafe.chat.title);
|
|
if (DemoApp.initDataUnsafe.chat.photo_url) {
|
|
$('#peer_photo').attr('src', DemoApp.initDataUnsafe.chat.photo_url);
|
|
} else {
|
|
$('#peer_photo').hide();
|
|
}
|
|
}
|
|
|
|
DemoApp.checkInitData();
|
|
|
|
DemoApp.init();
|
|
|
|
function setViewportData() {
|
|
$('.viewport-border').attr('text', window.innerWidth + ' x ' + round(Telegram.WebApp.viewportHeight, 2));
|
|
$('.viewport-stable_border').attr('text', window.innerWidth + ' x ' + round(Telegram.WebApp.viewportStableHeight, 2) + ' | is_expanded: ' + (Telegram.WebApp.isExpanded ? 'true' : 'false'));
|
|
}
|
|
Telegram.WebApp.setHeaderColor('bg_color');
|
|
Telegram.WebApp.onEvent('viewportChanged', setViewportData);
|
|
setViewportData();
|
|
Telegram.WebApp.onEvent('settingsButtonClicked', function() {
|
|
alert('Settings opened!');
|
|
});
|
|
|
|
var prev_bg_color_val = $('#bg_color_sel').val();
|
|
$('#bg_color_input').val(Telegram.WebApp.backgroundColor);
|
|
$('body').attr('style', '--tg-theme-bg-color:' + Telegram.WebApp.backgroundColor);
|
|
$('#bg_color_input').on('change', function(e) {
|
|
var color = e.target.value;
|
|
$('#bg_color_val').text(color);
|
|
$('#bg_color_sel').val('custom');
|
|
prev_bg_color_val = $('#bg_color_sel').val();
|
|
Telegram.WebApp.setBackgroundColor(color);
|
|
$('body').attr('style', '--tg-theme-bg-color:' + Telegram.WebApp.backgroundColor);
|
|
});
|
|
$('#bg_color_sel').on('change', function(e) {
|
|
var color_key = e.target.value;
|
|
if (color_key == 'custom') {
|
|
$('#bg_color_sel').val(prev_bg_color_val);
|
|
$('#bg_color_input').focus().click();
|
|
} else {
|
|
$('#bg_color_val').text('custom...');
|
|
Telegram.WebApp.setBackgroundColor(color_key);
|
|
$('body').attr('style', '--tg-theme-bg-color:' + Telegram.WebApp.backgroundColor);
|
|
$('#bg_color_input').val(Telegram.WebApp.backgroundColor);
|
|
prev_bg_color_val = $('#bg_color_sel').val();
|
|
}
|
|
});
|
|
Telegram.WebApp.onEvent('themeChanged', function() {
|
|
$('#bg_color_input').val(Telegram.WebApp.backgroundColor);
|
|
$('body').attr('style', '--tg-theme-bg-color:' + Telegram.WebApp.backgroundColor);
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|