Skip to content

Commit

Permalink
Update content of files
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Action committed May 10, 2022
1 parent bf2e484 commit 0bdff38
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 18 deletions.
4 changes: 2 additions & 2 deletions data/promote.telegram.org.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ <h2>Log In</h2>
<script src="/js/jquery-ui.min.js?1"></script>
<script src="/js/jquery-ex.js?11"></script>
<script src="/js/tchart.min.js?18"></script>
<script src="/js/health.js?17"></script>
<script src="/js/health.js?18"></script>

<script>ajInit({"version":573,"apiUrl":"\/api?hash=telegram-crawler","unauth":true});</script>
<script>ajInit({"version":574,"apiUrl":"\/api?hash=telegram-crawler","unauth":true});</script>
<script id="aj_script">l.add({"WEB_AB_WARNING_HEADER":"Turn off ad blocker","WEB_POPUP_CLOSE_BTN":"Close","WEB_AB_WARNING_TEXT":"You appear to be using an ad blocker that may prevent pages on the Telegram Ad Platform from working as expected.<br\/><br\/>Please turn off your ad blocker or add <a href=\"http:\/\/promote.telegram.org\/\">promote.telegram.org<\/a> as an exception to manage your promoted messages."});
window.enableInlineVideo&&$('video').each(function(){enableInlineVideo(this)});
Ads.init();
Expand Down
4 changes: 2 additions & 2 deletions data/promote.telegram.org/auth.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ <h2>Log In</h2>
<script src="/js/jquery-ui.min.js?1"></script>
<script src="/js/jquery-ex.js?11"></script>
<script src="/js/tchart.min.js?18"></script>
<script src="/js/health.js?17"></script>
<script src="/js/health.js?18"></script>

<script>ajInit({"version":573,"apiUrl":"\/api?hash=telegram-crawler","unauth":true});</script>
<script>ajInit({"version":574,"apiUrl":"\/api?hash=telegram-crawler","unauth":true});</script>
<script id="aj_script">l.add({"WEB_AB_WARNING_HEADER":"Turn off ad blocker","WEB_POPUP_CLOSE_BTN":"Close","WEB_AB_WARNING_TEXT":"You appear to be using an ad blocker that may prevent pages on the Telegram Ad Platform from working as expected.<br\/><br\/>Please turn off your ad blocker or add <a href=\"http:\/\/promote.telegram.org\/\">promote.telegram.org<\/a> as an exception to manage your promoted messages."});
openPopup('#login-popup-container');
window.enableInlineVideo&&$('video').each(function(){enableInlineVideo(this)});
Expand Down
4 changes: 2 additions & 2 deletions data/promote.telegram.org/basics.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ <h2>Log In</h2>
<script src="/js/jquery-ui.min.js?1"></script>
<script src="/js/jquery-ex.js?11"></script>
<script src="/js/tchart.min.js?18"></script>
<script src="/js/health.js?17"></script>
<script src="/js/health.js?18"></script>

<script>ajInit({"version":573,"apiUrl":"\/api?hash=telegram-crawler","unauth":true});</script>
<script>ajInit({"version":574,"apiUrl":"\/api?hash=telegram-crawler","unauth":true});</script>
<script id="aj_script">l.add({"WEB_AB_WARNING_HEADER":"Turn off ad blocker","WEB_POPUP_CLOSE_BTN":"Close","WEB_AB_WARNING_TEXT":"You appear to be using an ad blocker that may prevent pages on the Telegram Ad Platform from working as expected.<br\/><br\/>Please turn off your ad blocker or add <a href=\"http:\/\/promote.telegram.org\/\">promote.telegram.org<\/a> as an exception to manage your promoted messages."});
window.enableInlineVideo&&$('video').each(function(){enableInlineVideo(this)});
Ads.init();
Expand Down
4 changes: 2 additions & 2 deletions data/promote.telegram.org/getting-started.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ <h2>Log In</h2>
<script src="/js/jquery-ui.min.js?1"></script>
<script src="/js/jquery-ex.js?11"></script>
<script src="/js/tchart.min.js?18"></script>
<script src="/js/health.js?17"></script>
<script src="/js/health.js?18"></script>

<script>ajInit({"version":573,"apiUrl":"\/api?hash=telegram-crawler","unauth":true});</script>
<script>ajInit({"version":574,"apiUrl":"\/api?hash=telegram-crawler","unauth":true});</script>
<script id="aj_script">l.add({"WEB_AB_WARNING_HEADER":"Turn off ad blocker","WEB_POPUP_CLOSE_BTN":"Close","WEB_AB_WARNING_TEXT":"You appear to be using an ad blocker that may prevent pages on the Telegram Ad Platform from working as expected.<br\/><br\/>Please turn off your ad blocker or add <a href=\"http:\/\/promote.telegram.org\/\">promote.telegram.org<\/a> as an exception to manage your promoted messages."});
window.enableInlineVideo&&$('video').each(function(){enableInlineVideo(this)});
Ads.init();
Expand Down
4 changes: 2 additions & 2 deletions data/promote.telegram.org/guidelines.html
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ <h2>Log In</h2>
<script src="/js/jquery-ui.min.js?1"></script>
<script src="/js/jquery-ex.js?11"></script>
<script src="/js/tchart.min.js?18"></script>
<script src="/js/health.js?17"></script>
<script src="/js/health.js?18"></script>

<script>ajInit({"version":573,"apiUrl":"\/api?hash=telegram-crawler","unauth":true});</script>
<script>ajInit({"version":574,"apiUrl":"\/api?hash=telegram-crawler","unauth":true});</script>
<script id="aj_script">l.add({"WEB_AB_WARNING_HEADER":"Turn off ad blocker","WEB_POPUP_CLOSE_BTN":"Close","WEB_AB_WARNING_TEXT":"You appear to be using an ad blocker that may prevent pages on the Telegram Ad Platform from working as expected.<br\/><br\/>Please turn off your ad blocker or add <a href=\"http:\/\/promote.telegram.org\/\">promote.telegram.org<\/a> as an exception to manage your promoted messages."});
window.enableInlineVideo&&$('video').each(function(){enableInlineVideo(this)});
Ads.init();
Expand Down
2 changes: 1 addition & 1 deletion data/promote.telegram.org/js/health.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function fetchGraph(id, tokenData, retry) {
}
var loadingEl = domEl.querySelector('.chart_wrap_loading');
retry = retry || 0;
return fetch('/asyncgraph', {
return fetch('/asyncgraph' + (tokenData.test ? '?_test=1' : ''), {
method: 'post',
headers: {
"Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
Expand Down
4 changes: 2 additions & 2 deletions data/promote.telegram.org/tos.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ <h2>Log In</h2>
<script src="/js/jquery-ui.min.js?1"></script>
<script src="/js/jquery-ex.js?11"></script>
<script src="/js/tchart.min.js?18"></script>
<script src="/js/health.js?17"></script>
<script src="/js/health.js?18"></script>

<script>ajInit({"version":573,"apiUrl":"\/api?hash=telegram-crawler","unauth":true});</script>
<script>ajInit({"version":574,"apiUrl":"\/api?hash=telegram-crawler","unauth":true});</script>
<script id="aj_script">l.add({"WEB_AB_WARNING_HEADER":"Turn off ad blocker","WEB_POPUP_CLOSE_BTN":"Close","WEB_AB_WARNING_TEXT":"You appear to be using an ad blocker that may prevent pages on the Telegram Ad Platform from working as expected.<br\/><br\/>Please turn off your ad blocker or add <a href=\"http:\/\/promote.telegram.org\/\">promote.telegram.org<\/a> as an exception to manage your promoted messages."});
window.enableInlineVideo&&$('video').each(function(){enableInlineVideo(this)});
Ads.init();
Expand Down
43 changes: 42 additions & 1 deletion data/telegram.org/js/telegram-web-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,21 @@
return mainButton;
})();

var webAppInvoices = {};
function onInvoiceClosed(eventType, eventData) {
if (eventData.slug && webAppInvoices[eventData.slug]) {
var invoiceData = webAppInvoices[eventData.slug];
delete webAppInvoices[eventData.slug];
if (invoiceData.callback) {
invoiceData.callback(eventData.status);
}
receiveWebViewEvent('invoiceClosed', {
url: invoiceData.url,
status: eventData.status
});
}
}

if (!window.Telegram) {
window.Telegram = {};
}
Expand Down Expand Up @@ -740,7 +755,7 @@
}
WebView.postEvent('web_app_data_send', false, {data: data});
};
WebApp.openTgLink = function (url) {
WebApp.openTelegramLink = function (url) {
var a = document.createElement('A');
a.href = url;
if (a.protocol != 'http:' &&
Expand All @@ -759,6 +774,31 @@
location.href = 'https://t.me' + path_full;
}
};
WebApp.openInvoice = function (url, callback) {
var a = document.createElement('A'), match, slug;
a.href = url;
if (a.protocol != 'http:' &&
a.protocol != 'https:' ||
a.hostname != 't.me' ||
!(match = a.pathname.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/)) ||
!(slug = match[2])) {
console.error('[Telegram.WebApp] Invoice url is invalid', url);
throw Error('WebAppInvoiceUrlInvalid');
}
if (!versionAtLeast('1.1')) {
console.error('[Telegram.WebApp] Method openInvoice is not supported in version ' + webAppVersion);
throw Error('WebAppMethodUnsupported');
}
if (webAppInvoices[slug]) {
console.error('[Telegram.WebApp] Invoice is already opened');
throw Error('WebAppInvoiceOpened');
}
webAppInvoices[slug] = {
url: url,
callback: callback
};
WebView.postEvent('web_app_open_invoice', false, {slug: slug});
};
WebApp.ready = function () {
WebView.postEvent('web_app_ready');
};
Expand All @@ -780,6 +820,7 @@

WebView.onEvent('theme_changed', onThemeChanged);
WebView.onEvent('viewport_changed', onViewportChanged);
WebView.onEvent('invoice_closed', onInvoiceClosed);
WebView.postEvent('web_app_request_theme');
WebView.postEvent('web_app_request_viewport');

Expand Down
4 changes: 2 additions & 2 deletions data/webappcontent.telegram.org/cafe.html
Original file line number Diff line number Diff line change
Expand Up @@ -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?7"></script>
<script src="https://tg.dev/js/telegram-web-app.js?8"></script>
<script>
function setThemeClass() {
document.documentElement.className = Telegram.WebApp.colorScheme;
Expand Down Expand Up @@ -441,7 +441,7 @@ <h2 class="cafe-order-header">Your Order</h2>
</div>
<script src="https://tg.dev/js/jquery.min.js"></script>
<script src="https://tg.dev/js/tgsticker.js?27"></script>
<script src="/js/cafe.js?17"></script>
<script src="/js/cafe.js?18"></script>
<script>Cafe.init({"apiUrl":"\/cafe\/api","userId":0,"userHash":null});</script>
</body>
</html>
Expand Down
3 changes: 2 additions & 1 deletion data/webappcontent.telegram.org/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta name="MobileOptimized" content="176" />
<meta name="HandheldFriendly" content="True" />
<meta name="robots" content="noindex,nofollow" />
<script src="https://telegram.org/js/telegram-web-app.js?7"></script>
<script src="https://telegram.org/js/telegram-web-app.js?8"></script>
<script>
function setThemeClass() {
document.documentElement.className = Telegram.WebApp.colorScheme;
Expand Down Expand Up @@ -170,6 +170,7 @@
<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/VoteBot');">web_app_open_tg_link()</a> (opens inside Telegram app)</li>
<li><a href="tg://resolve?domain=vote">VoteBot tg:// link</a> (does not open)</li>
</ul>
<p>Test permissions:</p>
Expand Down
18 changes: 17 additions & 1 deletion data/webappcontent.telegram.org/js/cafe.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,27 @@ var Cafe = {
params.user_id = Cafe.userId;
params.user_hash = Cafe.userHash;
}
var invoiceSupported = Telegram.WebApp.isVersionAtLeast('1.1');
if (invoiceSupported) {
params.invoice = 1;
}
Cafe.toggleLoading(true);
Cafe.apiRequest('makeOrder', params, function(result) {
Cafe.toggleLoading(false);
if (result.ok) {
Telegram.WebApp.close();
if (invoiceSupported) {
Telegram.WebApp.openInvoice(result.invoice_url, function(status) {
if (status == 'paid') {
Telegram.WebApp.close();
} else if (status == 'failed') {
Cafe.showStatus('Payment has been failed.');
} else {
Cafe.showStatus('You have cancelled this order.');
}
});
} else {
Telegram.WebApp.close();
}
}
if (result.error) {
Cafe.showStatus(result.error);
Expand Down

0 comments on commit 0bdff38

Please sign in to comment.