]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/root-helpers/utils.ts
Translated using Weblate (Persian)
[github/Chocobozzz/PeerTube.git] / client / src / root-helpers / utils.ts
... / ...
CommitLineData
1function 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
10function 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
22function wait (ms: number) {
23 return new Promise<void>(res => {
24 setTimeout(() => res(), ms)
25 })
26}
27
28export {
29 copyToClipboard,
30 objectToUrlEncoded,
31 wait
32}