]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/root-helpers/utils.ts
Update translations
[github/Chocobozzz/PeerTube.git] / client / src / root-helpers / utils.ts
index acfb565a3635af92122cddb89e68374358eaeb19..00bd92411247aedfb890ea38fac7e3bd4acca28d 100644 (file)
@@ -7,6 +7,26 @@ function objectToUrlEncoded (obj: any) {
   return str.join('&')
 }
 
+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)
+}
+
+function wait (ms: number) {
+  return new Promise<void>(res => {
+    setTimeout(() => res(), ms)
+  })
+}
+
 export {
-  objectToUrlEncoded
+  copyToClipboard,
+  objectToUrlEncoded,
+  wait
 }