I'm not sure about the definition of cookieExists outside of the ieAlert class. Is it ok that the variable cookieExists is outside of the class ieAlert? Or should I define it as a property inside the class definition?
var cookieExists = document.cookie.indexOf('ie11_cookie') >= 0;
class ieAlert {
// Method for checking if IE11
static isIE() {
return window.navigator.userAgent.match(/(MSIE|Trident)/);
}
// Method for setting a cookie
static createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
}
if (!ieAlert.isIE() && !cookieExists) {
window.alert("Your browser is outdated!");
ieAlert.createCookie('myCookie', 'ie11_cookie', 1);
}
module.exports = ieAlert;