Files
www-data 2f2e8869d6 Reorganize PHP internals and static assets
Move shared PHP code into private/, move JavaScript files into js/, and block direct access to private/. Remove unused API key and cache artifacts from the working tree.
2026-05-26 11:32:36 +02:00

57 lines
1.7 KiB
JavaScript

(function () {
'use strict';
function fallbackCopy(text) {
const input = document.createElement('textarea');
input.value = text;
input.setAttribute('readonly', 'readonly');
input.style.position = 'fixed';
input.style.left = '-9999px';
document.body.appendChild(input);
input.select();
try {
document.execCommand('copy');
} finally {
document.body.removeChild(input);
}
}
function copyText(text) {
if (navigator.clipboard && navigator.clipboard.writeText) {
return navigator.clipboard.writeText(text);
}
fallbackCopy(text);
return Promise.resolve();
}
function showCopied(button) {
const original = button.dataset.copyLabel || button.textContent;
const copied = button.dataset.copiedLabel || 'Copied';
button.textContent = copied;
window.setTimeout(function () {
button.textContent = original;
}, 1400);
}
document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('.js-copy-button').forEach(function (button) {
button.addEventListener('click', function () {
let text = button.dataset.copyText || '';
const targetId = button.dataset.copyTarget || '';
const target = targetId ? document.getElementById(targetId) : null;
if (target) {
text = target.value || target.textContent || '';
}
copyText(text).then(function () {
showCopied(button);
});
});
});
});
}());