Add info dialog

This commit is contained in:
CzBiX
2019-05-03 18:16:02 +08:00
parent bd4d5792f6
commit 94d715376b
12 changed files with 538 additions and 28 deletions

View File

@@ -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');