mirror of
https://github.com/CzBiX/qb-web.git
synced 2026-04-13 15:59:42 +08:00
Add info dialog
This commit is contained in:
17
src/utils.ts
17
src/utils.ts
@@ -46,3 +46,20 @@ export function torrentIsState(type: StateType, state: string) {
|
||||
export function sleep(ms: number) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
export function codeToFlag(code: string) {
|
||||
const magicNumber = 0x1F1A5;
|
||||
|
||||
code = code.toUpperCase();
|
||||
const codePoints = [...code].map((c) => magicNumber + c.charCodeAt(0));
|
||||
const char = String.fromCodePoint(...codePoints);
|
||||
const url = 'https://cdn.jsdelivr.net/npm/twemoji/2/svg/' +
|
||||
`${codePoints[0].toString(16)}-${codePoints[1].toString(16)}.svg`;
|
||||
|
||||
return {
|
||||
char,
|
||||
url,
|
||||
};
|
||||
}
|
||||
|
||||
export const isWindows = navigator.userAgent.includes('Windows');
|
||||
|
||||
Reference in New Issue
Block a user