Added toast and copy to clipboard functionality
This commit is contained in:
14
src/toast.ts
Normal file
14
src/toast.ts
Normal file
@ -0,0 +1,14 @@
|
||||
export function toast(element: HTMLDivElement, message: string) {
|
||||
// Target our predefined DIV that will hold toast messages.
|
||||
const toastDiv = element.getElementsByClassName('toast')
|
||||
|
||||
// If we currently have a toast displayed, let's remove it from the DOM.
|
||||
if (toastDiv && toastDiv.length != 0) {
|
||||
for (const el of toastDiv){
|
||||
el.remove()
|
||||
}
|
||||
}
|
||||
|
||||
// Finally add our toast message.
|
||||
element.innerHTML += `<div class='toast'>${message}</div>`
|
||||
}
|
Reference in New Issue
Block a user