mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 07:17:17 +00:00
add fallback for copying to clipboard
This commit is contained in:
parent
45f5006db3
commit
2684e4b3f4
@ -25,7 +25,7 @@
|
||||
|
||||
async function copyLogs() {
|
||||
const logs = packageInfoLogs.text();
|
||||
await navigator.clipboard.writeText(logs);
|
||||
await copyToClipboard(logs);
|
||||
|
||||
packageInfoLogsCopyButton.html("<i class=\"bi bi-clipboard-check\"></i> copied");
|
||||
setTimeout(()=> {
|
||||
|
@ -101,7 +101,7 @@ SigLevel = Database{% if has_repo_signed %}Required{% else %}Never{% endif %} Pa
|
||||
|
||||
async function copyPacmanConf() {
|
||||
const conf = pacmanConf.text();
|
||||
await navigator.clipboard.writeText(conf);
|
||||
await copyToClipboard(conf);
|
||||
|
||||
pacmanConfCopyButton.html("<i class=\"bi bi-clipboard-check\"></i> copied");
|
||||
setTimeout(() => {
|
||||
|
@ -11,3 +11,18 @@
|
||||
<script src="https://unpkg.com/bootstrap-table@1.21.1/dist/extensions/export/bootstrap-table-export.min.js"></script>
|
||||
|
||||
<script src="https://unpkg.com/bootstrap-table@1.21.1/dist/extensions/resizable/bootstrap-table-resizable.js"></script>
|
||||
|
||||
<script>
|
||||
async function copyToClipboard(text) {
|
||||
if (navigator.clipboard === undefined) {
|
||||
const input = document.createElement("textarea");
|
||||
input.innerHTML = text;
|
||||
document.body.appendChild(input);
|
||||
input.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(input);
|
||||
} else {
|
||||
await navigator.clipboard.writeText(text);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user