mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 10:23:33 +00:00
Lint all files
This commit is contained in:
parent
22af76b4d6
commit
30e52ebb54
334 changed files with 76519 additions and 75932 deletions
|
|
@ -1,23 +1,23 @@
|
|||
export const constrainSidebarWidth = (num: number) => {
|
||||
if (num < 260) {
|
||||
return 260;
|
||||
}
|
||||
if (num < 260) {
|
||||
return 260;
|
||||
}
|
||||
|
||||
if (num > 400) {
|
||||
return 400;
|
||||
}
|
||||
if (num > 400) {
|
||||
return 400;
|
||||
}
|
||||
|
||||
return num;
|
||||
return num;
|
||||
};
|
||||
|
||||
export const constrainRightSidebarWidth = (num: number) => {
|
||||
if (num < 250) {
|
||||
return 250;
|
||||
}
|
||||
if (num < 250) {
|
||||
return 250;
|
||||
}
|
||||
|
||||
if (num > 960) {
|
||||
return 960;
|
||||
}
|
||||
if (num > 960) {
|
||||
return 960;
|
||||
}
|
||||
|
||||
return num;
|
||||
return num;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,24 +1,24 @@
|
|||
import formatDuration from 'format-duration';
|
||||
|
||||
export const formatDurationString = (duration: number) => {
|
||||
const rawDuration = formatDuration(duration).split(':');
|
||||
const rawDuration = formatDuration(duration).split(':');
|
||||
|
||||
let string;
|
||||
let string;
|
||||
|
||||
switch (rawDuration.length) {
|
||||
case 1:
|
||||
string = `${rawDuration[0]} sec`;
|
||||
break;
|
||||
case 2:
|
||||
string = `${rawDuration[0]} min ${rawDuration[1]} sec`;
|
||||
break;
|
||||
case 3:
|
||||
string = `${rawDuration[0]} hr ${rawDuration[1]} min ${rawDuration[2]} sec`;
|
||||
break;
|
||||
case 4:
|
||||
string = `${rawDuration[0]} day ${rawDuration[1]} hr ${rawDuration[2]} min ${rawDuration[3]} sec`;
|
||||
break;
|
||||
}
|
||||
switch (rawDuration.length) {
|
||||
case 1:
|
||||
string = `${rawDuration[0]} sec`;
|
||||
break;
|
||||
case 2:
|
||||
string = `${rawDuration[0]} min ${rawDuration[1]} sec`;
|
||||
break;
|
||||
case 3:
|
||||
string = `${rawDuration[0]} hr ${rawDuration[1]} min ${rawDuration[2]} sec`;
|
||||
break;
|
||||
case 4:
|
||||
string = `${rawDuration[0]} day ${rawDuration[1]} hr ${rawDuration[2]} min ${rawDuration[3]} sec`;
|
||||
break;
|
||||
}
|
||||
|
||||
return string;
|
||||
return string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
export const getHeaderColor = (rgbColor: string, opacity?: number) => {
|
||||
return rgbColor.replace('rgb', 'rgba').replace(')', `, ${opacity || 0.8})`);
|
||||
return rgbColor.replace('rgb', 'rgba').replace(')', `, ${opacity || 0.8})`);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export const normalizeServerUrl = (url: string) => {
|
||||
// Remove trailing slash
|
||||
return url.endsWith('/') ? url.slice(0, -1) : url;
|
||||
// Remove trailing slash
|
||||
return url.endsWith('/') ? url.slice(0, -1) : url;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,16 +2,16 @@ import isUndefined from 'lodash/isUndefined';
|
|||
import omitBy from 'lodash/omitBy';
|
||||
|
||||
export const parseSearchParams = (searchParams: Record<any, any>) => {
|
||||
const params = new URLSearchParams();
|
||||
const paramsWithoutUndefined = omitBy(searchParams, isUndefined);
|
||||
const params = new URLSearchParams();
|
||||
const paramsWithoutUndefined = omitBy(searchParams, isUndefined);
|
||||
|
||||
Object.entries(paramsWithoutUndefined).forEach(([key, value]) => {
|
||||
if (!Array.isArray(value)) {
|
||||
params.append(key, value.toString());
|
||||
} else {
|
||||
value.forEach((value) => params.append(key, value.toString()));
|
||||
}
|
||||
});
|
||||
Object.entries(paramsWithoutUndefined).forEach(([key, value]) => {
|
||||
if (!Array.isArray(value)) {
|
||||
params.append(key, value.toString());
|
||||
} else {
|
||||
value.forEach((value) => params.append(key, value.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
return params.toString();
|
||||
return params.toString();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
export const randomString = (length?: number) => {
|
||||
const charSet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
let string = '';
|
||||
for (let i = 0; i < (length || 12); i += 1) {
|
||||
const randomPoz = Math.floor(Math.random() * charSet.length);
|
||||
string += charSet.substring(randomPoz, randomPoz + 1);
|
||||
}
|
||||
return string;
|
||||
const charSet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
let string = '';
|
||||
for (let i = 0; i < (length || 12); i += 1) {
|
||||
const randomPoz = Math.floor(Math.random() * charSet.length);
|
||||
string += charSet.substring(randomPoz, randomPoz + 1);
|
||||
}
|
||||
return string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
export const setLocalStorageSettings = (type: 'player', object: any) => {
|
||||
const settings = JSON.parse(localStorage.getItem('settings') || '{}');
|
||||
const settings = JSON.parse(localStorage.getItem('settings') || '{}');
|
||||
|
||||
const newSettings = {
|
||||
...settings,
|
||||
[type]: { ...object },
|
||||
};
|
||||
const newSettings = {
|
||||
...settings,
|
||||
[type]: { ...object },
|
||||
};
|
||||
|
||||
localStorage.setItem('settings', JSON.stringify(newSettings));
|
||||
localStorage.setItem('settings', JSON.stringify(newSettings));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
export const titleCase = (str: string) => {
|
||||
return str.replace(/\w\S*/g, (txt) => {
|
||||
return txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase();
|
||||
});
|
||||
return str.replace(/\w\S*/g, (txt) => {
|
||||
return txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase();
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue