Don't use webpack on boot.js

This commit is contained in:
djmaze 2020-09-03 16:34:23 +02:00
parent b837013cfb
commit fcaa2fd6de
11 changed files with 167 additions and 388 deletions

View file

@ -30,33 +30,4 @@ w.ResizeObserver || (w.ResizeObserver = class {
}
});
const Storage = type => {
let name = type+'Storage';
try {
w[name].setItem('storage', '');
w[name].getItem('storage');
w[name].removeItem('storage');
} catch (e) {
console.error(e);
const cookieName = encodeURIComponent(name+('session' === type ? w.name || (w.name = Date.now()) : ''));
// initialise if there's already data
let data = document.cookie.match('(^|;) ?'+cookieName+'=([^;]*)(;|$)');
data = data ? decodeURIComponent(data[2]) : null;
data = data ? JSON.parse(data) : {};
w[name] = {
getItem: key => data[key] === undefined ? null : data[key],
setItem: function (key, value) {
data[key] = ''+value; // forces the value to a string
document.cookie = cookieName+'='+encodeURIComponent(JSON.stringify(data))
+"; expires="+('local' === type ? (new Date(Date.now()+(365*24*60*60*1000))).toGMTString() : '')
+"; path=/; samesite=strict";
}
};
}
};
Storage('local');
Storage('session');
})(window);