diff options
author | Devaev Maxim <[email protected]> | 2018-11-04 03:45:57 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-11-04 03:45:57 +0300 |
commit | bdca0e883950281da6001cbe1710842ac687c37a (patch) | |
tree | 55f3ba11a1c315585fc0d2bb91f78fc7f89636f2 /web/js/tools.js | |
parent | 63229b0e8eb4f9eb4340f3c882af172215ccf2ff (diff) |
workaround for chrome bug #527446
Diffstat (limited to 'web/js/tools.js')
-rw-r--r-- | web/js/tools.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/web/js/tools.js b/web/js/tools.js index 9f94175a..068032ac 100644 --- a/web/js/tools.js +++ b/web/js/tools.js @@ -44,6 +44,45 @@ var tools = new function() { this.info = (...args) => console.log("LOG/INFO", ...args); // eslint-disable-line no-console this.error = (...args) => console.error("LOG/ERROR", ...args); // eslint-disable-line no-console + + this.browser = new function() { + // https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser/9851769 + + // Opera 8.0+ + var is_opera = ( + (!!window.opr && !!opr.addons) // eslint-disable-line no-undef + || !!window.opera + || (navigator.userAgent.indexOf(" OPR/") >= 0) + ); + + // Firefox 1.0+ + var is_firefox = (typeof InstallTrigger !== "undefined"); + + // Safari 3.0+ "[object HTMLElementConstructor]" + var is_safari = (/constructor/i.test(window.HTMLElement) || (function (p) { + return p.toString() === "[object SafariRemoteNotification]"; + })(!window["safari"] || (typeof safari !== "undefined" && safari.pushNotification))); // eslint-disable-line no-undef + + // Chrome 1+ + var is_chrome = (!!window.chrome && !!window.chrome.webstore); + + // Blink engine detection + var is_blink = ((is_chrome || is_opera) && !!window.CSS); + + // iOS browsers + // https://stackoverflow.com/questions/9038625/detect-if-device-is-ios + var is_ios = (!!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform)); + + return { + "is_opera": is_opera, + "is_firefox": is_firefox, + "is_safari": is_safari, + "is_chrome": is_chrome, + "is_blink": is_blink, + "is_ios": is_ios, + }; + }; + this.info("Browser:", this.browser); }; var $ = (id) => document.getElementById(id); |