-
Notifications
You must be signed in to change notification settings - Fork 0
/
notification.js
39 lines (35 loc) · 1.45 KB
/
notification.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
35
36
37
38
39
var messages = 0; //the global count of messages
//this is the function to send the notification
async function send(msg, sender) {
//increments it
messages++;
var oof = messages;
//create a new element
var notification = document.createElement('div');
notification.className = "singleNotification"; //gives it the proper styling
notification.id = sender + oof + "Notification"; //name of this notification
notification.innerHTML =
`
<div class="singleNotificationText">
` + sender.toUpperCase() + ": " + msg + `
</div>
<button class="singleNotificationCloseButton" title="Close" onclick="document.getElementById('` + sender + oof + "Notification" + `').parentNode.removeChild(document.getElementById('` + sender + oof + "Notification" + `'))">
<svg class="singleNotificationClose">
<use xlink:href="SvgIcons/disabled.svg#Capa_1"></use>
</svg>
</button>
`;
document.getElementById('notificationCenter').appendChild(notification);
//fade it out
killNotification(sender + oof + "Notification");
}
async function killNotification(title)
{
setTimeout(function () {
document.getElementById(title).style.animation = 'fadeOut .5s';
setTimeout(function () {
document.getElementById(title).parentNode.removeChild(document.getElementById(title));
}, 450);
}, 5000);
}
module.exports = { send };