chore: fix indentation and semi in files

This commit is contained in:
Wesley F. Young committed 2024-08-09 10:37:09 +08:00
1 parent 65521bd840
commit 81e56a77dc
27 files changed
+1326 -1330

No files matched your search

+1 -1
View File
@@ -1,3 +1,3 @@
export const SettingButton = (text: string, id?: string, type: string = 'secondary') => {
return `<setting-button ${type ? `data-type="${type}"` : ''} ${id ? `id="${id}"` : ''}>${text}</setting-button>`;
return `<setting-button ${type ? `data-type="${type}"` : ''} ${id ? `id="${id}"` : ''}>${text}</setting-button>`;
};
+6 -6
View File
@@ -1,11 +1,11 @@
export const SettingItem = (
title: string,
subtitle?: string,
action?: string,
id?: string,
visible: boolean = true,
title: string,
subtitle?: string,
action?: string,
id?: string,
visible: boolean = true,
) => {
return `<setting-item ${id ? `id="${id}"` : ''} ${!visible ? 'is-hidden' : ''}>
return `<setting-item ${id ? `id="${id}"` : ''} ${!visible ? 'is-hidden' : ''}>
<div>
<setting-text>${title}</setting-text>
${subtitle ? `<setting-text data-type="secondary">${subtitle}</setting-text>` : ''}
+5 -5
View File
@@ -1,10 +1,10 @@
export const SettingList = (
items: string[],
title?: string,
isCollapsible: boolean = false,
direction: string = 'column',
items: string[],
title?: string,
isCollapsible: boolean = false,
direction: string = 'column',
) => {
return `<setting-section ${title && !isCollapsible ? `data-title="${title}"` : ''}>
return `<setting-section ${title && !isCollapsible ? `data-title="${title}"` : ''}>
<setting-panel>
<setting-list ${direction ? `data-direction="${direction}"` : ''} ${isCollapsible ? 'is-collapsible' : ''} ${title && isCollapsible ? `data-title="${title}"` : ''}>
${items.join('')}
+1 -1
View File
@@ -1,3 +1,3 @@
export const SettingOption = (text: string, value?: string, isSelected: boolean = false) => {
return `<setting-option ${value ? `data-value="${value}"` : ''} ${isSelected ? 'is-selected' : ''}>${text}</setting-option>`;
return `<setting-option ${value ? `data-value="${value}"` : ''} ${isSelected ? 'is-selected' : ''}>${text}</setting-option>`;
};
+46 -46
View File
@@ -20,65 +20,65 @@ SelectTemplate.innerHTML = `<style>
</div>`;
window.customElements.define(
'ob-setting-select',
class extends HTMLElement {
readonly _button: HTMLDivElement;
readonly _text: HTMLInputElement;
readonly _context: HTMLUListElement;
'ob-setting-select',
class extends HTMLElement {
readonly _button: HTMLDivElement;
readonly _text: HTMLInputElement;
readonly _context: HTMLUListElement;
constructor() {
super();
constructor() {
super();
this.attachShadow({ mode: 'open' });
this.shadowRoot?.append(SelectTemplate.content.cloneNode(true));
this.attachShadow({ mode: 'open' });
this.shadowRoot?.append(SelectTemplate.content.cloneNode(true));
this._button = this.shadowRoot.querySelector('div[part="button"]');
this._text = this.shadowRoot.querySelector('input[part="current-text"]');
this._context = this.shadowRoot.querySelector('ul[part="option-list"]');
this._button = this.shadowRoot.querySelector('div[part="button"]');
this._text = this.shadowRoot.querySelector('input[part="current-text"]');
this._context = this.shadowRoot.querySelector('ul[part="option-list"]');
const buttonClick = () => {
const isHidden = this._context.classList.toggle('hidden');
window[`${isHidden ? 'remove' : 'add'}EventListener`]('pointerdown', windowPointerDown);
};
const buttonClick = () => {
const isHidden = this._context.classList.toggle('hidden');
window[`${isHidden ? 'remove' : 'add'}EventListener`]('pointerdown', windowPointerDown);
};
const windowPointerDown = ({ target }) => {
if (!this.contains(target)) buttonClick();
};
const windowPointerDown = ({ target }) => {
if (!this.contains(target)) buttonClick();
};
this._button.addEventListener('click', buttonClick);
this._context.addEventListener('click', ({ target }: MouseEventExtend) => {
if (target.tagName !== 'SETTING-OPTION') return;
buttonClick();
this._button.addEventListener('click', buttonClick);
this._context.addEventListener('click', ({ target }: MouseEventExtend) => {
if (target.tagName !== 'SETTING-OPTION') return;
buttonClick();
if (target.hasAttribute('is-selected')) return;
if (target.hasAttribute('is-selected')) return;
this.querySelectorAll('setting-option[is-selected]').forEach((dom) => dom.toggleAttribute('is-selected'));
target.toggleAttribute('is-selected');
this.querySelectorAll('setting-option[is-selected]').forEach((dom) => dom.toggleAttribute('is-selected'));
target.toggleAttribute('is-selected');
this._text.value = target.textContent as string;
this.dispatchEvent(
new CustomEvent('selected', {
bubbles: true,
composed: true,
detail: {
name: target.textContent,
value: target.dataset.value,
},
}),
);
});
this._text.value = target.textContent as string;
this.dispatchEvent(
new CustomEvent('selected', {
bubbles: true,
composed: true,
detail: {
name: target.textContent,
value: target.dataset.value,
},
}),
);
});
this._text.value = this.querySelector('setting-option[is-selected]')?.textContent as string;
}
},
this._text.value = this.querySelector('setting-option[is-selected]')?.textContent as string;
}
},
);
export const SettingSelect = (items: Array<{ text: string; value: string }>, configKey?: string, configValue?: any) => {
return `<ob-setting-select ${configKey ? `data-config-key="${configKey}"` : ''}>
return `<ob-setting-select ${configKey ? `data-config-key="${configKey}"` : ''}>
${items
.map((e, i) => {
return SettingOption(e.text, e.value, configKey && configValue ? configValue === e.value : i === 0);
})
.join('')}
.map((e, i) => {
return SettingOption(e.text, e.value, configKey && configValue ? configValue === e.value : i === 0);
})
.join('')}
</ob-setting-select>`;
};
+1 -1
View File
@@ -1,5 +1,5 @@
export const SettingSwitch = (configKey?: string, isActive: boolean = false, extraData?: Record<string, string>) => {
return `<setting-switch
return `<setting-switch
${configKey ? `data-config-key="${configKey}"` : ''}
${isActive ? 'is-active' : ''}
${extraData ? Object.keys(extraData).map((key) => `data-${key}="${extraData[key]}"`) : ''}
+35 -35
View File
@@ -33,42 +33,42 @@ export interface OB11Config {
}
class WebUiApiOB11ConfigWrapper {
private retCredential: string = '';
async Init(Credential: string) {
this.retCredential = Credential;
}
async GetOB11Config(): Promise<OB11Config> {
const ConfigResponse = await fetch('../api/OB11Config/GetConfig', {
method: 'POST',
headers: {
Authorization: 'Bearer ' + this.retCredential,
'Content-Type': 'application/json',
},
});
if (ConfigResponse.status == 200) {
const ConfigResponseJson = await ConfigResponse.json();
if (ConfigResponseJson.code == 0) {
return ConfigResponseJson?.data;
}
private retCredential: string = '';
async Init(Credential: string) {
this.retCredential = Credential;
}
return {} as OB11Config;
}
async SetOB11Config(config: OB11Config): Promise<boolean> {
const ConfigResponse = await fetch('../api/OB11Config/SetConfig', {
method: 'POST',
headers: {
Authorization: 'Bearer ' + this.retCredential,
'Content-Type': 'application/json',
},
body: JSON.stringify({ config: JSON.stringify(config) }),
});
if (ConfigResponse.status == 200) {
const ConfigResponseJson = await ConfigResponse.json();
if (ConfigResponseJson.code == 0) {
return true;
}
async GetOB11Config(): Promise<OB11Config> {
const ConfigResponse = await fetch('../api/OB11Config/GetConfig', {
method: 'POST',
headers: {
Authorization: 'Bearer ' + this.retCredential,
'Content-Type': 'application/json',
},
});
if (ConfigResponse.status == 200) {
const ConfigResponseJson = await ConfigResponse.json();
if (ConfigResponseJson.code == 0) {
return ConfigResponseJson?.data;
}
}
return {} as OB11Config;
}
async SetOB11Config(config: OB11Config): Promise<boolean> {
const ConfigResponse = await fetch('../api/OB11Config/SetConfig', {
method: 'POST',
headers: {
Authorization: 'Bearer ' + this.retCredential,
'Content-Type': 'application/json',
},
body: JSON.stringify({ config: JSON.stringify(config) }),
});
if (ConfigResponse.status == 200) {
const ConfigResponseJson = await ConfigResponse.json();
if (ConfigResponseJson.code == 0) {
return true;
}
}
return false;
}
return false;
}
}
export const OB11ConfigWrapper = new WebUiApiOB11ConfigWrapper();