mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-07 16:17:20 +02:00
Add optionsGroup
This commit is contained in:
parent
7409956616
commit
368a6f726a
1
src/types/preferences.d.ts
vendored
1
src/types/preferences.d.ts
vendored
@ -1,5 +1,6 @@
|
|||||||
export type PreferenceSetting = {
|
export type PreferenceSetting = {
|
||||||
default: any;
|
default: any;
|
||||||
|
optionsGroup?: string;
|
||||||
options?: {[index: string]: string};
|
options?: {[index: string]: string};
|
||||||
multipleOptions?: {[index: string]: string};
|
multipleOptions?: {[index: string]: string};
|
||||||
unsupported?: string | boolean;
|
unsupported?: string | boolean;
|
||||||
|
@ -130,6 +130,7 @@ export class Preferences {
|
|||||||
label: t('bypass-region-restriction'),
|
label: t('bypass-region-restriction'),
|
||||||
note: '⚠️ ' + t('use-this-at-your-own-risk'),
|
note: '⚠️ ' + t('use-this-at-your-own-risk'),
|
||||||
default: 'off',
|
default: 'off',
|
||||||
|
optionsGroup: t('region'),
|
||||||
options: Object.assign({
|
options: Object.assign({
|
||||||
'off': t('off'),
|
'off': t('off'),
|
||||||
}, BypassServers),
|
}, BypassServers),
|
||||||
|
@ -30,11 +30,20 @@ export class SettingElement {
|
|||||||
// title: setting.label,
|
// title: setting.label,
|
||||||
tabindex: 0,
|
tabindex: 0,
|
||||||
}) as HTMLSelectElement;
|
}) as HTMLSelectElement;
|
||||||
|
|
||||||
|
let $parent: HTMLElement;
|
||||||
|
if (setting.optionsGroup) {
|
||||||
|
$parent = CE('optgroup', {'label': setting.optionsGroup});
|
||||||
|
$control.appendChild($parent);
|
||||||
|
} else {
|
||||||
|
$parent = $control;
|
||||||
|
}
|
||||||
|
|
||||||
for (let value in setting.options) {
|
for (let value in setting.options) {
|
||||||
const label = setting.options[value];
|
const label = setting.options[value];
|
||||||
|
|
||||||
const $option = CE<HTMLOptionElement>('option', {value: value}, label);
|
const $option = CE<HTMLOptionElement>('option', {value: value}, label);
|
||||||
$control.appendChild($option);
|
$parent.appendChild($option);
|
||||||
}
|
}
|
||||||
|
|
||||||
$control.value = currentValue;
|
$control.value = currentValue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user