mirror of
https://github.com/MarshalX/telegram-crawler.git
synced 2025-01-11 12:41:37 +01:00
Update content of files
This commit is contained in:
parent
4f4fd716d9
commit
0eaad39c79
4 changed files with 55 additions and 10 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue