Update content of files

This commit is contained in:
GitHub Action 2023-10-05 14:50:03 +00:00
parent 4f4fd716d9
commit 0eaad39c79
4 changed files with 55 additions and 10 deletions

View file

@ -1174,17 +1174,62 @@
}
}
function getRequestedContact(callback, timeout) {
var reqTo, fallbackTo, reqDelay = 0;
var reqInvoke = function() {
invokeCustomMethod('getRequestedContact', {}, function(err, res) {
if (res && res.length) {
clearTimeout(fallbackTo);
callback(res);
} else {
reqDelay += 50;
reqTo = setTimeout(reqInvoke, reqDelay);
}
});
};
var fallbackInvoke = function() {
clearTimeout(reqTo);
callback('');
};
fallbackTo = setTimeout(fallbackInvoke, timeout);
reqInvoke();
}
var WebAppContactRequested = false;
function onPhoneRequested(eventType, eventData) {
if (WebAppContactRequested) {
var requestData = WebAppContactRequested;
WebAppContactRequested = false;
if (requestData.callback) {
requestData.callback(eventData.status == 'sent');
}
receiveWebViewEvent('contactRequested', {
var requestSent = eventData.status == 'sent';
var webViewEvent = {
status: eventData.status
});
};
if (requestSent) {
getRequestedContact(function(res) {
if (res && res.length) {
webViewEvent.response = res;
webViewEvent.responseUnsafe = Utils.urlParseQueryString(res);
for (var key in webViewEvent.responseUnsafe) {
var val = webViewEvent.responseUnsafe[key];
try {
if (val.substr(0, 1) == '{' && val.substr(-1) == '}' ||
val.substr(0, 1) == '[' && val.substr(-1) == ']') {
webViewEvent.responseUnsafe[key] = JSON.parse(val);
}
} catch (e) {}
}
}
if (requestData.callback) {
requestData.callback(requestSent, webViewEvent);
}
receiveWebViewEvent('contactRequested', webViewEvent);
}, 3000);
} else {
if (requestData.callback) {
requestData.callback(requestSent, webViewEvent);
}
receiveWebViewEvent('contactRequested', webViewEvent);
}
}
}

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?36"></script>
<script src="https://tg.dev/js/telegram-web-app.js?37"></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?36"></script>
<script src="https://tg.dev/js/telegram-web-app.js?37"></script>
<script>
function setThemeClass() {
document.documentElement.className = Telegram.WebApp.colorScheme;
@ -139,7 +139,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?19"></script>
<script src="/js/webappdemo.js?21"></script>
<script>DemoApp.apiUrl = "/demo/api";
Telegram.WebApp.onEvent('themeChanged', function() {

View file

@ -190,9 +190,9 @@ var DemoApp = {
});
},
requestPhoneNumber: function(el) {
Telegram.WebApp.requestContact(function(sent) {
Telegram.WebApp.requestContact(function(sent, event) {
if (sent) {
$(el).next('span').text('(Phone number sent to the bot)').attr('class', 'ok');
$(el).next('span').text('(Phone number sent to the bot' + (event && event.responseUnsafe && event.responseUnsafe.contact && event.responseUnsafe.contact.phone_number ? ': +' + event.responseUnsafe.contact.phone_number : '') + ')').attr('class', 'ok');
} else {
$(el).next('span').html('(User declined this request)').attr('class', 'err');
}