Casual_blog/public/js/script.min.74bf1a3fcf1af396efa4acf3e660e876b61a2153ab9cbe1893ac24ea6d4f94ee.js
2024-03-08 13:59:06 +03:00

1 line
1.3 KiB
JavaScript

document.addEventListener("DOMContentLoaded",function(){"use strict";if(!document.queryCommandSupported("copy"))return;let t='<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25"><path d="M18 6v-6h-18v18h6v6h18v-18h-6zm-12 10h-4v-14h14v4h-10v10zm16 6h-14v-14h14v14z"/></svg>',s='<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25"><path d="M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z"/></svg>',o='<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25"><path d="M23.954 21.03l-9.184-9.095 9.092-9.174-2.832-2.807-9.09 9.179-9.176-9.088-2.81 2.81 9.186 9.105-9.095 9.184 2.81 2.81 9.112-9.192 9.18 9.1z"/></svg>';function n(e,n){e.innerHTML=n,setTimeout(()=>{e.innerHTML=t},1e3)}function i(e){let t=window.getSelection(),n=document.createRange();return e.childElementCount===2?n.selectNodeContents(e.children[1]):n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n),t}function a(e){let a=document.createElement("button");a.className="highlight-copy-btn",a.innerHTML=t;let r=e.firstElementChild;a.addEventListener("click",()=>{try{let e=i(r);document.execCommand("copy"),e.removeAllRanges(),n(a,s)}catch(e){console&&console.log(e),n(a,o)}}),e.appendChild(a)}let r=document.getElementsByClassName("highlight");Array.prototype.forEach.call(r,a)},!1)