mirror of
https://github.com/jbowdre/runtimeterror.git
synced 2024-11-10 01:52:19 +00:00
remove unused code
This commit is contained in:
parent
169e4187f6
commit
016b8726c8
1 changed files with 16 additions and 24 deletions
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue