data-validator-js
Version:
Validation Methods for all types of Data
116 lines (115 loc) • 3.13 kB
JavaScript
;
var BrowserUtilities = /** @class */ (function () {
function BrowserUtilities() {
}
/**
* GetBrowser
*/
BrowserUtilities.GetBrowser = function () {
var userAgent = window.navigator.userAgent;
var isBrowserIE = (userAgent.indexOf("MSIE") !== -1 || userAgent.indexOf("Trident") !== -1) ? true : false;
var isBrowserEdge = (userAgent.indexOf("Edge/") !== -1) ? true : false;
var isBrowserChrome = (userAgent.indexOf("Chrome") !== -1) ? true : false;
var isBrowserFirefox = (userAgent.indexOf("Firefox") !== -1) ? true : false;
var isBrowserSafari;
if (userAgent.indexOf("Safari") !== -1) {
if ((userAgent.indexOf("Chrome") !== -1) || (userAgent.indexOf("Android") !== -1)) {
isBrowserSafari = false;
}
else {
isBrowserSafari = true;
}
}
if (isBrowserChrome) {
return "Chrome";
}
else if (isBrowserEdge) {
return "Edge";
}
else if (isBrowserFirefox) {
return "FireFox";
}
else if (isBrowserIE) {
return "Internet Explorer";
}
else if (isBrowserSafari) {
return "Safari";
}
else {
return 'No browser';
}
};
/**
* IsOffline
*/
BrowserUtilities.prototype.IsOffline = function () {
return navigator.onLine;
};
/**
* IsOnline
*/
BrowserUtilities.prototype.IsOnline = function () {
return navigator.onLine;
};
/**
* IsMacMachine
*/
BrowserUtilities.prototype.IsMacMachine = function () {
return window.navigator.platform === "MacIntel";
};
/**
* IsUbuntuMachine
*/
BrowserUtilities.prototype.IsUbuntuMachine = function () {
return window.navigator.platform === "Linux";
};
/**
* IsWindowsMachine
*/
BrowserUtilities.prototype.IsWindowsMachine = function () {
return window.navigator.platform === "Win";
};
/**
* IsBrowser
*/
BrowserUtilities.prototype.IsBrowser = function () {
return false;
};
/**
* GetUserLanguage
*/
BrowserUtilities.prototype.GetUserLanguage = function () {
return navigator.language;
};
/**
* IsChargerConnected
*/
BrowserUtilities.prototype.IsChargerConnected = function () {
return false;
};
/**
* getBatteryStatus
*/
// public getBatteryStatus() {
// navigator.getBattery().then(a=> {console.log(a)})
// }
/**
* IsCookieEnabled
*/
BrowserUtilities.prototype.IsCookieEnabled = function () {
return navigator.cookieEnabled;
};
/**
* IsCookieDisabled
*/
BrowserUtilities.prototype.IsCookieDisabled = function () {
return navigator.cookieEnabled;
};
/**
* IsJavaEnabled
*/
BrowserUtilities.prototype.IsJavaEnabled = function () {
return navigator.javaEnabled;
};
return BrowserUtilities;
}());