From 4c92ead37f946fa7fcd1f1c0e604e23cb7641868 Mon Sep 17 00:00:00 2001 From: Leon van Kammen Date: Sun, 15 Oct 2023 13:38:49 +0200 Subject: [PATCH] copy url to clipboard --- dist/utils.js | 8 ++++++++ example/assets/js/utils.js | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/dist/utils.js b/dist/utils.js index 3e17af8..326fc74 100644 --- a/dist/utils.js +++ b/dist/utils.js @@ -291,6 +291,14 @@ function embed(){ let newHash = document.location.hash.replace(/[&]?pos=[0-9\.-]+,[0-9\.-]+,[0-9\.-]+/,'') newHash += `&${lastPos}` document.location.hash = newHash.replace(/&&/,'&') + // copy url to clipboard + var dummy = document.createElement('input'), + text = window.location.href; + document.body.appendChild(dummy); + dummy.value = text; + dummy.select(); + document.execCommand('copy'); + document.body.removeChild(dummy); // End of *TODO* window.notify(`Link copied to clipboard! ❤️
ps. to embed this experience in your website,
copy/paste the following into your HTML:
`,{timeout:10000}) } diff --git a/example/assets/js/utils.js b/example/assets/js/utils.js index 4663137..b0602b6 100644 --- a/example/assets/js/utils.js +++ b/example/assets/js/utils.js @@ -291,6 +291,14 @@ export function embed(){ let newHash = document.location.hash.replace(/[&]?pos=[0-9\.-]+,[0-9\.-]+,[0-9\.-]+/,'') newHash += `&${lastPos}` document.location.hash = newHash.replace(/&&/,'&') + // copy url to clipboard + var dummy = document.createElement('input'), + text = window.location.href; + document.body.appendChild(dummy); + dummy.value = text; + dummy.select(); + document.execCommand('copy'); + document.body.removeChild(dummy); // End of *TODO* window.notify(`Link copied to clipboard! ❤️
ps. to embed this experience in your website,
copy/paste the following into your HTML:
`,{timeout:10000}) }