Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
fix: cannot copy under unsecure connection
Browse files Browse the repository at this point in the history
  • Loading branch information
yuantuo666 committed Sep 23, 2023
1 parent dbe3d53 commit 686edc4
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions public/static/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,23 +570,22 @@ function CopyDownloadLink() {
icon: "success"
});
}
const CopyDownloadLink_old = () => {
$("input#downloadlink").select();
document.execCommand("copy");
Success();
}


// In unsecure site will not work, add check
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText($("input#downloadlink").val()).then(function () {
console.log('Copying to clipboard was successful!');
}, function (err) {
console.error('Could not copy text: ', err);
CopyDownloadLink_old()
$("input#downloadlink").select();
document.execCommand("copy");
Success();
}).then(function () {
Success();
});
} else {
CopyDownloadlink_old();
$("input#downloadlink").select();
document.execCommand("copy");
Success();
}
}

0 comments on commit 686edc4

Please sign in to comment.