diff --git a/photo21/static/copy-button.js b/photo21/static/copy-button.js new file mode 100644 index 0000000..91f7ec8 --- /dev/null +++ b/photo21/static/copy-button.js @@ -0,0 +1,24 @@ +document.querySelectorAll('[data-clipboard-text]').forEach(function(btn) { + btn.addEventListener('click', function() { + var text = btn.dataset.clipboardText; + if (navigator.clipboard) { + navigator.clipboard.writeText(text); + } else { + var ta = document.createElement('textarea'); + ta.value = text; + ta.style.position = 'fixed'; + ta.style.opacity = '0'; + document.body.appendChild(ta); + ta.select(); + document.execCommand('copy'); + document.body.removeChild(ta); + } + var original = btn.textContent; + btn.textContent = '✓ Copied!'; + btn.disabled = true; + setTimeout(function() { + btn.textContent = original; + btn.disabled = false; + }, 2000); + }); +}); diff --git a/photo21/templates/base.html b/photo21/templates/base.html index 66ea520..9a1c499 100644 --- a/photo21/templates/base.html +++ b/photo21/templates/base.html @@ -36,6 +36,7 @@ SPDX-License-Identifier: GPL-3.0-or-later