wp-duckbehaviorjournal/assets/js/clipboard.js
Kumi 72ef4d8c0c
fix: update DOI URL to use freedoi.org
Replaces the dynamic origin-based DOI URL with a standardized URL using freedoi.org. This ensures consistent and accurate DOI links, improving user experience and reliability.
2024-06-22 20:09:20 +02:00

22 lines
699 B
JavaScript

document.addEventListener("DOMContentLoaded", function () {
const doiLink = document.getElementById("doi-link");
const doiCopyMessage = document.getElementById("doi-copy-message");
doiLink.addEventListener("click", function (event) {
event.preventDefault();
const doi = doiLink.getAttribute("data-doi");
const fullDoiUrl = `https://freedoi.org/${doi}`;
navigator.clipboard.writeText(fullDoiUrl).then(
function () {
doiCopyMessage.style.display = "inline";
setTimeout(function () {
doiCopyMessage.style.display = "none";
}, 2000);
},
function () {
alert("Failed to copy DOI to clipboard.");
}
);
});
});