3 lines
1.2 KiB
JavaScript
3 lines
1.2 KiB
JavaScript
(()=>{var t=document.querySelector(".container"),e=document.querySelectorAll(".menu");document.body.addEventListener("click",()=>{e.forEach(e=>{e.classList.contains("open")&&e.classList.remove("open")})}),window.addEventListener("resize",()=>{e.forEach(e=>{e.classList.remove("open")})}),e.forEach(n=>{const o=n.querySelector(".menu__trigger"),s=n.querySelector(".menu__dropdown");o.addEventListener("click",o=>{o.stopPropagation(),n.classList.contains("open")?n.classList.remove("open"):(e.forEach(e=>e.classList.remove("open")),n.classList.add("open")),s.getBoundingClientRect().right>t.getBoundingClientRect().right&&(s.style.left="auto",s.style.right=0)}),s.addEventListener("click",e=>e.stopPropagation())})})(),(()=>{var e=document.querySelectorAll(".chroma code[data-lang]");for(const n of e){const s=n.parentElement,o=n.innerText.split(`
|
|
`).filter(Boolean).join(`
|
|
`),t=document.createElement("div"),i=n.dataset.lang;if(t.classList.add("code-title"),t.innerText=i,navigator.clipboard!==void 0){const e=document.createElement("button");e.classList.add("copy-button"),e.innerText="Copy",e.addEventListener("click",()=>{e.innerText="Copied",setTimeout(()=>{e.innerText="Copy"},1e3),navigator.clipboard.writeText(o)}),t.append(e)}s.closest(".highlight").prepend(t)}})() |