mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-07-05 22:01:43 +02:00
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
109cd63a7b | |||
8ea6b7f81a | |||
e7c10d43f5 | |||
2f7a57e084 | |||
c99e38b097 | |||
f6ec6d7c9b | |||
e69fa19ef3 | |||
cc422b31a4 | |||
9609d0ae7b | |||
506fd71433 | |||
f40b8cb0b2 | |||
49a6c036a3 | |||
f5a5a79a82 | |||
7ec449160a | |||
fecc5411da | |||
f704452171 | |||
135193813c | |||
bb57f72e64 |
39
build.ts
39
build.ts
@ -35,13 +35,42 @@ const postProcess = (str: string): string => {
|
|||||||
// Add ADDITIONAL CODE block
|
// Add ADDITIONAL CODE block
|
||||||
str = str.replace('var DEFAULT_FLAGS', '\n/* ADDITIONAL CODE */\n\nvar DEFAULT_FLAGS');
|
str = str.replace('var DEFAULT_FLAGS', '\n/* ADDITIONAL CODE */\n\nvar DEFAULT_FLAGS');
|
||||||
|
|
||||||
// Minify SVG
|
str = str.replaceAll('(e) => `', 'e => `');
|
||||||
str = str.replaceAll(/= "(<svg.*)";/g, function(match) {
|
|
||||||
match = match.replaceAll(/\\n*\s*/g, '');
|
// Simplify object definitions
|
||||||
return match;
|
// {[1]: "a"} => {1: "a"}
|
||||||
|
str = str.replaceAll(/\[(\d+)\]: /g, '$1: ');
|
||||||
|
// {["a"]: 1, ["b-c"]: 2} => {a: 1, "b-c": 2}
|
||||||
|
str = str.replaceAll(/\["([^"]+)"\]: /g, function(match, p1) {
|
||||||
|
if (p1.includes('-') || p1.match(/^\d/)) {
|
||||||
|
p1 = `"${p1}"`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return p1 + ': ';
|
||||||
});
|
});
|
||||||
|
|
||||||
str = str.replaceAll('(e) => `', 'e => `');
|
// Minify SVG import code
|
||||||
|
const svgMap = {}
|
||||||
|
str = str.replaceAll(/var ([\w_]+) = ("<svg.*?");\n\n/g, function(match, p1, p2) {
|
||||||
|
// Remove new lines in SVG
|
||||||
|
p2 = p2.replaceAll(/\\n*\s*/g, '');
|
||||||
|
|
||||||
|
svgMap[p1] = p2;
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const name in svgMap) {
|
||||||
|
str = str.replace(`: ${name}`, `: ${svgMap[name]}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Collapse empty brackets
|
||||||
|
str = str.replaceAll(/\{[\s\n]+\}/g, '{}');
|
||||||
|
|
||||||
|
// Collapse if/else blocks without curly braces
|
||||||
|
str = str.replaceAll(/((if \(.*?\)|else)\n\s+)/g, '$2 ');
|
||||||
|
|
||||||
|
// Remove blank lines
|
||||||
|
str = str.replaceAll(/\n([\s]*)\n/g, "\n");
|
||||||
|
|
||||||
assert(str.includes('/* ADDITIONAL CODE */'));
|
assert(str.includes('/* ADDITIONAL CODE */'));
|
||||||
assert(str.includes('window.BX_EXPOSED = BxExposed'));
|
assert(str.includes('window.BX_EXPOSED = BxExposed'));
|
||||||
|
2
dist/better-xcloud.meta.js
vendored
2
dist/better-xcloud.meta.js
vendored
@ -1,5 +1,5 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Better xCloud
|
// @name Better xCloud
|
||||||
// @namespace https://github.com/redphx
|
// @namespace https://github.com/redphx
|
||||||
// @version 5.7.5
|
// @version 5.7.7
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
2982
dist/better-xcloud.user.js
vendored
2982
dist/better-xcloud.user.js
vendored
File diff suppressed because one or more lines are too long
@ -179,15 +179,3 @@ button.bx-inactive {
|
|||||||
opacity: 0.2;
|
opacity: 0.2;
|
||||||
background: transparent !important;
|
background: transparent !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bx-button-shortcut {
|
|
||||||
max-width: max-content;
|
|
||||||
margin: 10px 0 0 0;
|
|
||||||
flex: 1 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 568px) and (max-height: 480px) {
|
|
||||||
.bx-button-shortcut {
|
|
||||||
margin: 8px 0 0 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
21
src/assets/css/misc.styl
Normal file
21
src/assets/css/misc.styl
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
.bx-product-details-buttons {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
button {
|
||||||
|
max-width: max-content;
|
||||||
|
margin: 10px 0 0 0;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 568px) and (max-height: 480px) {
|
||||||
|
.bx-product-details-buttons {
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
button {
|
||||||
|
margin: 8px 0 0 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -37,14 +37,6 @@
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
span {
|
|
||||||
font-weight: bold;
|
|
||||||
font-size: 18px;
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.bx-remote-play-resolution {
|
.bx-remote-play-resolution {
|
||||||
@ -94,7 +86,7 @@
|
|||||||
|
|
||||||
.bx-remote-play-power-state {
|
.bx-remote-play-power-state {
|
||||||
color: #888;
|
color: #888;
|
||||||
font-size: 14px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bx-remote-play-connect-button {
|
.bx-remote-play-connect-button {
|
||||||
|
@ -300,6 +300,7 @@
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
align-self: center;
|
align-self: center;
|
||||||
margin-bottom: 0 !important;
|
margin-bottom: 0 !important;
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
+ * {
|
+ * {
|
||||||
margin: 0 0 0 auto;
|
margin: 0 0 0 auto;
|
||||||
|
@ -16,3 +16,4 @@
|
|||||||
@import 'game-bar.styl';
|
@import 'game-bar.styl';
|
||||||
@import 'stream-stats.styl';
|
@import 'stream-stats.styl';
|
||||||
@import 'mkb.styl';
|
@import 'mkb.styl';
|
||||||
|
@import 'misc.styl';
|
||||||
|
@ -4,12 +4,16 @@
|
|||||||
flex: 0 1 auto;
|
flex: 0 1 auto;
|
||||||
|
|
||||||
select {
|
select {
|
||||||
display: none !important;
|
// Render offscreen instead of "display: none" so we could get its size
|
||||||
|
position: absolute !important;
|
||||||
|
top: -9999px !important;
|
||||||
|
left: -9999px !important;
|
||||||
|
visibility: hidden !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
> div, button.bx-select-value {
|
> div, button.bx-select-value {
|
||||||
min-width: 110px;
|
min-width: 120px;
|
||||||
text-align: center;
|
text-align: left;
|
||||||
margin: 0 8px;
|
margin: 0 8px;
|
||||||
line-height: 24px;
|
line-height: 24px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
@ -53,7 +57,7 @@
|
|||||||
|
|
||||||
span {
|
span {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
text-align: center;
|
text-align: left;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,8 +67,10 @@ if (BX_FLAGS.SafariWorkaround && document.readyState !== 'loading') {
|
|||||||
// Stop loading
|
// Stop loading
|
||||||
window.stop();
|
window.stop();
|
||||||
|
|
||||||
// Show the reloading overlay
|
// We need to set it to an empty string first to work around Bun's bug
|
||||||
const css = compressCss(`
|
// https://github.com/oven-sh/bun/issues/12067
|
||||||
|
let css = '';
|
||||||
|
css += compressCss(`
|
||||||
.bx-reload-overlay {
|
.bx-reload-overlay {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
@ -115,6 +117,7 @@ if (BX_FLAGS.SafariWorkaround && document.readyState !== 'loading') {
|
|||||||
}, '🤓 ' + t('how-to-fix'));
|
}, '🤓 ' + t('how-to-fix'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show the reloading overlay
|
||||||
const $fragment = document.createDocumentFragment();
|
const $fragment = document.createDocumentFragment();
|
||||||
$fragment.appendChild(CE('style', {}, css));
|
$fragment.appendChild(CE('style', {}, css));
|
||||||
$fragment.appendChild(CE('div',{
|
$fragment.appendChild(CE('div',{
|
||||||
|
@ -314,6 +314,7 @@ export class ControllerShortcut {
|
|||||||
const $selectProfile = CE<HTMLSelectElement>('select', {class: 'bx-shortcut-profile', autocomplete: 'off'});
|
const $selectProfile = CE<HTMLSelectElement>('select', {class: 'bx-shortcut-profile', autocomplete: 'off'});
|
||||||
|
|
||||||
const $profile = PREF_CONTROLLER_FRIENDLY_UI ? BxSelectElement.wrap($selectProfile) : $selectProfile;
|
const $profile = PREF_CONTROLLER_FRIENDLY_UI ? BxSelectElement.wrap($selectProfile) : $selectProfile;
|
||||||
|
$profile.classList.add('bx-full-width');
|
||||||
|
|
||||||
const $container = CE('div', {
|
const $container = CE('div', {
|
||||||
'data-has-gamepad': 'false',
|
'data-has-gamepad': 'false',
|
||||||
@ -390,6 +391,8 @@ export class ControllerShortcut {
|
|||||||
|
|
||||||
if (PREF_CONTROLLER_FRIENDLY_UI) {
|
if (PREF_CONTROLLER_FRIENDLY_UI) {
|
||||||
const $bxSelect = BxSelectElement.wrap($select);
|
const $bxSelect = BxSelectElement.wrap($select);
|
||||||
|
$bxSelect.classList.add('bx-full-width');
|
||||||
|
|
||||||
$div.appendChild($bxSelect);
|
$div.appendChild($bxSelect);
|
||||||
setNearby($row, {
|
setNearby($row, {
|
||||||
focus: $bxSelect,
|
focus: $bxSelect,
|
||||||
|
@ -44,7 +44,7 @@ export class LoadingScreen {
|
|||||||
static #hideRocket() {
|
static #hideRocket() {
|
||||||
let $bgStyle = LoadingScreen.#$bgStyle;
|
let $bgStyle = LoadingScreen.#$bgStyle;
|
||||||
|
|
||||||
const css = compressCss(`
|
$bgStyle.textContent! += compressCss(`
|
||||||
#game-stream div[class*=RocketAnimation-module__container] > svg {
|
#game-stream div[class*=RocketAnimation-module__container] > svg {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@ -53,7 +53,6 @@ export class LoadingScreen {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
$bgStyle.textContent! += css;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static #setBackground(imageUrl: string) {
|
static #setBackground(imageUrl: string) {
|
||||||
@ -63,7 +62,7 @@ export class LoadingScreen {
|
|||||||
// Limit max width to reduce image size
|
// Limit max width to reduce image size
|
||||||
imageUrl = imageUrl + '?w=1920';
|
imageUrl = imageUrl + '?w=1920';
|
||||||
|
|
||||||
const css = compressCss(`
|
$bgStyle.textContent! += compressCss(`
|
||||||
#game-stream {
|
#game-stream {
|
||||||
background-color: transparent !important;
|
background-color: transparent !important;
|
||||||
background-position: center center !important;
|
background-position: center center !important;
|
||||||
@ -75,7 +74,6 @@ export class LoadingScreen {
|
|||||||
transition: opacity 0.3s ease-in-out !important;
|
transition: opacity 0.3s ease-in-out !important;
|
||||||
}
|
}
|
||||||
`) + `#game-stream {background-image: linear-gradient(#00000033, #000000e6), url(${imageUrl}) !important;}`;
|
`) + `#game-stream {background-image: linear-gradient(#00000033, #000000e6), url(${imageUrl}) !important;}`;
|
||||||
$bgStyle.textContent! += css;
|
|
||||||
|
|
||||||
const bg = new Image();
|
const bg = new Image();
|
||||||
bg.onload = e => {
|
bg.onload = e => {
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import { GamepadKey } from "@/enums/mkb";
|
import { GamepadKey } from "@/enums/mkb";
|
||||||
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
import { EmulatedMkbHandler } from "@/modules/mkb/mkb-handler";
|
import { EmulatedMkbHandler } from "@/modules/mkb/mkb-handler";
|
||||||
import { BxEvent } from "@/utils/bx-event";
|
import { BxEvent } from "@/utils/bx-event";
|
||||||
import { STATES } from "@/utils/global";
|
import { STATES } from "@/utils/global";
|
||||||
import { CE, isElementVisible } from "@/utils/html";
|
import { CE, isElementVisible } from "@/utils/html";
|
||||||
import { setNearby } from "@/utils/navigation-utils";
|
import { setNearby } from "@/utils/navigation-utils";
|
||||||
|
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||||
|
|
||||||
export enum NavigationDirection {
|
export enum NavigationDirection {
|
||||||
UP = 1,
|
UP = 1,
|
||||||
@ -154,6 +156,57 @@ export class NavigationDialogManager {
|
|||||||
|
|
||||||
// Hide dialog when the Guide menu is shown
|
// Hide dialog when the Guide menu is shown
|
||||||
window.addEventListener(BxEvent.XCLOUD_GUIDE_MENU_SHOWN, e => this.hide());
|
window.addEventListener(BxEvent.XCLOUD_GUIDE_MENU_SHOWN, e => this.hide());
|
||||||
|
|
||||||
|
// Calculate minimum width of controller-friendly <select> elements
|
||||||
|
if (getPref(PrefKey.UI_CONTROLLER_FRIENDLY)) {
|
||||||
|
const observer = new MutationObserver(mutationList => {
|
||||||
|
if (mutationList.length === 0 || mutationList[0].addedNodes.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get dialog
|
||||||
|
const $dialog = mutationList[0].addedNodes[0];
|
||||||
|
if (!$dialog || !($dialog instanceof HTMLElement)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find un-calculated <select> elements
|
||||||
|
this.calculateSelectBoxes($dialog);
|
||||||
|
});
|
||||||
|
observer.observe(this.$container, {childList: true});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
calculateSelectBoxes($root: HTMLElement) {
|
||||||
|
const $selects = $root.querySelectorAll('.bx-select:not([data-calculated]) select');
|
||||||
|
$selects.forEach($select => {
|
||||||
|
const $parent = $select.parentElement! as HTMLElement;
|
||||||
|
|
||||||
|
// Don't apply to select.bx-full-width elements
|
||||||
|
if ($parent.classList.contains('bx-full-width')) {
|
||||||
|
$parent.dataset.calculated = 'true';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const rect = $select.getBoundingClientRect();
|
||||||
|
|
||||||
|
let $label;
|
||||||
|
let width = Math.ceil(rect.width);
|
||||||
|
if (!width) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($select as HTMLSelectElement).multiple) {
|
||||||
|
$label = $parent.querySelector('.bx-select-value') as HTMLElement;
|
||||||
|
width += 20; // Add checkbox's width
|
||||||
|
} else {
|
||||||
|
$label = $parent.querySelector('div') as HTMLElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set min-width
|
||||||
|
$label.style.minWidth = width + 'px';
|
||||||
|
$parent.dataset.calculated = 'true';
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleEvent(event: Event) {
|
handleEvent(event: Event) {
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import { ButtonStyle, CE, createButton } from "@/utils/html";
|
import { ButtonStyle, CE, createButton } from "@/utils/html";
|
||||||
import { NavigationDialog } from "./navigation-dialog";
|
import { NavigationDialog, type NavigationElement } from "./navigation-dialog";
|
||||||
import { PrefKey } from "@/enums/pref-keys";
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
import { BxIcon } from "@/utils/bx-icon";
|
import { BxIcon } from "@/utils/bx-icon";
|
||||||
import { getPref, setPref } from "@/utils/settings-storages/global-settings-storage";
|
import { getPref, setPref } from "@/utils/settings-storages/global-settings-storage";
|
||||||
import { t } from "@/utils/translation";
|
import { t } from "@/utils/translation";
|
||||||
import { RemotePlayConsoleState, RemotePlayManager } from "@/modules/remote-play-manager";
|
import { RemotePlayConsoleState, RemotePlayManager } from "@/modules/remote-play-manager";
|
||||||
|
import { BxSelectElement } from "@/web-components/bx-select";
|
||||||
|
import { BxEvent } from "@/utils/bx-event";
|
||||||
|
|
||||||
|
|
||||||
export class RemotePlayNavigationDialog extends NavigationDialog {
|
export class RemotePlayNavigationDialog extends NavigationDialog {
|
||||||
@ -35,48 +37,33 @@ export class RemotePlayNavigationDialog extends NavigationDialog {
|
|||||||
|
|
||||||
const $settingNote = CE('p', {});
|
const $settingNote = CE('p', {});
|
||||||
|
|
||||||
const resolutions = [1080, 720];
|
|
||||||
const currentResolution = getPref(PrefKey.REMOTE_PLAY_RESOLUTION);
|
const currentResolution = getPref(PrefKey.REMOTE_PLAY_RESOLUTION);
|
||||||
const $resolutionGroup = CE('div', {});
|
let $resolutions : HTMLSelectElement | NavigationElement = CE<HTMLSelectElement>('select', {},
|
||||||
|
CE('option', {value: '1080p'}, '1080p'),
|
||||||
|
CE('option', {value: '720p'}, '720p'),
|
||||||
|
);
|
||||||
|
|
||||||
const onResolutionChange = (e: Event) => {
|
if (getPref(PrefKey.UI_CONTROLLER_FRIENDLY)) {
|
||||||
const value = (e.target as HTMLInputElement).value;
|
$resolutions = BxSelectElement.wrap($resolutions as HTMLSelectElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
$resolutions.addEventListener('input', (e: Event) => {
|
||||||
|
const value = (e.target as HTMLSelectElement).value;
|
||||||
|
|
||||||
$settingNote.textContent = value === '1080p' ? '✅ ' + t('can-stream-xbox-360-games') : '❌ ' + t('cant-stream-xbox-360-games');
|
$settingNote.textContent = value === '1080p' ? '✅ ' + t('can-stream-xbox-360-games') : '❌ ' + t('cant-stream-xbox-360-games');
|
||||||
setPref(PrefKey.REMOTE_PLAY_RESOLUTION, value);
|
setPref(PrefKey.REMOTE_PLAY_RESOLUTION, value);
|
||||||
};
|
});
|
||||||
|
|
||||||
for (const resolution of resolutions) {
|
($resolutions as any).value = currentResolution;
|
||||||
const value = `${resolution}p`;
|
BxEvent.dispatch($resolutions, 'input', {
|
||||||
const id = `bx_radio_xhome_resolution_${resolution}`;
|
manualTrigger: true,
|
||||||
|
});
|
||||||
const $radio = CE<HTMLInputElement>('input', {
|
|
||||||
type: 'radio',
|
|
||||||
value: value,
|
|
||||||
id: id,
|
|
||||||
name: 'bx_radio_xhome_resolution',
|
|
||||||
}, value);
|
|
||||||
|
|
||||||
$radio.addEventListener('input', onResolutionChange);
|
|
||||||
|
|
||||||
const $label = CE('label', {
|
|
||||||
for: id,
|
|
||||||
class: 'bx-remote-play-resolution',
|
|
||||||
}, $radio, `${resolution}p`);
|
|
||||||
|
|
||||||
$resolutionGroup.appendChild($label);
|
|
||||||
|
|
||||||
if (currentResolution === value) {
|
|
||||||
$radio.checked = true;
|
|
||||||
$radio.dispatchEvent(new Event('input'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const $qualitySettings = CE('div', {
|
const $qualitySettings = CE('div', {
|
||||||
class: 'bx-remote-play-settings',
|
class: 'bx-remote-play-settings',
|
||||||
}, CE('div', {},
|
}, CE('div', {},
|
||||||
CE('label', {}, t('target-resolution'), $settingNote),
|
CE('label', {}, t('target-resolution'), $settingNote),
|
||||||
$resolutionGroup,
|
$resolutions,
|
||||||
));
|
));
|
||||||
|
|
||||||
$fragment.appendChild($qualitySettings);
|
$fragment.appendChild($qualitySettings);
|
||||||
|
@ -943,6 +943,11 @@ export class SettingsNavigationDialog extends NavigationDialog {
|
|||||||
for (const $child of Array.from(this.$settings.children)) {
|
for (const $child of Array.from(this.$settings.children)) {
|
||||||
if ($child.getAttribute('data-tab-group') === settingTab.group) {
|
if ($child.getAttribute('data-tab-group') === settingTab.group) {
|
||||||
$child.classList.remove('bx-gone');
|
$child.classList.remove('bx-gone');
|
||||||
|
|
||||||
|
// Calculate size of controller-friendly select boxes
|
||||||
|
if (getPref(PrefKey.UI_CONTROLLER_FRIENDLY)) {
|
||||||
|
this.dialogManager.calculateSelectBoxes($child as HTMLElement);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$child.classList.add('bx-gone');
|
$child.classList.add('bx-gone');
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
import { BX_FLAGS } from "@/utils/bx-flags";
|
import { BX_FLAGS } from "@/utils/bx-flags";
|
||||||
import { BxIcon } from "@/utils/bx-icon";
|
import { BxIcon } from "@/utils/bx-icon";
|
||||||
import { AppInterface } from "@/utils/global";
|
import { AppInterface } from "@/utils/global";
|
||||||
import { ButtonStyle, createButton } from "@/utils/html";
|
import { ButtonStyle, CE, createButton } from "@/utils/html";
|
||||||
import { t } from "@/utils/translation";
|
import { t } from "@/utils/translation";
|
||||||
|
|
||||||
export class ProductDetailsPage {
|
export class ProductDetailsPage {
|
||||||
private static $btnShortcut = AppInterface && createButton({
|
private static $btnShortcut = AppInterface && createButton({
|
||||||
classes: ['bx-button-shortcut'],
|
|
||||||
icon: BxIcon.CREATE_SHORTCUT,
|
icon: BxIcon.CREATE_SHORTCUT,
|
||||||
label: t('create-shortcut'),
|
label: t('create-shortcut'),
|
||||||
style: ButtonStyle.FOCUSABLE,
|
style: ButtonStyle.FOCUSABLE,
|
||||||
@ -17,7 +16,6 @@ export class ProductDetailsPage {
|
|||||||
});
|
});
|
||||||
|
|
||||||
private static $btnWallpaper = AppInterface && createButton({
|
private static $btnWallpaper = AppInterface && createButton({
|
||||||
classes: ['bx-button-shortcut'],
|
|
||||||
icon: BxIcon.DOWNLOAD,
|
icon: BxIcon.DOWNLOAD,
|
||||||
label: t('wallpaper'),
|
label: t('wallpaper'),
|
||||||
style: ButtonStyle.FOCUSABLE,
|
style: ButtonStyle.FOCUSABLE,
|
||||||
@ -48,17 +46,12 @@ export class ProductDetailsPage {
|
|||||||
// Find action buttons container
|
// Find action buttons container
|
||||||
const $container = document.querySelector('div[class*=ActionButtons-module__container]');
|
const $container = document.querySelector('div[class*=ActionButtons-module__container]');
|
||||||
if ($container && $container.parentElement) {
|
if ($container && $container.parentElement) {
|
||||||
const fragment = document.createDocumentFragment();
|
$container.parentElement.appendChild(CE('div', {
|
||||||
|
class: 'bx-product-details-buttons',
|
||||||
// Shortcut button
|
},
|
||||||
if (BX_FLAGS.DeviceInfo.deviceType === 'android') {
|
BX_FLAGS.DeviceInfo.deviceType === 'android' && ProductDetailsPage.$btnShortcut,
|
||||||
fragment.appendChild(ProductDetailsPage.$btnShortcut);
|
ProductDetailsPage.$btnWallpaper,
|
||||||
}
|
));
|
||||||
|
|
||||||
// Wallpaper button
|
|
||||||
fragment.appendChild(ProductDetailsPage.$btnWallpaper);
|
|
||||||
|
|
||||||
$container.parentElement.appendChild(fragment);
|
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ export function escapeHtml(html: string): string {
|
|||||||
|
|
||||||
export function isElementVisible($elm: HTMLElement): boolean {
|
export function isElementVisible($elm: HTMLElement): boolean {
|
||||||
const rect = $elm.getBoundingClientRect();
|
const rect = $elm.getBoundingClientRect();
|
||||||
return !!rect.width && !!rect.height;
|
return (rect.x >= 0 || rect.y >= 0) && !!rect.width && !!rect.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CTN = document.createTextNode.bind(document);
|
export const CTN = document.createTextNode.bind(document);
|
||||||
|
@ -135,8 +135,8 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
|||||||
'da-DK': 'dansk',
|
'da-DK': 'dansk',
|
||||||
'de-DE': 'Deutsch',
|
'de-DE': 'Deutsch',
|
||||||
'el-GR': 'Ελληνικά',
|
'el-GR': 'Ελληνικά',
|
||||||
'en-GB': 'English (United Kingdom)',
|
'en-GB': 'English (UK)',
|
||||||
'en-US': 'English (United States)',
|
'en-US': 'English (US)',
|
||||||
'es-ES': 'español (España)',
|
'es-ES': 'español (España)',
|
||||||
'es-MX': 'español (Latinoamérica)',
|
'es-MX': 'español (Latinoamérica)',
|
||||||
'fi-FI': 'suomi',
|
'fi-FI': 'suomi',
|
||||||
|
@ -2,7 +2,7 @@ import { NATIVE_FETCH } from "./bx-flags";
|
|||||||
import { BxLogger } from "./bx-logger";
|
import { BxLogger } from "./bx-logger";
|
||||||
|
|
||||||
export const SUPPORTED_LANGUAGES = {
|
export const SUPPORTED_LANGUAGES = {
|
||||||
'en-US': 'English (United States)',
|
'en-US': 'English (US)',
|
||||||
|
|
||||||
'ca-CA': 'Català',
|
'ca-CA': 'Català',
|
||||||
'da-DK': 'dansk',
|
'da-DK': 'dansk',
|
||||||
@ -171,7 +171,7 @@ const Texts = {
|
|||||||
(e: any) => `Dostępna jest nowa wersja ${e.version}`,
|
(e: any) => `Dostępna jest nowa wersja ${e.version}`,
|
||||||
(e: any) => `Versão ${e.version} disponível`,
|
(e: any) => `Versão ${e.version} disponível`,
|
||||||
,
|
,
|
||||||
,
|
(e: any) => `เวอร์ชัน ${e.version} พร้อมใช้งานแล้ว`,
|
||||||
,
|
,
|
||||||
(e: any) => `Доступна версія ${e.version}`,
|
(e: any) => `Доступна версія ${e.version}`,
|
||||||
(e: any) => `Đã có phiên bản ${e.version}`,
|
(e: any) => `Đã có phiên bản ${e.version}`,
|
||||||
@ -232,7 +232,7 @@ const Texts = {
|
|||||||
(e: any) => `Zalecane ustawienia dla ${e.device}`,
|
(e: any) => `Zalecane ustawienia dla ${e.device}`,
|
||||||
(e: any) => `Configurações recomendadas para ${e.device}`,
|
(e: any) => `Configurações recomendadas para ${e.device}`,
|
||||||
(e: any) => `Рекомендуемые настройки для ${e.device}`,
|
(e: any) => `Рекомендуемые настройки для ${e.device}`,
|
||||||
,
|
(e: any) => `การตั้งค่าที่แนะนำสำหรับ ${e.device}`,
|
||||||
(e: any) => `${e.device} için önerilen ayarlar`,
|
(e: any) => `${e.device} için önerilen ayarlar`,
|
||||||
(e: any) => `Рекомендовані налаштування для ${e.device}`,
|
(e: any) => `Рекомендовані налаштування для ${e.device}`,
|
||||||
(e: any) => `Cấu hình được đề xuất cho ${e.device}`,
|
(e: any) => `Cấu hình được đề xuất cho ${e.device}`,
|
||||||
|
@ -164,6 +164,10 @@ export class BxSelectElement {
|
|||||||
Object.defineProperty($div, 'value', {
|
Object.defineProperty($div, 'value', {
|
||||||
get() {
|
get() {
|
||||||
return $select.value;
|
return $select.value;
|
||||||
|
},
|
||||||
|
|
||||||
|
set(value) {
|
||||||
|
($div as any).setValue(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user