Kumi
3bd51e66ed
Introduced a new JavaScript file to handle the DOI copy-to-clipboard feature. Updated the 'single-article.php' template to include a clickable DOI link that copies the DOI to the clipboard and displays a confirmation message. Enhances user convenience by simplifying the process of copying DOIs.
22 lines
705 B
JavaScript
22 lines
705 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 = `${window.location.origin}/${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.");
|
|
}
|
|
);
|
|
});
|
|
});
|