-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsse.js
34 lines (28 loc) · 1.1 KB
/
sse.js
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
const createAllert = (message, category = 'info') => {
const li = document.createElement('li');
li.setAttribute('role', 'alert')
li.classList.add('alert');
li.classList.add('alert-dismissible');
li.classList.add('fade');
li.classList.add('show');
li.classList.add('mt-2');
li.classList.add(`alert-${category}`);
const span = document.createElement('span');
span.innerText = message;
li.appendChild(span);
const closeButton = document.createElement('button');
closeButton.classList.add('close');
closeButton.setAttribute('type', 'button');
closeButton.setAttribute('data-dismiss', 'alert');
closeButton.setAttribute('aria-label', 'Close');
const closeIcon = document.createElement('span');
closeIcon.setAttribute('aria-hidden', 'true');
closeIcon.innerHTML = '×';
closeButton.appendChild(closeIcon);
li.appendChild(closeButton);
return li;
};
const displayInformation = (message, category = 'info') => {
const flashList = document.getElementById('flashes');
flashList.appendChild(createAllert(message, category));
};