diff --git a/js/main.js b/js/main.js index 2383ba2f..67f60279 100644 --- a/js/main.js +++ b/js/main.js @@ -1105,59 +1105,3 @@ document.fonts.addEventListener("loadingdone", (event) => { // Initial call to set the margin based on current state updateMargin(); })(); - -//------------------------------------------------ -// Fix for Copy Button (with HTTP Fallback) -//------------------------------------------------ -document.addEventListener('click', function(e) { - const copyBtn = e.target.closest('.hljs-copy-button'); - if (!copyBtn) return; - - const pre = copyBtn.closest('pre'); - const code = pre ? pre.querySelector('code') : null; - - if (code) { - const text = code.innerText; - - function copyToClipboard(content) { - if (navigator.clipboard && window.isSecureContext) { - return navigator.clipboard.writeText(content); - } else { - return new Promise((resolve, reject) => { - const textArea = document.createElement("textarea"); - textArea.value = content; - textArea.style.position = "fixed"; - textArea.style.left = "-9999px"; - textArea.style.top = "-9999px"; - document.body.appendChild(textArea); - textArea.focus(); - textArea.select(); - try { - const successful = document.execCommand('copy'); - document.body.removeChild(textArea); - successful ? resolve() : reject(); - } catch (err) { - document.body.removeChild(textArea); - reject(err); - } - }); - } - } - - copyToClipboard(text).then(() => { - const originalText = copyBtn.innerText; - // Update button state - copyBtn.innerText = 'Copied!'; - copyBtn.setAttribute('data-copied', 'true'); - copyBtn.style.pointerEvents = 'none'; // Prevent double clicks - - setTimeout(() => { - copyBtn.innerText = 'Copy'; - copyBtn.setAttribute('data-copied', 'false'); - copyBtn.style.pointerEvents = 'auto'; - }, 2000); - }).catch(err => { - console.error('Copy failed:', err); - }); - } -});