1
0
mirror of https://github.com/SuperBFG7/ympd synced 2024-12-27 11:20:26 +00:00

Click hides notification

This commit is contained in:
jcorporation 2018-07-11 00:12:36 +01:00
parent 1c0c9aa14f
commit 69d95a8ab1

View File

@ -1389,6 +1389,9 @@ function showNotification(notificationTitle,notificationText,notificationHtml,no
if (!document.getElementById('alertBox')) { if (!document.getElementById('alertBox')) {
alertBox = document.createElement('div'); alertBox = document.createElement('div');
alertBox.setAttribute('id', 'alertBox'); alertBox.setAttribute('id', 'alertBox');
alertBox.addEventListener('click', function() {
hideNotification();
}, false);
} }
else { else {
alertBox = document.getElementById('alertBox'); alertBox = document.getElementById('alertBox');
@ -1400,15 +1403,20 @@ function showNotification(notificationTitle,notificationText,notificationHtml,no
if (alertTimeout) if (alertTimeout)
clearTimeout(alertTimeout); clearTimeout(alertTimeout);
alertTimeout = setTimeout(function() { alertTimeout = setTimeout(function() {
if (document.getElementById('alertBox')) hideNotification();
document.getElementById('alertBox').classList.remove('alertBoxActive');
setTimeout(function() {
document.getElementById('alertBox').remove();
}, 600);
}, 3000); }, 3000);
} }
} }
function hideNotification() {
if (document.getElementById('alertBox')) {
document.getElementById('alertBox').classList.remove('alertBoxActive');
setTimeout(function() {
document.getElementById('alertBox').remove();
}, 600);
}
}
function notificationsSupported() { function notificationsSupported() {
return "Notification" in window; return "Notification" in window;
} }