X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Froot-helpers%2Futils.ts;h=af94ed6cac82f0d3039e7609a2482e663417fae1;hb=ac24de4e7dce71067906d0b6858214c76bdbe026;hp=acfb565a3635af92122cddb89e68374358eaeb19;hpb=4504f09f6e85f09b0489debb547a17209d7176ea;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/root-helpers/utils.ts b/client/src/root-helpers/utils.ts index acfb565a3..af94ed6ca 100644 --- a/client/src/root-helpers/utils.ts +++ b/client/src/root-helpers/utils.ts @@ -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(res => { + setTimeout(() => res(), ms) + }) } export { - objectToUrlEncoded + copyToClipboard, + wait }