website: Added click-to-copy functionality for specific code blocks with success alert. (#5804)
Some checks failed
Build and deploy docs / Xonsh docs to gh-pages (push) Has been cancelled
CI Tests / Test Python 3.10 macOS-latest (push) Has been cancelled
CI Tests / Test Python 3.11 macOS-latest (push) Has been cancelled
CI Tests / Test Python 3.12 macOS-latest (push) Has been cancelled
CI Tests / Test Python 3.13 macOS-latest (push) Has been cancelled
CI Tests / Test Python 3.10 ubuntu-latest (push) Has been cancelled
CI Tests / Test Python 3.11 ubuntu-latest (push) Has been cancelled
CI Tests / Test Python 3.12 ubuntu-latest (push) Has been cancelled
CI Tests / Test Python 3.13 ubuntu-latest (push) Has been cancelled
CI Tests / Test Python 3.10 windows-latest (push) Has been cancelled
CI Tests / Test Python 3.11 windows-latest (push) Has been cancelled
CI Tests / Test Python 3.12 windows-latest (push) Has been cancelled
CI Tests / Test Python 3.13 windows-latest (push) Has been cancelled

* Added Copy Functionality.

Implemented click-to-copy functionality for specific code areas, displaying an alert upon successful copy.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Ahmed 2025-02-27 20:49:54 +05:30 committed by GitHub
parent 34b3f3cfbe
commit bbd652c06d
Failed to generate hash of commit

View file

@ -679,6 +679,20 @@ chmod +x xonsh-x86_64.AppImage
<script src="_static/landing2/js/custom.js"></script>
<script language="JavaScript">
const code = document.querySelectorAll(".code");
code.forEach((element) => {
element.addEventListener("click", () => {
let textes = element.innerText;
navigator.clipboard.writeText(textes)
.then(() => {
alert("Code copied!");
})
.catch((error) => {
console.error("Code didnt copy", error);
})
});
});
var tagsToReplace = {
'&': '&amp;',
'<': '&lt;',