Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"use strinct";
const alert = document.getElementById('alert-message');
function showAlert(head, body, green) {
if(alert == null)
return;
green ? alert.classList.add('alert-success') : alert.classList.add('alert-danger');
alert.innerHTML = `
<div class="d-flex justify-content-around container-fluid">
${green ? '<i class="fa-solid fa-check-circle fa-4x" aria-hidden="true"></i>' : '<i class="fa-solid fa-exclamation-circle fa-4x aria-hidden="true""></i>'}
<div>
<h4 class="alert-heading">${head}</h4>
<p>${body}</p>
</div>
</div>`;//<i class="fa-solid fa-triangle-exclamation fa-fade"></i>
alert.classList.remove('invisible');
// dismiss the alert after 3 seconds
setTimeout(() => {
alert.classList.add('invisible');
alert.classList.remove('alert-success');
alert.classList.remove('alert-danger');
alert.innerHTML = "";
}, 3000);
};
/**
* makes the element bounce for 3 seconds so that it's easily visible
* @param {*} element the element to be bounced
*/
function makeElementBounce(element) {
element.classList.add('fa-bounce');
// stop after 3 seconds
setTimeout(() => {
element.classList.remove('fa-bounce');
}, 3000);
}
export { showAlert, makeElementBounce };