]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/root-helpers/utils.ts
Translate plugin settings
[github/Chocobozzz/PeerTube.git] / client / src / root-helpers / utils.ts
CommitLineData
4504f09f
RK
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
afff310e
RK
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
210856a7 22function wait (ms: number) {
72aa835e 23 return new Promise<void>(res => {
210856a7
C
24 setTimeout(() => res(), ms)
25 })
26}
27
4504f09f 28export {
afff310e 29 copyToClipboard,
210856a7
C
30 objectToUrlEncoded,
31 wait
4504f09f 32}