portails/assets/js/alert.js

20 lines
480 B
JavaScript
Raw Normal View History

2021-09-07 12:08:46 +02:00
var announcement = document.getElementById('announcement');
if (announcement !== null) {
var id = announcement.dataset.id;
Object.keys(localStorage).forEach(function(key) {
if (/^global-alert-/.test(key)) {
if (key !== id ) {
localStorage.removeItem(key);
document.documentElement.removeAttribute('data-global-alert');
}
}
});
2021-09-07 12:08:46 +02:00
announcement.addEventListener('closed.bs.alert', () => {
localStorage.setItem(id, 'closed');
2021-09-07 12:08:46 +02:00
});
}