export function createNotification(text, timer = 3000) { if (!createNotification.templateToast) { createNotification.templateToast = new DOMParser().parseFromString(` `, 'text/html') .querySelector('body') .firstChild; } const toastElement = createNotification.templateToast.cloneNode(true); toastElement.getElementsByClassName('toast-body')[0].innerHTML = text; toastElement.addEventListener('hidden.bs.toast', e => e.target.remove()); new bootstrap.Toast(toastElement).show(); const toastContainer = document.getElementById('toastContainer'); toastContainer.insertBefore(toastElement, toastContainer.firstChild); }