From 2a181695961345372243a55880736c2f5bcf815e Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Mon, 2 Dec 2024 20:40:06 -0800 Subject: [PATCH] Revert "Capture interactive context for copy to clipboard" This reverts commit 7dbddad1bc7ee818f64abfcdc138eda9783016cd. --- static/index.html | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/static/index.html b/static/index.html index 19790f1..c1fc02f 100644 --- a/static/index.html +++ b/static/index.html @@ -93,10 +93,7 @@ function error(err1, err2) { document.getElementById('err').show(); } -async function setFromInputs(copy = null) { - if (copy == null) { - copy = async (v) => await navigator.clipboard.writeText(v); - } +async function setFromInputs() { const short = document.getElementById('short').value; const long = document.getElementById('long').value; @@ -108,10 +105,10 @@ async function setFromInputs(copy = null) { document.getElementById('short-icon').setAttribute('name', 'check-square-fill'); document.getElementById('long-icon').setAttribute('name', 'check-square-fill'); - await set(short, long, copy); + await set(short, long); } -async function set(short, long, copy) { +async function set(short, long) { if (short != '') { setShortItem(short, 'check-square-fill'); } @@ -131,7 +128,7 @@ async function set(short, long, copy) { }); } catch (err) { console.log(err); - setTimeout(async () => await set(short, long, copy), 5000); + setTimeout(async () => await set(short, long), 5000); return; } @@ -154,7 +151,7 @@ async function set(short, long, copy) { // Only set the clipboard if the user didn't change the inputs if (document.getElementById('short').value == oldShort && document.getElementById('long').value == oldLong) { try { - await copy(`${window.location.origin}/${newShort}`); + await navigator.clipboard.writeText(`${window.location.origin}/${newShort}`); } catch (err) { console.log(err); } @@ -240,8 +237,7 @@ document.addEventListener('DOMContentLoaded', async () => { document.getElementById('short').addEventListener('paste', async () => { if (document.getElementById('long').value != '') { - const copy = async (v) => await navigator.clipboard.writeText(v); - setTimeout(async () => await setFromInputs(copy), 0); + setTimeout(async () => await setFromInputs(), 0); } }); @@ -265,8 +261,7 @@ document.addEventListener('DOMContentLoaded', async () => { document.getElementById('long').addEventListener('paste', () => { if (document.getElementById('short').value != '') { - const copy = async (v) => await navigator.clipboard.writeText(v); - setTimeout(async () => await setFromInputs(copy), 0); + setTimeout(async () => await setFromInputs(), 0); } });