diff --git a/core/utils.js b/core/utils.js index 617d5bfdc..a97e56a8c 100644 --- a/core/utils.js +++ b/core/utils.js @@ -1051,10 +1051,12 @@ Blockly.utils.userAgent = {}; /** * Case-insensitive test of whether name is in the useragent string. * @param {string} name Name to test. + * @return {boolean} True if name is present. */ function has(name) { return rawUpper.indexOf(name.toUpperCase()) != -1; } + // Browsers. Logic from: // https://github.com/google/closure-library/blob/master/closure/goog/labs/useragent/browser.js Blockly.utils.userAgent.IE = has('Trident') || has('MSIE'); @@ -1064,13 +1066,15 @@ Blockly.utils.userAgent = {}; // Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.44 // (KHTML, like Gecko) JavaFX/8.0 Safari/537.44 Blockly.utils.userAgent.JAVA_FX = has('JavaFX'); + // Engines. Logic from: // https://github.com/google/closure-library/blob/master/closure/goog/labs/useragent/engine.js Blockly.utils.userAgent.WEBKIT = has('WebKit') && !Blockly.utils.userAgent.EDGE; Blockly.utils.userAgent.GECKO = has('Gecko') && !Blockly.utils.userAgent.IE && !Blockly.utils.userAgent.EDGE; - // Platform. Logic from: + + // Platforms. Logic from: // https://github.com/google/closure-library/blob/master/closure/goog/labs/useragent/platform.js Blockly.utils.userAgent.ANDROID = has('Android'); Blockly.utils.userAgent.IPAD = has('iPad'); @@ -1078,7 +1082,8 @@ Blockly.utils.userAgent = {}; Blockly.utils.userAgent.IPHONE = has('iPhone') && !Blockly.utils.userAgent.IPAD && !Blockly.utils.userAgent.IPOD; Blockly.utils.userAgent.MAC = has('Macintosh'); - // Device. Logic from: + + // Devices. Logic from: // https://github.com/google/closure-library/blob/master/closure/goog/labs/useragent/device.js Blockly.utils.userAgent.TABLET = Blockly.utils.userAgent.IPAD || (Blockly.utils.userAgent.ANDROID && !has('Mobile')) || has('Silk');