Add copy button to crash page

This commit is contained in:
Harvey Tindall
2021-06-13 15:36:36 +01:00
parent 1dc0b2234a
commit 21125033ff
3 changed files with 16 additions and 2 deletions
+13
View File
@@ -1,3 +1,5 @@
import { toClipboard } from "./modules/common.js";
const buttonNormal = document.getElementById("button-log-normal") as HTMLInputElement;
const buttonSanitized = document.getElementById("button-log-sanitized") as HTMLInputElement;
@@ -24,3 +26,14 @@ const buttonChange = (type: string) => {
}
buttonNormal.onclick = () => buttonChange("normal");
buttonSanitized.onclick = () => buttonChange("sanitized");
const copyButton = document.getElementById("copy-log") as HTMLSpanElement;
copyButton.onclick = () => {
if (logSanitized.classList.contains("unfocused")) {
toClipboard("```\n" + logNormal.textContent + "```");
} else {
toClipboard("```\n" + logSanitized.textContent + "```");
}
copyButton.textContent = "Copied.";
setTimeout(() => { copyButton.textContent = "Copy"; }, 1500);
};