Update content of files

This commit is contained in:
GitHub Action 2022-12-14 13:55:38 +00:00
parent 1d1f8532e4
commit 581280a754
4 changed files with 36 additions and 10 deletions

View file

@ -983,22 +983,27 @@
}
var webAppScanQrPopupOpened = false;
function onScanQrPopupClosed(eventType, eventData) {
function onQrTextReceived(eventType, eventData) {
if (webAppScanQrPopupOpened) {
var popupData = webAppScanQrPopupOpened;
webAppScanQrPopupOpened = false;
var data = null;
if (typeof eventData.data !== 'undefined') {
data = eventData.data;
}
if (popupData.callback) {
popupData.callback(data);
if (popupData.callback(data)) {
webAppScanQrPopupOpened = false;
WebView.postEvent('web_app_close_scan_qr_popup', false);
}
}
receiveWebViewEvent('scanQrPopupClosed', {
receiveWebViewEvent('qrTextReceived', {
data: data
});
}
}
function onScanQrPopupClosed(eventType, eventData) {
webAppScanQrPopupOpened = false;
}
var webAppClipboardRequests = {};
function onClipboardTextReceived(eventType, eventData) {
@ -1320,6 +1325,15 @@
};
WebView.postEvent('web_app_open_scan_qr_popup', false, popup_params);
};
WebApp.closeScanQrPopup = function () {
if (!versionAtLeast('6.4')) {
console.error('[Telegram.WebApp] Method closeScanQrPopup is not supported in version ' + webAppVersion);
throw Error('WebAppMethodUnsupported');
}
webAppScanQrPopupOpened = false;
WebView.postEvent('web_app_close_scan_qr_popup', false);
};
WebApp.readTextFromClipboard = function (callback) {
if (!versionAtLeast('6.4')) {
console.error('[Telegram.WebApp] Method readTextFromClipboard is not supported in version ' + webAppVersion);
@ -1356,6 +1370,7 @@
WebView.onEvent('viewport_changed', onViewportChanged);
WebView.onEvent('invoice_closed', onInvoiceClosed);
WebView.onEvent('popup_closed', onPopupClosed);
WebView.onEvent('qr_text_received', onQrTextReceived);
WebView.onEvent('scan_qr_popup_closed', onScanQrPopupClosed);
WebView.onEvent('clipboard_text_received', onClipboardTextReceived);
WebView.postEvent('web_app_request_theme');

View file

@ -9,7 +9,7 @@
<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?27"></script>
<script src="https://tg.dev/js/telegram-web-app.js?28"></script>
<script>
function setThemeClass() {
document.documentElement.className = Telegram.WebApp.colorScheme;

View file

@ -8,7 +8,7 @@
<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?27"></script>
<script src="https://tg.dev/js/telegram-web-app.js?28"></script>
<script>
function setThemeClass() {
document.documentElement.className = Telegram.WebApp.colorScheme;
@ -78,6 +78,7 @@
<li><a href="javascript:;" onclick="DemoApp.showConfirm('Are you sure?');">showConfirm</a></li>
<li><a href="javascript:;" onclick="DemoApp.showPopup();">showPopup</a></li>
<li><a href="javascript:;" onclick="DemoApp.showScanQrPopup();">showScanQrPopup</a></li>
<li><a href="javascript:;" onclick="DemoApp.showScanQrPopup(true);">showScanQrPopup (links only)</a></li>
</ul>
</div>
<p>Haptics:</p>
@ -104,7 +105,7 @@
<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?7"></script>
<script src="/js/webappdemo.js?8"></script>
<script>
Telegram.WebApp.onEvent('themeChanged', function() {
$('#theme_data').html(JSON.stringify(Telegram.WebApp.themeParams, null, 2));

View file

@ -188,12 +188,22 @@ var DemoApp = {
}
});
},
showScanQrPopup: function() {
showScanQrPopup: function(links_only) {
Telegram.WebApp.showScanQrPopup({
text: 'for test purposes'
text: links_only ? 'with any link' : 'for test purposes'
}, function(text) {
if (text !== null) {
if (links_only) {
var lower_text = text.toSting().toLowerCase();
if (lower_text.substr(0, 7) == 'http://' ||
lower_text.substr(0, 8) == 'https://') {
setTimeout(function() {
Telegram.WebApp.openLink(text);
}, 50);
return true;
}
} else {
DemoApp.showAlert(text);
return true;
}
});
},