mirror of
https://github.com/MarshalX/telegram-crawler.git
synced 2024-11-28 19:23:11 +01:00
Update content of files
This commit is contained in:
parent
75110f7544
commit
839b58b66d
3 changed files with 54 additions and 19 deletions
|
@ -291,6 +291,9 @@
|
|||
var webAppIsActive = true;
|
||||
var webAppIsFullscreen = false;
|
||||
var webAppIsOrientationLocked = false;
|
||||
var webAppBackgroundColor = 'bg_color';
|
||||
var webAppHeaderColorKey = 'bg_color';
|
||||
var webAppHeaderColor = null;
|
||||
|
||||
if (initParams.tgWebAppData && initParams.tgWebAppData.length) {
|
||||
webAppInitData = initParams.tgWebAppData;
|
||||
|
@ -318,6 +321,19 @@
|
|||
if (stored_theme_params) {
|
||||
setThemeParams(stored_theme_params);
|
||||
}
|
||||
var stored_def_colors = Utils.sessionStorageGet('defaultColors');
|
||||
if (initParams.tgWebAppDefaultColors && initParams.tgWebAppDefaultColors.length) {
|
||||
var defColorsRaw = initParams.tgWebAppDefaultColors;
|
||||
try {
|
||||
var def_colors = JSON.parse(defColorsRaw);
|
||||
if (def_colors) {
|
||||
setDefaultColors(def_colors);
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
if (stored_def_colors) {
|
||||
setDefaultColors(stored_def_colors);
|
||||
}
|
||||
if (initParams.tgWebAppVersion) {
|
||||
webAppVersion = initParams.tgWebAppVersion;
|
||||
}
|
||||
|
@ -461,6 +477,27 @@
|
|||
Utils.sessionStorageSet('themeParams', themeParams);
|
||||
}
|
||||
|
||||
function setDefaultColors(def_colors) {
|
||||
if (colorScheme == 'dark') {
|
||||
if (def_colors.bg_dark_color) {
|
||||
webAppBackgroundColor = def_colors.bg_dark_color;
|
||||
}
|
||||
if (def_colors.header_dark_color) {
|
||||
webAppHeaderColorKey = null;
|
||||
webAppHeaderColor = def_colors.header_dark_color;
|
||||
}
|
||||
} else {
|
||||
if (def_colors.bg_color) {
|
||||
webAppBackgroundColor = def_colors.bg_color;
|
||||
}
|
||||
if (def_colors.header_color) {
|
||||
webAppHeaderColorKey = null;
|
||||
webAppHeaderColor = def_colors.header_color;
|
||||
}
|
||||
}
|
||||
Utils.sessionStorageSet('defaultColors', def_colors);
|
||||
}
|
||||
|
||||
var webAppCallbacks = {};
|
||||
function generateCallbackId(len) {
|
||||
var tries = 100;
|
||||
|
@ -690,14 +727,13 @@
|
|||
}
|
||||
|
||||
|
||||
var headerColorKey = 'bg_color', headerColor = null;
|
||||
function getHeaderColor() {
|
||||
if (headerColorKey == 'secondary_bg_color') {
|
||||
if (webAppHeaderColorKey == 'secondary_bg_color') {
|
||||
return themeParams.secondary_bg_color;
|
||||
} else if (headerColorKey == 'bg_color') {
|
||||
} else if (webAppHeaderColorKey == 'bg_color') {
|
||||
return themeParams.bg_color;
|
||||
}
|
||||
return headerColor;
|
||||
return webAppHeaderColor;
|
||||
}
|
||||
function setHeaderColor(color) {
|
||||
if (!versionAtLeast('6.1')) {
|
||||
|
@ -729,32 +765,31 @@
|
|||
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');
|
||||
}
|
||||
headerColorKey = color_key;
|
||||
headerColor = head_color;
|
||||
webAppHeaderColorKey = color_key;
|
||||
webAppHeaderColor = head_color;
|
||||
updateHeaderColor();
|
||||
}
|
||||
var appHeaderColorKey = null, appHeaderColor = null;
|
||||
function updateHeaderColor() {
|
||||
if (appHeaderColorKey != headerColorKey ||
|
||||
appHeaderColor != headerColor) {
|
||||
appHeaderColorKey = headerColorKey;
|
||||
appHeaderColor = headerColor;
|
||||
if (appHeaderColorKey != webAppHeaderColorKey ||
|
||||
appHeaderColor != webAppHeaderColor) {
|
||||
appHeaderColorKey = webAppHeaderColorKey;
|
||||
appHeaderColor = webAppHeaderColor;
|
||||
if (appHeaderColor) {
|
||||
WebView.postEvent('web_app_set_header_color', false, {color: headerColor});
|
||||
WebView.postEvent('web_app_set_header_color', false, {color: webAppHeaderColor});
|
||||
} else {
|
||||
WebView.postEvent('web_app_set_header_color', false, {color_key: headerColorKey});
|
||||
WebView.postEvent('web_app_set_header_color', false, {color_key: webAppHeaderColorKey});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var backgroundColor = 'bg_color';
|
||||
function getBackgroundColor() {
|
||||
if (backgroundColor == 'secondary_bg_color') {
|
||||
if (webAppBackgroundColor == 'secondary_bg_color') {
|
||||
return themeParams.secondary_bg_color;
|
||||
} else if (backgroundColor == 'bg_color') {
|
||||
} else if (webAppBackgroundColor == 'bg_color') {
|
||||
return themeParams.bg_color;
|
||||
}
|
||||
return backgroundColor;
|
||||
return webAppBackgroundColor;
|
||||
}
|
||||
function setBackgroundColor(color) {
|
||||
if (!versionAtLeast('6.1')) {
|
||||
|
@ -771,7 +806,7 @@
|
|||
throw Error('WebAppBackgroundColorInvalid');
|
||||
}
|
||||
}
|
||||
backgroundColor = bg_color;
|
||||
webAppBackgroundColor = bg_color;
|
||||
updateBackgroundColor();
|
||||
}
|
||||
var appBackgroundColor = null;
|
||||
|
|
|
@ -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-beta.js?79"></script>
|
||||
<script src="https://tg.dev/js/telegram-web-app-beta.js?80"></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-beta.js?79"></script>
|
||||
<script src="https://tg.dev/js/telegram-web-app-beta.js?80"></script>
|
||||
<script>
|
||||
function setThemeClass() {
|
||||
document.documentElement.className = Telegram.WebApp.colorScheme;
|
||||
|
|
Loading…
Reference in a new issue