From bded5490d2df7824df530fdbe235acf3354160bb Mon Sep 17 00:00:00 2001 From: Steve-Mcl Date: Thu, 29 Apr 2021 17:35:11 +0100 Subject: [PATCH] add utility func getBrowserInfo - prep for monaco - for slimming down monaco on mobile - prep for monaco - needed to prevent monaco on IE --- .../editor-client/src/js/ui/utils.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js b/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js index f81c98748..35e938e49 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js @@ -1234,6 +1234,23 @@ RED.utils = (function() { } return false; } + + function getBrowserInfo() { + var r = {} + try { + var ua = navigator.userAgent; + r.ua = ua; + r.browser = /Edge\/\d+/.test(ua) ? 'ed' : /MSIE 9/.test(ua) ? 'ie9' : /MSIE 10/.test(ua) ? 'ie10' : /MSIE 11/.test(ua) ? 'ie11' : /MSIE\s\d/.test(ua) ? 'ie?' : /rv\:11/.test(ua) ? 'ie11' : /Firefox\W\d/.test(ua) ? 'ff' : /Chrom(e|ium)\W\d|CriOS\W\d/.test(ua) ? 'gc' : /\bSafari\W\d/.test(ua) ? 'sa' : /\bOpera\W\d/.test(ua) ? 'op' : /\bOPR\W\d/i.test(ua) ? 'op' : typeof MSPointerEvent !== 'undefined' ? 'ie?' : ''; + r.os = /Windows NT 10/.test(ua) ? "win10" : /Windows NT 6\.0/.test(ua) ? "winvista" : /Windows NT 6\.1/.test(ua) ? "win7" : /Windows NT 6\.\d/.test(ua) ? "win8" : /Windows NT 5\.1/.test(ua) ? "winxp" : /Windows NT [1-5]\./.test(ua) ? "winnt" : /Mac/.test(ua) ? "mac" : /Linux/.test(ua) ? "linux" : /X11/.test(ua) ? "nix" : ""; + r.touch = 'ontouchstart' in document.documentElement; + r.mobile = /IEMobile|Windows Phone|Lumia/i.test(ua) ? 'w' : /iPhone|iP[oa]d/.test(ua) ? 'i' : /Android/.test(ua) ? 'a' : /BlackBerry|PlayBook|BB10/.test(ua) ? 'b' : /Mobile Safari/.test(ua) ? 's' : /webOS|Mobile|Tablet|Opera Mini|\bCrMo\/|Opera Mobi/i.test(ua) ? 1 : 0; + r.tablet = /Tablet|iPad/i.test(ua); + r.ie = /MSIE \d|Trident.*rv:/.test(navigator.userAgent); + r.android = /android/i.test(navigator.userAgent); + } catch (error) { } + return r; + } + return { createObjectElement: buildMessageElement, getMessageProperty: getMessageProperty, @@ -1255,6 +1272,7 @@ RED.utils = (function() { createNodeIcon: createNodeIcon, getDarkerColor: getDarkerColor, parseModuleList: parseModuleList, - checkModuleAllowed: checkModuleAllowed + checkModuleAllowed: checkModuleAllowed, + getBrowserInfo: getBrowserInfo } })();