mirror of
https://github.com/MarshalX/telegram-crawler.git
synced 2024-12-26 06:20:27 +01:00
Update content of files
This commit is contained in:
parent
8b6fa93ec2
commit
61d4b9fd58
3 changed files with 42 additions and 10 deletions
|
@ -391,19 +391,42 @@
|
|||
setCssProperty('viewport-stable-height', stable_height);
|
||||
}
|
||||
|
||||
var headerColor = 'bg_color';
|
||||
function setHeaderColor(color_key) {
|
||||
var headerColorKey = 'bg_color';
|
||||
function setHeaderColor(color) {
|
||||
if (!versionAtLeast('6.1')) {
|
||||
console.warn('[Telegram.WebApp] Header color is not supported in version ' + webAppVersion);
|
||||
return;
|
||||
}
|
||||
var color_key;
|
||||
if (color == 'bg_color' || color == 'secondary_bg_color') {
|
||||
color_key = color;
|
||||
} else {
|
||||
color_key = parseColorToHex(color);
|
||||
if (themeParams.bg_color &&
|
||||
themeParams.bg_color == color_key) {
|
||||
color_key = 'bg_color';
|
||||
} else if (themeParams.secondary_bg_color &&
|
||||
themeParams.secondary_bg_color == color_key) {
|
||||
color_key = 'secondary_bg_color';
|
||||
} else {
|
||||
color_key = false;
|
||||
}
|
||||
}
|
||||
if (color_key != 'bg_color' &&
|
||||
color_key != 'secondary_bg_color') {
|
||||
console.error('[Telegram.WebApp] Header color key should be one of \'bg_color\', \'secondary_bg_color\'', color_key);
|
||||
console.error('[Telegram.WebApp] Header color key should be one of Telegram.WebApp.themeParams.bg_color, Telegram.WebApp.themeParams.secondary_bg_color, \'bg_color\', \'secondary_bg_color\'', color);
|
||||
throw Error('WebAppHeaderColorKeyInvalid');
|
||||
}
|
||||
headerColor = color_key;
|
||||
headerColorKey = color_key;
|
||||
WebView.postEvent('web_app_set_header_color', false, {color_key: color_key});
|
||||
};
|
||||
|
||||
var backgroundColor = null;
|
||||
function setBackgroundColor(color) {
|
||||
if (!versionAtLeast('6.1')) {
|
||||
console.warn('[Telegram.WebApp] Background color is not supported in version ' + webAppVersion);
|
||||
return;
|
||||
}
|
||||
var bg_color = parseColorToHex(color);
|
||||
if (!bg_color) {
|
||||
console.error('[Telegram.WebApp] Background color format is invalid', color);
|
||||
|
@ -789,6 +812,11 @@
|
|||
return mainButton;
|
||||
})();
|
||||
|
||||
function onSettingsButtonPressed() {
|
||||
receiveWebViewEvent('settingsButtonClicked');
|
||||
}
|
||||
WebView.onEvent('settings_button_pressed', onSettingsButtonPressed);
|
||||
|
||||
var HapticFeedback = (function() {
|
||||
var hapticFeedback = {};
|
||||
|
||||
|
@ -888,7 +916,7 @@
|
|||
});
|
||||
Object.defineProperty(WebApp, 'headerColor', {
|
||||
set: function(val){ setHeaderColor(val); },
|
||||
get: function(){ return headerColor; },
|
||||
get: function(){ return themeParams[headerColorKey] || null; },
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(WebApp, 'backgroundColor', {
|
||||
|
|
|
@ -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?14"></script>
|
||||
<script src="https://tg.dev/js/telegram-web-app.js?16"></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://telegram.org/js/telegram-web-app.js?14"></script>
|
||||
<script src="https://telegram.org/js/telegram-web-app.js?16"></script>
|
||||
<script>
|
||||
function setThemeClass() {
|
||||
document.documentElement.className = Telegram.WebApp.colorScheme;
|
||||
|
@ -101,11 +101,13 @@
|
|||
section {
|
||||
padding: 15px;
|
||||
text-align: center;
|
||||
background-color: var(--tg-theme-bg-color, #ffffff);
|
||||
}
|
||||
section.gray {
|
||||
background-color: var(--tg-theme-secondary-bg-color, #efefef);
|
||||
}
|
||||
section + section {
|
||||
padding: 0 15px 65px;
|
||||
background-color: var(--tg-theme-bg-color, #ffffff);
|
||||
}
|
||||
p {
|
||||
margin: 40px 0 15px;
|
||||
|
@ -200,7 +202,7 @@
|
|||
</style>
|
||||
</head>
|
||||
<body style="visibility: hidden;">
|
||||
<section>
|
||||
<section class="">
|
||||
<button id="main_btn" onclick="sendMessage('');">Send «Hello, World!»</button>
|
||||
<button id="with_webview_btn" onclick="sendMessage('', true);">Send «Hello, World!» with inline webview button</button>
|
||||
<button id="data_btn" onclick="sendTime(true);">Send current time to bot (x10)</button>
|
||||
|
@ -451,7 +453,9 @@ function setViewportData() {
|
|||
Telegram.WebApp.setHeaderColor('bg_color');
|
||||
Telegram.WebApp.onEvent('viewportChanged', setViewportData);
|
||||
setViewportData();
|
||||
|
||||
Telegram.WebApp.onEvent('settingsButtonClicked', function() {
|
||||
alert('Settings opened!');
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
|
Loading…
Reference in a new issue