1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-29 04:17:41 +02:00

getBrowser cache

This commit is contained in:
Kyle Spearrin 2016-09-21 11:11:36 -04:00
parent 5b1172b8d0
commit 32d459159c

View File

@ -1,22 +1,44 @@
function UtilsService() {
initUtilsService();
this.browserCache = null;
};
function initUtilsService() {
UtilsService.prototype.getBrowser = function () {
if (navigator.userAgent.indexOf("Firefox") !== -1 || navigator.userAgent.indexOf("Gecko/") !== -1) {
return 'firefox';
}
if ((!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0) {
return 'opera';
}
if (navigator.userAgent.indexOf(" Edge/") !== -1) {
return 'edge';
}
if (window.chrome) {
return 'chrome';
if (this.browserCache) {
return this.browserCache;
}
return null;
if (navigator.userAgent.indexOf("Firefox") !== -1 || navigator.userAgent.indexOf("Gecko/") !== -1) {
this.browserCache = 'firefox';
}
else if ((!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0) {
this.browserCache = 'opera';
}
else if (navigator.userAgent.indexOf(" Edge/") !== -1) {
this.browserCache = 'edge';
}
else if (window.chrome) {
this.browserCache = 'chrome';
}
return this.browserCache;
};
UtilsService.prototype.isFirefox = function () {
return this.getBrowser() === 'firefox';
}
UtilsService.prototype.isChrome = function () {
return this.getBrowser() === 'chrome';
}
UtilsService.prototype.isEdge = function () {
return this.getBrowser() === 'edge';
}
UtilsService.prototype.isOpera = function () {
return this.getBrowser() === 'opera';
}
};