Update content of files

This commit is contained in:
GitHub Action 2022-04-08 11:15:09 +00:00
parent b7014183f0
commit 60769e73f5
2 changed files with 33 additions and 2 deletions

View file

@ -450,9 +450,11 @@
mainButton.setParams = setParams;
mainButton.setText = function(text) {
mainButton.text = text;
return mainButton;
};
mainButton.onClick = function(callback) {
onClickCallback = callback;
return mainButton;
};
mainButton.show = function() {
return mainButton.setParams({is_visible: true});

View file

@ -150,7 +150,7 @@ function sendMessage(msg_id, with_webview) {
$('#btn_status').text('Sending...').removeClass('ok err').show();
$.ajax('/demo/sendMessage', {
type: 'POST',
data: {query_id: WebAppData.query_id, msg_id: msg_id || '', with_webview: !WebAppData.receiver && with_webview ? 1 : 0},
data: {_auth: WebAppDataRaw, query_id: WebAppData.query_id, msg_id: msg_id || '', with_webview: !WebAppData.receiver && with_webview ? 1 : 0},
dataType: 'json',
success: function(result) {
$('button').prop('disabled', false);
@ -173,6 +173,35 @@ function sendMessage(msg_id, with_webview) {
}
});
}
function changeButton() {
$('button').prop('disabled', true);
$('#btn_status').text('Changing button...').removeClass('ok err').show();
$.ajax('/demo/changeMenuButton', {
type: 'POST',
data: {_auth: WebAppDataRaw},
dataType: 'json',
success: function(result) {
$('button').prop('disabled', false);
if (result.response) {
if (result.response.ok) {
$('#btn_status').html('Button changed!').addClass('ok').show();
Telegram.WebApp.close();
} else {
$('#btn_status').text(result.response.description).addClass('err').show();
alert(result.response.description);
}
} else {
$('#btn_status').text('Unknown error').addClass('err').show();
alert('Unknown error');
}
},
error: function(xhr) {
$('button').prop('disabled', false);
$('#btn_status').text('Server error').addClass('err').show();
alert('Server error');
}
});
}
function byteLength(str) {
if (window.Blob) {
try { return new Blob([str]).size; } catch (e) {}
@ -254,7 +283,7 @@ if (WebAppData.query_id && WebAppDataRaw) {
$('#webview_data_status').show();
$.ajax('/demo/checkData', {
type: 'POST',
data: {data: WebAppDataRaw},
data: {_auth: WebAppDataRaw},
dataType: 'json',
success: function(result) {
if (result.ok) {