aboutsummaryrefslogtreecommitdiffstats
path: root/code/frontpage/assets/js/alert.js
blob: 1956103d8a26288a9489f065102a56b9b0f8ecc8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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');
      }
    }
  });

  announcement.addEventListener('closed.bs.alert', () => {
    localStorage.setItem(id, 'closed');
  });

}