keeweb/app/scripts/util/features.js

41 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-07-17 21:08:23 +02:00
const MobileRegex = /iPhone|iPad|iPod|Android|BlackBerry|Opera Mini|IEMobile|WPDesktop|Windows Phone|webOS/i;
const MinDesktopScreenWidth = 800;
2017-05-28 17:30:00 +02:00
const isDesktop = !!(window.process && window.process.versions && window.process.versions.electron);
2019-09-15 08:11:11 +02:00
const Features = {
2019-08-18 10:17:09 +02:00
isDesktop,
2016-07-17 21:08:23 +02:00
isMac: navigator.platform.indexOf('Mac') >= 0,
isWindows: navigator.platform.indexOf('Win') >= 0,
isiOS: /iPad|iPhone|iPod/i.test(navigator.userAgent),
isMobile: MobileRegex.test(navigator.userAgent) || screen.width < MinDesktopScreenWidth,
2019-08-16 23:05:39 +02:00
isPopup: !!(window.parent !== window.top || window.opener),
2017-05-16 21:26:42 +02:00
isStandalone: !!navigator.standalone,
2017-08-31 18:56:11 +02:00
isFrame: window.top !== window,
2019-08-18 08:05:38 +02:00
isSelfHosted:
!isDesktop &&
!/^http(s?):\/\/((localhost:8085)|((app|beta)\.keeweb\.info))/.test(location.href),
needFixClicks: /Edge\/14/.test(navigator.appVersion),
2016-07-17 21:08:23 +02:00
2019-08-18 10:17:09 +02:00
supportsTitleBarStyles() {
2017-05-14 21:23:49 +02:00
return this.isMac;
},
2019-08-18 10:17:09 +02:00
hasUnicodeFlags() {
2017-03-26 16:46:26 +02:00
return this.isMac;
2017-05-16 22:56:52 +02:00
},
2019-08-18 10:17:09 +02:00
getBrowserCssClass() {
2019-09-08 08:25:15 +02:00
if (window.chrome && window.navigator.userAgent.indexOf('Chrome/') > -1) {
2017-05-25 21:37:04 +02:00
return 'chrome';
}
if (window.navigator.userAgent.indexOf('Edge/') > -1) {
return 'edge';
}
2019-03-28 22:31:53 +01:00
if (navigator.standalone) {
return 'standalone';
}
2017-05-25 21:37:04 +02:00
return '';
2015-10-17 23:49:24 +02:00
}
};
2019-09-15 14:16:32 +02:00
export { Features };