remove unused code

This commit is contained in:
John Bowdre 2023-11-08 20:28:42 -06:00
parent 6273694b27
commit a829d12127

View file

@ -33,32 +33,24 @@ async function copyCodeToClipboard(button, highlightDiv) {
if (result.state == "granted" || result.state == "prompt") { if (result.state == "granted" || result.state == "prompt") {
await navigator.clipboard.writeText(codeToCopy); await navigator.clipboard.writeText(codeToCopy);
} else { } else {
copyCodeBlockExecCommand(codeToCopy, highlightDiv); button.blur();
button.innerText = "Error!";
setTimeout(function () {
button.innerText = "Copy";
}, 2000);
} }
} catch (_) { } catch (_) {
copyCodeBlockExecCommand(codeToCopy, highlightDiv); button.blur();
button.innerText = "Error!";
setTimeout(function () {
button.innerText = "Copy";
}, 2000);
} finally { } finally {
button.blur(); button.blur();
button.innerText = "Copied!"; button.innerText = "Copied!";
setTimeout(function () { setTimeout(function () {
button.innerText = "Copy"; button.innerText = "Copy";
}, 2000); } }, 2000);
}
} }
function copyCodeBlockExecCommand(codeToCopy, highlightDiv) {
console.log("We shouldn't get here...");
const textArea = document.createElement("textArea");
textArea.contentEditable = "true";
textArea.readOnly = "false";
textArea.className = "copyable-text-area";
textArea.value = codeToCopy;
highlightDiv.insertBefore(textArea, highlightDiv.firstChild);
const range = document.createRange();
range.selectNodeContents(textArea);
const sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
textArea.setSelectionRange(0, 999999);
document.execCommand("copy");
highlightDiv.removeChild(textArea);
}