]>
Commit | Line | Data |
---|---|---|
4504f09f RK |
1 | function objectToUrlEncoded (obj: any) { |
2 | const str: string[] = [] | |
3 | for (const key of Object.keys(obj)) { | |
4 | str.push(encodeURIComponent(key) + '=' + encodeURIComponent(obj[key])) | |
5 | } | |
6 | ||
7 | return str.join('&') | |
8 | } | |
9 | ||
afff310e RK |
10 | function copyToClipboard (text: string) { |
11 | const el = document.createElement('textarea') | |
12 | el.value = text | |
13 | el.setAttribute('readonly', '') | |
14 | el.style.position = 'absolute' | |
15 | el.style.left = '-9999px' | |
16 | document.body.appendChild(el) | |
17 | el.select() | |
18 | document.execCommand('copy') | |
19 | document.body.removeChild(el) | |
20 | } | |
21 | ||
210856a7 | 22 | function wait (ms: number) { |
72aa835e | 23 | return new Promise<void>(res => { |
210856a7 C |
24 | setTimeout(() => res(), ms) |
25 | }) | |
26 | } | |
27 | ||
4504f09f | 28 | export { |
afff310e | 29 | copyToClipboard, |
210856a7 C |
30 | objectToUrlEncoded, |
31 | wait | |
4504f09f | 32 | } |