]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/root-helpers/utils.ts
Change bootstrap helpers and variables
[github/Chocobozzz/PeerTube.git] / client / src / root-helpers / utils.ts
index acfb565a3635af92122cddb89e68374358eaeb19..af94ed6cac82f0d3039e7609a2482e663417fae1 100644 (file)
@@ -1,12 +1,22 @@
-function objectToUrlEncoded (obj: any) {
-  const str: string[] = []
-  for (const key of Object.keys(obj)) {
-    str.push(encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]))
-  }
+function copyToClipboard (text: string) {
+  const el = document.createElement('textarea')
+  el.value = text
+  el.setAttribute('readonly', '')
+  el.style.position = 'absolute'
+  el.style.left = '-9999px'
+  document.body.appendChild(el)
+  el.select()
+  document.execCommand('copy')
+  document.body.removeChild(el)
+}
 
-  return str.join('&')
+function wait (ms: number) {
+  return new Promise<void>(res => {
+    setTimeout(() => res(), ms)
+  })
 }
 
 export {
-  objectToUrlEncoded
+  copyToClipboard,
+  wait
 }