moar refactoring

This commit is contained in:
Silas 2024-02-01 21:38:33 -05:00
parent 01d817a206
commit ccfe6c60cd
Signed by: silentsilas
GPG Key ID: 4199EFB7DAA34349
1 changed files with 3 additions and 4 deletions

View File

@ -29,7 +29,7 @@ export async function setupRequestPage(element: HTMLElement) {
<button <button
aria-label="Copy to Clipboard" aria-label="Copy to Clipboard"
.id=${COPY_BUTTON_ID} .id=${COPY_BUTTON_ID}
@click=${copyToClipboard} @click=${(event: Event) => copyToClipboard(event, url.toString())}
> >
Copy to Clipboard Copy to Clipboard
</button> </button>
@ -39,10 +39,9 @@ export async function setupRequestPage(element: HTMLElement) {
render(element, template); render(element, template);
} }
async function copyToClipboard(event: Event) { async function copyToClipboard(event: Event, url: string) {
event.preventDefault(); event.preventDefault();
const input = document.getElementById(URL_INPUT_ID) as HTMLInputElement; await navigator.clipboard.writeText(url);
await navigator.clipboard.writeText(input.value);
alert("Copied to clipboard!"); alert("Copied to clipboard!");
} }