]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/root-helpers/utils.ts
Don't manage remote channels
[github/Chocobozzz/PeerTube.git] / client / src / root-helpers / utils.ts
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
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
22 function wait (ms: number) {
23 return new Promise<void>(res => {
24 setTimeout(() => res(), ms)
25 })
26 }
27
28 export {
29 copyToClipboard,
30 objectToUrlEncoded,
31 wait
32 }