function toast()

in htdocs/js/selfserve.js [142:160]


function toast(message, type="danger", redirect_on_close=null) {
  // Displays a message/alert as a toast if possible, falling back to alert() otherwise
  const toastdiv = document.getElementById('liveToast');
  if (toastdiv) {
    const toastobj = new bootstrap.Toast(toastdiv);
    toastdiv.querySelector('.toast-header').setAttribute('class', `toast-header text-white bg-${type}`);
    toastdiv.querySelector('.toast-body').innerText = message;
    toastobj.show();
    toastdiv.addEventListener('hide.bs.toast', () => {
      blur_bg(false);
      if (redirect_on_close) {
        location.href = redirect_on_close;
      }
    });
    blur_bg();
  } else {
    alert(message);
  }
}