From cd958f149223e1331f9877009a879a7f9974fc50 Mon Sep 17 00:00:00 2001 From: Joe Martinez Date: Mon, 24 Jan 2022 05:21:13 -0500 Subject: [PATCH] warn if clipboard support is missing (#922) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * warn if clipboard support is missing * make the message a bit more helpful * Update assets/js/app.js Co-authored-by: Jonatan Kłosko --- assets/js/app.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index a2cbb99a7..6eb30c51d 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -91,12 +91,16 @@ window.addEventListener("lb:set_value", (event) => { event.target.value = event.detail.value; }); -if ("clipboard" in navigator) { - window.addEventListener("lb:clipcopy", (event) => { +window.addEventListener("lb:clipcopy", (event) => { + if ("clipboard" in navigator) { const text = event.target.textContent; navigator.clipboard.writeText(text); - }); -} + } else { + alert( + "Sorry, your browser does not support clipboard copy.\nThis generally requires a secure origin — either HTTPS or localhost." + ); + } +}); // Other global handlers