Fixes
This commit is contained in:
8 files changed
+123
-110
No files matched your search
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
const copy = document.getElementById("copy-code");
|
||||
const status = document.getElementById("copy-status");
|
||||
const fallback = document.getElementById("raw-code");
|
||||
|
||||
copy.addEventListener("click", async () => {
|
||||
const bytes = Uint8Array.from(atob(copy.dataset.raw), character => character.charCodeAt(0));
|
||||
const content = new TextDecoder("utf-8", { ignoreBOM: true }).decode(bytes);
|
||||
copy.disabled = true;
|
||||
try {
|
||||
await navigator.clipboard.writeText(content);
|
||||
fallback.hidden = true;
|
||||
} catch {
|
||||
fallback.value = content;
|
||||
fallback.hidden = false;
|
||||
fallback.focus();
|
||||
fallback.select();
|
||||
} finally {
|
||||
copy.disabled = false;
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user