Fix missing labels (a11y)

Additionally add some missing translations
This commit is contained in:
daudix
2024-06-20 06:48:56 +03:00
parent 0a9b65d056
commit 7691b260a3
8 changed files with 62 additions and 44 deletions

View File

@ -1,37 +0,0 @@
// Based on https://www.roboleary.net/2022/01/13/copy-code-to-clipboard-blog.html
document.addEventListener("DOMContentLoaded", function () {
let blocks = document.querySelectorAll("pre[class^='language-']");
blocks.forEach((block) => {
if (navigator.clipboard) {
let container = document.createElement("div");
container.classList.add("pre-container");
block.parentNode.insertBefore(container, block);
container.appendChild(block);
let button = document.createElement("button");
let icon = document.createElement("i");
icon.classList.add("icon");
button.appendChild(icon);
container.appendChild(button);
button.addEventListener("click", async () => {
await copyCode(block, button);
});
}
});
async function copyCode(block, button) {
let code = block.querySelector("code");
let text = code.innerText;
await navigator.clipboard.writeText(text);
button.classList.add("active");
setTimeout(() => {
button.classList.remove("active");
}, 800);
}
});