Verified Commit 938c5d47 authored by Camil Staps's avatar Camil Staps 🙂

Use localStorage to save hidden banners instead of cookie

parent ab9f59f4
...@@ -124,13 +124,12 @@ function highlightQuery(query) { ...@@ -124,13 +124,12 @@ function highlightQuery(query) {
} }
var banners = document.getElementsByClassName('banner'); var banners = document.getElementsByClassName('banner');
for (var i = 0; i < banners.length; i++) { for (let i = 0; i < banners.length; i++) {
var banner = banners[i]; let banner = banners[i];
banner.dataset.index = i; banner.dataset.index = i;
var id = banner.dataset.id; let id = banner.dataset.id;
var hidden = document.cookie.replace(/(?:(?:^|.*;\s*)hidden_banners\s*\=\s*([^;]*).*$)|^.*$/, "$1"); if (window.localStorage['banner-' + id] == 'hidden')
if (hidden.split(' ').indexOf(id) >= 0)
continue; continue;
var from = new Date(banner.dataset.from); var from = new Date(banner.dataset.from);
...@@ -144,9 +143,9 @@ for (var i = 0; i < banners.length; i++) { ...@@ -144,9 +143,9 @@ for (var i = 0; i < banners.length; i++) {
hidelink.innerHTML = '&times;'; hidelink.innerHTML = '&times;';
hidelink.setAttribute('href', '#'); hidelink.setAttribute('href', '#');
hidelink.setAttribute('title', 'Hide this banner forever'); hidelink.setAttribute('title', 'Hide this banner forever');
hidelink.onclick = function() { hidelink.onclick = function () {
banner.remove(); banner.remove();
document.cookie = 'hidden_banners=' + hidden + ' ' + id; window.localStorage['banner-' + id] = 'hidden';
} }
banner.appendChild(hidelink); banner.appendChild(hidelink);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment